10 class KeyException : public std::exception
12 const char* what() {return "Key Exception";}
15 class KeyInvalidName : public KeyException
17 const char* what() {return "Invalid Keyname";}
20 /**Key represents an elektra key.*/
24 Key () :key (ckdb::keyNew (0)) { operator++(); }
25 Key (ckdb::Key *k) :key(k) { operator++(); }
26 Key (Key &k) :key (k.key) { operator++(); }
27 Key (const Key &k) :key (k.key) { operator++(); }
28 Key (const char * name, va_list ap);
29 Key (const char * name, ...);
30 Key (const std::string name, ...);
32 void del () { operator --(); ckdb::keyDel(key); }
33 void copy (const Key &other) { ckdb::keyCopy(key,other.key); }
34 void clear () { ckdb::keyCopy(key,0); }
37 void operator ++(int) { operator++(); }
38 void operator ++() { ckdb::keyIncRef(key); }
40 void operator --(int) { operator--(); }
41 void operator --() { ckdb::keyDecRef(key); }
43 bool operator ==(const Key &k) const { return key == k.key; }
51 std::istringstream ist(str);
52 ist >> x; // convert string to type
60 std::ostringstream ost;
61 ost << x; // convert type to string
62 setString (ost.str());
65 /*Passes out the pointer, maybe directly changing this object*/
66 ckdb::Key* getKey () const { return key; }
67 ckdb::Key* operator* () const { return key; }
68 ckdb::Key* dup () const { return ckdb::keyDup(getKey()); }
70 Key& operator= (ckdb::Key *k);
71 Key& operator= (const Key &k);
73 Key& operator= (const std::string &name);
74 Key& operator+= (const std::string &name);
75 Key& operator-= (const std::string &name);
77 Key& operator= (const char *name);
78 Key& operator+= (const char *name);
79 Key& operator-= (const char *name);
81 type_t getType() const;
82 void setType(type_t type = KEY_TYPE_STRING);
84 std::string getName() const;
85 const char* name() const;
86 size_t getNameSize() const;
88 std::string getBaseName() const;
89 const char* baseName() const;
90 size_t getBaseNameSize() const;
92 void setName (const std::string &name);
93 void setBaseName (const std::string &basename);
95 size_t getFullNameSize() const;
96 std::string getFullName() const;
98 std::string getComment() const;
99 const char* comment() const;
100 size_t getCommentSize() const;
101 void setComment(const std::string &comment);
103 uid_t getUID() const;
104 void setUID(uid_t uid);
106 gid_t getGID() const;
107 void setGID(gid_t gid);
109 mode_t getMode() const;
110 void setMode(mode_t mode);
112 std::string getOwner() const;
113 const char* owner() const;
114 size_t getOwnerSize() const;
115 void setOwner(const std::string &owner);
117 const void* value() const;
118 size_t getValueSize() const;
120 std::string getString() const;
121 void setString(std::string newString);
123 size_t getBinary(void *returnedBinary, size_t maxSize) const;
124 size_t setBinary(const void *newBinary, size_t dataSize);
128 void setMTime(time_t time);
129 void setATime(time_t time);
130 void setCTime(time_t time);
132 time_t getMTime() const;
133 time_t getATime() const;
134 time_t getCTime() const;
136 bool isSystem() const;
139 int getNamespace() const;
140 size_t getReference() const;
143 bool isString() const;
144 bool isBinary() const;
146 bool isInactive() const;
147 bool isBelow(const Key &k) const;
148 bool isDirectBelow(const Key &k) const;
150 bool needSync() const;
151 bool needRemove() const;
152 bool needStat() const;
158 ssize_t toStream(FILE* stream = stdout, unsigned long options = 0) const;
159 ssize_t output(FILE* stream = stdout, unsigned long options = 0) const;
160 ssize_t generate(FILE* stream = stdout, unsigned long options = 0) const;
163 friend std::ostream & operator << (std::ostream & os, const Key &d);
164 friend std::istream & operator >> (std::istream & os, Key &d);
167 ckdb::Key * key; // holds elektra key struct
170 } // end of namespace kdb