sipXcallLib home page


PtConfigDb.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 #ifndef _PtConfigDb_h_
13 #define _PtConfigDb_h_
14 
15 // SYSTEM INCLUDES
16 #include <stdio.h>
17 
18 // APPLICATION INCLUDES
19 #include "PtDefs.h"
20 
21 // DEFINES
22 // MACROS
23 // EXTERNAL FUNCTIONS
24 // EXTERNAL VARIABLES
25 // CONSTANTS
26 // STRUCTS
27 // TYPEDEFS
28 // FORWARD DECLARATIONS
29 
30 //:Configuration database containing key/value pairs.
31 // This class maintains a dictionary of key/value pairs.
32 
34 {
35 /* //////////////////////////// PUBLIC //////////////////////////////////// */
36 public:
37 
38 /* ============================ CREATORS ================================== */
39 
40  PtConfigDb();
41  //:Default constructor
42 
43  virtual
44  ~PtConfigDb();
45  //:Destructor
46 
47 /* ============================ MANIPULATORS ============================== */
48 
49  PtStatus loadFromFile(FILE* fp);
50  //:Load the configuration database from a file
53 
54  PtStatus storeToFile(FILE* fp);
55  //:Store the config database to a file
58 
59  PtStatus remove(const char* pKey);
60  //:Remove the key/value pair associated with pKey.
65 
66  PtStatus set(const char* pKey, const char* pNewValue);
67  //:Insert the key/value pair into the config database.
68  // If the database already contains an entry for this key, then
69  // set the value for the existing entry to pNewValue.
74 
75 /* ============================ ACCESSORS ================================= */
76 
77  PtStatus get(const char* pKey, char*& rpValue);
78  //:Sets <i>rpValue</i> to point to the value in the database
79  //:associated with <i>pKey</i>.
80  // If pKey is found in the database, returns PT_SUCCESS. Otherwise,
81  // returns PT_NOT_FOUND and sets rpValue to point to an empty string.
87 
88  PtStatus get(const char* pKey, int& rValue);
89  //:Sets <i>rValue</i> to the integer value in the database associated
90  //:with <i>pKey</i>.
91  // If pKey is found in the database, returns PT_SUCCESS. Otherwise,
92  // returns PT_NOT_FOUND and sets rValue to -1.
98 
99  PtStatus getNext(const char* pKey,
100  char*& rpNextKey, char*& rpNextValue);
101  //:Relative to <i>pKey</i>, sets <i>rpNextKey</i> and
102  //:<i>rpNextValue</i> to point to the key and value associated with
103  //:next (lexicographically ordered) key/value pair stored in the
104  //:database.
105  // If pKey is the empty string, the key and value associated
106  // with the first entry in the database will be returned.
114 
115 /* ============================ INQUIRY =================================== */
116 
117  PtStatus isEmpty(PtBoolean& rIsEmpty);
118  //:Sets <i>rIsEmpty</i> to TRUE if the database is empty, otherwise
119  //:FALSE.
122 
123  PtStatus numEntries(int& rNumEntries);
124  //:Sets <i>rNumEntries</i> to the number of entries in the config database
127 
128 /* //////////////////////////// PROTECTED ///////////////////////////////// */
129 protected:
130 
131 /* //////////////////////////// PRIVATE /////////////////////////////////// */
132 private:
133 
134 };
135 
136 /* ============================ INLINE METHODS ============================ */
137 
138 #endif // _PtConfigDb_h_
PtStatus getNext(const char *pKey, char *&rpNextKey, char *&rpNextValue)
param: pKey - The lookup key param: rValue - Set to the integer value corresponding to pKey retcode: ...
PtStatus
Definition: PtDefs.h:49
PtConfigDb()
Definition: PtConfigDb.cpp:28
int PtBoolean
Definition: PtDefs.h:71
Definition: PtConfigDb.h:33
PtStatus storeToFile(FILE *fp)
retcode: PT_SUCCESS - Success retcode: PT_PROVIDER_UNAVAILABLE - The provider is not available ...
PtStatus loadFromFile(FILE *fp)
PtStatus numEntries(int &rNumEntries)
retcode: PT_SUCCESS - Success retcode: PT_PROVIDER_UNAVAILABLE - The provider is not available ...
PtStatus isEmpty(PtBoolean &rIsEmpty)
param: pKey - The lookup key param: rpNextKey - Set to point to the key for the next key/value pair s...
virtual ~PtConfigDb()
Definition: PtConfigDb.cpp:33