Switch to unified view

a/src/query/dynconf.cpp b/src/query/dynconf.cpp
...
...
23
#include "dynconf.h"
23
#include "dynconf.h"
24
#include "base64.h"
24
#include "base64.h"
25
#include "smallut.h"
25
#include "smallut.h"
26
#include "debuglog.h"
26
#include "debuglog.h"
27
27
28
#ifndef NO_NAMESPACES
29
using namespace std;
28
using namespace std;
30
#endif
31
29
32
// Well known keys for history and external indexes.
30
// Well known keys for history and external indexes.
33
const string docHistSubKey = "docs";
31
const string docHistSubKey = "docs";
34
const string allEdbsSk = "allExtDbs";
32
const string allEdbsSk = "allExtDbs";
35
const string actEdbsSk = "actExtDbs";
33
const string actEdbsSk = "actExtDbs";
34
const string advSearchHistSk = "advSearchHist";
36
35
37
36
38
// @param sk section this is for
39
// @param n  new entry
40
// @param s a scratch entry used for decoding and comparisons. 
41
//    This avoids templating this routine for the actual entry type.
42
bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
37
bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
43
    int maxlen)
38
             int maxlen)
44
{
39
{
45
    // Is this doc already in list ? If it is we remove the old entry
40
    // Is this doc already in list ? If it is we remove the old entry
46
    vector<string> names = m_data.getNames(sk);
41
    vector<string> names = m_data.getNames(sk);
47
    vector<string>::const_iterator it;
42
    vector<string>::const_iterator it;
48
    bool changed = false;
43
    bool changed = false;
...
...
96
bool RclDynConf::eraseAll(const string &sk)
91
bool RclDynConf::eraseAll(const string &sk)
97
{
92
{
98
    vector<string> names = m_data.getNames(sk);
93
    vector<string> names = m_data.getNames(sk);
99
    vector<string>::const_iterator it;
94
    vector<string>::const_iterator it;
100
    for (it = names.begin(); it != names.end(); it++) {
95
    for (it = names.begin(); it != names.end(); it++) {
101
        m_data.erase(*it, sk);
96
    m_data.erase(*it, sk);
102
    }
97
    }
103
    return true;
98
    return true;
104
}
99
}
105
100
106
101
107
// Generic string list specialization ///////////////////////////////////
102
// Specialization for plain strings ///////////////////////////////////
108
103
109
// Encode/decode simple string. base64 used to avoid problems with
110
// strange chars
111
bool RclSListEntry::encode(string& enc)
112
{
113
    base64_encode(value, enc);
114
    return true;
115
}
116
bool RclSListEntry::decode(const string &enc)
117
{
118
    base64_decode(enc, value);
119
    return true;
120
}
121
bool RclSListEntry::equal(const DynConfEntry& other)
122
{
123
    const RclSListEntry& e = dynamic_cast<const RclSListEntry&>(other);
124
    return e.value == value;
125
}
126
bool RclDynConf::enterString(const string sk, const string value, int maxlen)
104
bool RclDynConf::enterString(const string sk, const string value, int maxlen)
127
{
105
{
128
    RclSListEntry ne(value);
106
    RclSListEntry ne(value);
129
    RclSListEntry scratch;
107
    RclSListEntry scratch;
130
    return insertNew(sk, ne, scratch, maxlen);
108
    return insertNew(sk, ne, scratch, maxlen);
131
}
109
}
110
132
list<string> RclDynConf::getStringList(const string sk) 
111
list<string> RclDynConf::getStringList(const string sk) 
133
{
112
{
134
    list<RclSListEntry> el = getList<RclSListEntry>(sk);
113
    list<RclSListEntry> el = getList<RclSListEntry>(sk);
135
    list<string> sl;
114
    list<string> sl;
136
    for (list<RclSListEntry>::const_iterator it = el.begin(); 
115
    for (list<RclSListEntry>::const_iterator it = el.begin();