certmanager/lib

dn.h
1 /*
2  dn.h
3 
4  This file is part of libkleopatra, the KDE keymanagement library
5  Copyright (c) 2004 Klarälvdalens Datakonsult AB
6 
7  Libkleopatra is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of the
10  License, or (at your option) any later version.
11 
12  Libkleopatra is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the TQt library by Trolltech AS, Norway (or with modified versions
24  of TQt that use the same license as TQt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  TQt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #ifndef __KLEO_DN_H__
34 #define __KLEO_DN_H__
35 
36 #include <tqstring.h>
37 #include <tqvaluevector.h>
38 #include <tdemacros.h>
39 
40 class TQStringList;
41 class TQWidget;
42 
43 namespace Kleo {
44  class DNAttributeOrderConfigWidget;
45 }
46 
47 namespace Kleo {
48 
52  class TDE_EXPORT DNAttributeMapper {
55  public:
56  static const DNAttributeMapper * instance();
57 
58  TQString name2label( const TQString & s ) const;
59  TQStringList names() const;
60 
61  const TQStringList & attributeOrder() const;
62 
63  void setAttributeOrder( const TQStringList & order );
64 
65  DNAttributeOrderConfigWidget * configWidget( TQWidget * parent=0, const char * name=0 ) const;
66 
67  private:
68  class Private;
69  Private * d;
70  static DNAttributeMapper * mSelf;
71  };
72 
76  class TDE_EXPORT DN {
77  public:
78  class Attribute;
79  typedef TQValueVector<Attribute> AttributeList;
80  typedef AttributeList::const_iterator const_iterator;
81 
82  DN();
83  DN( const TQString & dn );
84  DN( const char * utf8DN );
85  DN( const DN & other );
86  ~DN();
87 
88  const DN & operator=( const DN & other );
89 
91  static TQString escape( const TQString & value );
92 
95  TQString prettyDN() const;
97  TQString dn() const;
98 
99  TQString operator[]( const TQString & attr ) const;
100 
101  void append( const Attribute & attr );
102 
103  const_iterator begin() const;
104  const_iterator end() const;
105 
106  private:
107  void detach();
108  private:
109  class Private;
110  Private * d;
111  };
112 
113  class TDE_EXPORT DN::Attribute {
114  public:
115  typedef DN::AttributeList List;
116 
117  Attribute( const TQString & name=TQString(), const TQString & value=TQString() )
118  : mName( name.upper() ), mValue( value ) {}
119  Attribute( const Attribute & other )
120  : mName( other.name() ), mValue( other.value() ) {}
121 
122  const Attribute & operator=( const Attribute & other ) {
123  if ( this != &other ) {
124  mName = other.name();
125  mValue = other.value();
126  }
127  return *this;
128  }
129 
130  const TQString & name() const { return mName; }
131  const TQString & value() const { return mValue; }
132 
133  void setValue( const TQString & value ) { mValue = value; }
134 
135  private:
136  TQString mName;
137  TQString mValue;
138  };
139 
140 }
141 
142 #endif // __KLEO_DN_H__
DN Attribute mapper.
Definition: dn.h:52
DN parser and reorderer.
Definition: dn.h:76