reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
KeyValueStore.cxx
Go to the documentation of this file.
2#include "rutil/Log.hxx"
3#include "rutil/Logger.hxx"
6
7using namespace resip;
8using namespace std;
9
10#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
11
12namespace resip
13{
14
18
20 mKeyAllocator(keyAllocator)
21{
22 if(mKeyAllocator.mNextKey > 1) // Only resize if there are allocated keys
23 {
24 Value defaultValue;
25 defaultValue.dataValue = 0;
26 defaultValue.uint64Value = 0; // largest member of union - will zero out all data
27 mKeyValueStore.resize(mKeyAllocator.mNextKey, defaultValue);
28 }
29}
30
32{
33 KeyValueStoreContainer::iterator it = mKeyValueStore.begin();
34 for(; it != mKeyValueStore.end(); it++)
35 {
36 delete it->dataValue;
37 }
38}
39
42{
43 Value defaultValue;
44 defaultValue.dataValue = 0;
45 defaultValue.uint64Value = 0; // largest member of union - will zero out all data
47 mKeyValueStore.resize(key+1, defaultValue);
48 return key;
49}
50
51void
53{
54 if(mKeyValueStore[key].dataValue)
55 {
56 *mKeyValueStore[key].dataValue = value;
57 }
58 else
59 {
60 mKeyValueStore[key].dataValue = new Data(value);
61 }
62}
63
64const Data&
66{
67 if(!mKeyValueStore[key].dataValue)
68 {
69 return Data::Empty;
70 }
71 return *mKeyValueStore[key].dataValue;
72}
73
74Data&
76{
77 if(!mKeyValueStore[key].dataValue)
78 {
79 mKeyValueStore[key].dataValue = new Data();
80 }
81 return *mKeyValueStore[key].dataValue;
82}
83
85operator<<(EncodeStream& strm, const KeyValueStore& store)
86{
87 strm << "[KeyValueStore]";
88 return strm;
89}
90
91}
92
93/* ====================================================================
94 * The Vovida Software License, Version 1.0
95 *
96 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
97 *
98 * Redistribution and use in source and binary forms, with or without
99 * modification, are permitted provided that the following conditions
100 * are met:
101 *
102 * 1. Redistributions of source code must retain the above copyright
103 * notice, this list of conditions and the following disclaimer.
104 *
105 * 2. Redistributions in binary form must reproduce the above copyright
106 * notice, this list of conditions and the following disclaimer in
107 * the documentation and/or other materials provided with the
108 * distribution.
109 *
110 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
111 * and "Vovida Open Communication Application Library (VOCAL)" must
112 * not be used to endorse or promote products derived from this
113 * software without prior written permission. For written
114 * permission, please contact vocal@vovida.org.
115 *
116 * 4. Products derived from this software may not be called "VOCAL", nor
117 * may "VOCAL" appear in their name, without prior written
118 * permission of Vovida Networks, Inc.
119 *
120 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
121 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
122 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
123 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
124 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
125 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
126 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
127 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
128 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
129 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
130 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
131 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
132 * DAMAGE.
133 *
134 * ====================================================================
135 *
136 * This software consists of voluntary contributions made by Vovida
137 * Networks, Inc. and many individuals on behalf of Vovida Networks,
138 * Inc. For more information on Vovida Networks, Inc., please see
139 * <http://www.vovida.org/>.
140 *
141 */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
KeyValueStoreKeyAllocator mKeyAllocator
KeyValueStoreContainer mKeyValueStore
void setDataValue(Key key, const Data &value)
const Data & getDataValue(Key key) const
dcm! – add UnusedChecking(_enum) below;
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)
#define EncodeStream