-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsltest.cpp
132 lines (115 loc) · 3.4 KB
/
sltest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
Copyright (C) 2014,2015 Blaise Dias
This file is part of sqzbsrv.
sqzbsrv is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
sqzbsrv is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with sqzbsrv. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstdio>
#include <cstring>
#include <clocale>
#include <iostream>
#include <unordered_map>
#include <vector>
#include <stdlib.h>
#include <memory>
#include <fstream>
#include <boost/serialization/vector.hpp>
#include "dbstring.h"
#include "dbstring_boost_serialization.h"
#include "stringlist.hpp"
using benedias::memdb::dbstring;
using benedias::memdb::dbstring_iterator;
using benedias::sharedobj_ptr;
const char* strs1[] = {
"pqr",
"stu",
"vwx",
"abc",
"def",
"ghi",
"jkl",
"mno",
"yz"
};
const char* strs2[] = {
"def",
"jkl",
"pqr",
"vwx",
};
const char* strs3[] = {
"abc",
"ghi",
"mno",
"stu",
"yz"
};
void populate0(const char** teststrs, unsigned num, std::vector<sharedobj_ptr<dbstring>>& v)
{
std::cout << std::endl << "populate {" << std::endl;
for (unsigned i = 0; i < num; i++)
{
v.push_back(dbstring::make_sharedobj(teststrs[i]));
}
for(auto it = v.cbegin(); it != v.end(); ++it)
{
std::cout << (*it).self() << " " << (*it)->std_str() << " " << (*it)->size() << std::endl;
}
std::cout << "} populate" << std::endl;
}
void iterate0()
{
{
std::cout << std::endl << "iterate {" << std::endl;
for(dbstring_iterator itr = dbstring::begin();
itr != dbstring::end(); ++itr)
{
std::cout << (*itr)->c_str() << std::endl;
}
std::cout << "} iterate" << std::endl << std::endl;
}
}
void dump(std::vector<sharedobj_ptr<dbstring>>& v)
{
std::cout << std::endl << "dump {" << std::endl;
for(auto it = v.cbegin(); it != v.end(); ++it)
{
std::cout << (*it).self() << " " << (*it)->std_str() << " " << (*it)->size() << std::endl;
}
std::cout << "} dump" << std::endl;
}
int main(int argc, char* argv[] )
{
{
#if 0
std::vector<sharedobj_ptr<dbstring>> vdbs;
populate0(strs1, sizeof(strs1)/sizeof(*strs1), vdbs);
dump(vdbs);
#else
auto spdbs = dbstring::make_sharedobj("ZZZ");
std::cout << "hash(spdbs) " << std::hash<sharedobj_ptr<dbstring>>()(spdbs) << std::endl;
dbstring& rdbs = *(spdbs.get());
std::cout << "rdbs " << rdbs << std::endl;
std::cout << "spdbs.get() " << spdbs.get() << std::endl;
std::cout << "spdbs->c_str() " << spdbs->c_str() << std::endl;
const char* cstr = rdbs;
std::string stdstr = rdbs;
std::cout << "cstr " << cstr << std::endl;
std::cout << "stdstr " << stdstr << std::endl;
#endif
}
std::cout << "------------------------" << std::endl;
std::cout << "------------------------" << std::endl;
{
}
std::cout << "------------------------" << std::endl;
std::cout << "All Done. " << std::endl;
}