libkleo
dn.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __KLEO_DN_H__
00034 #define __KLEO_DN_H__
00035
00036 #include "kleo/kleo_export.h"
00037
00038 #include <QtCore/QString>
00039 #include <QtCore/QVector>
00040
00041 class QStringList;
00042 class QWidget;
00043
00044 namespace Kleo {
00045 class DNAttributeOrderConfigWidget;
00046 }
00047
00048 namespace Kleo {
00049
00053 class KLEO_EXPORT DNAttributeMapper {
00054 DNAttributeMapper();
00055 ~DNAttributeMapper();
00056 public:
00057 static const DNAttributeMapper * instance();
00058
00059 QString name2label( const QString & s ) const;
00060 QStringList names() const;
00061
00062 const QStringList & attributeOrder() const;
00063
00064 void setAttributeOrder( const QStringList & order );
00065
00066 DNAttributeOrderConfigWidget * configWidget( QWidget * parent=0 ) const;
00067
00068 private:
00069 class Private;
00070 Private * d;
00071 static DNAttributeMapper * mSelf;
00072 };
00073
00077 class KLEO_EXPORT DN {
00078 public:
00079 class Attribute;
00080 typedef QVector<Attribute> AttributeList;
00081 typedef AttributeList::const_iterator const_iterator;
00082
00083 DN();
00084 explicit DN( const QString & dn );
00085 explicit DN( const char * utf8DN );
00086 DN( const DN & other );
00087 ~DN();
00088
00089 const DN & operator=( const DN & other );
00090
00092 static QString escape( const QString & value );
00093
00096 QString prettyDN() const;
00098 QString dn() const;
00099
00100 QString operator[]( const QString & attr ) const;
00101
00102 void append( const Attribute & attr );
00103
00104 const_iterator begin() const;
00105 const_iterator end() const;
00106
00107 private:
00108 void detach();
00109 private:
00110 class Private;
00111 Private * d;
00112 };
00113
00114 class KLEO_EXPORT DN::Attribute {
00115 public:
00116 typedef DN::AttributeList List;
00117
00118 explicit Attribute( const QString & name=QString(), const QString & value=QString() )
00119 : mName( name.toUpper() ), mValue( value ) {}
00120 Attribute( const Attribute & other )
00121 : mName( other.name() ), mValue( other.value() ) {}
00122
00123 const Attribute & operator=( const Attribute & other ) {
00124 if ( this != &other ) {
00125 mName = other.name();
00126 mValue = other.value();
00127 }
00128 return *this;
00129 }
00130
00131 const QString & name() const { return mName; }
00132 const QString & value() const { return mValue; }
00133
00134 void setValue( const QString & value ) { mValue = value; }
00135
00136 private:
00137 QString mName;
00138 QString mValue;
00139 };
00140
00141 }
00142
00143 #endif // __KLEO_DN_H__