00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CONFIGDECLARATION_H
00016 #define CONFIGDECLARATION_H
00017
00018 #include "dtoolbase.h"
00019 #include "configFlags.h"
00020 #include "configPage.h"
00021 #include "vector_string.h"
00022 #include "numeric_types.h"
00023
00024 #include <vector>
00025
00026 class ConfigVariableCore;
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class EXPCL_DTOOLCONFIG ConfigDeclaration : public ConfigFlags {
00037 private:
00038 ConfigDeclaration(ConfigPage *page, ConfigVariableCore *variable,
00039 const string &string_value, int decl_seq);
00040 ~ConfigDeclaration();
00041
00042 public:
00043 INLINE bool operator < (const ConfigDeclaration &other) const;
00044
00045 PUBLISHED:
00046 INLINE ConfigPage *get_page() const;
00047 INLINE ConfigVariableCore *get_variable() const;
00048
00049 INLINE const string &get_string_value() const;
00050 INLINE void set_string_value(const string &value);
00051
00052 INLINE int get_num_words() const;
00053
00054 INLINE bool has_string_word(int n) const;
00055 INLINE bool has_bool_word(int n) const;
00056 INLINE bool has_int_word(int n) const;
00057 INLINE bool has_int64_word(int n) const;
00058 INLINE bool has_double_word(int n) const;
00059
00060 INLINE string get_string_word(int n) const;
00061 INLINE bool get_bool_word(int n) const;
00062 INLINE int get_int_word(int n) const;
00063 INLINE PN_int64 get_int64_word(int n) const;
00064 INLINE double get_double_word(int n) const;
00065
00066 void set_string_word(int n, const string &value);
00067 void set_bool_word(int n, bool value);
00068 void set_int_word(int n, int value);
00069 void set_int64_word(int n, PN_int64 value);
00070 void set_double_word(int n, double value);
00071
00072 INLINE int get_decl_seq() const;
00073
00074 void output(ostream &out) const;
00075 void write(ostream &out) const;
00076
00077 public:
00078 static int extract_words(const string &str, vector_string &words);
00079 static string downcase(const string &s);
00080
00081 private:
00082 void get_words();
00083 void check_bool_word(int n);
00084 void check_int_word(int n);
00085 void check_int64_word(int n);
00086 void check_double_word(int n);
00087
00088 private:
00089 ConfigPage *_page;
00090 ConfigVariableCore *_variable;
00091 string _string_value;
00092 int _decl_seq;
00093
00094 enum WordFlags {
00095 F_checked_bool = 0x0001,
00096 F_valid_bool = 0x0002,
00097 F_checked_int = 0x0004,
00098 F_valid_int = 0x0008,
00099 F_checked_double = 0x0010,
00100 F_valid_double = 0x0020,
00101 F_checked_int64 = 0x0040,
00102 F_valid_int64 = 0x0080,
00103 };
00104
00105 class Word {
00106 public:
00107 string _str;
00108 bool _bool;
00109 int _int;
00110 PN_int64 _int_64;
00111 double _double;
00112 short _flags;
00113 };
00114
00115 typedef vector<Word> Words;
00116 Words _words;
00117 bool _got_words;
00118
00119 friend class ConfigPage;
00120 };
00121
00122 INLINE ostream &operator << (ostream &out, const ConfigDeclaration &decl);
00123
00124 #include "configDeclaration.I"
00125
00126 #endif