Skip to content

Commit af25d87

Browse files
author
Tony Li
committed
New src folder for new feature testing
1 parent bf51d93 commit af25d87

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+14976
-0
lines changed
16 KB
Binary file not shown.

src-test/ConfEntry.cpp

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* Copyright 2010-2020 [email protected](http://datasys.cs.iit.edu/index.html)
3+
* Director: Ioan Raicu([email protected])
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
* This file is part of ZHT library(http://datasys.cs.iit.edu/projects/ZHT/index.html).
18+
* Tonglin Li([email protected]) with nickname Tony,
19+
* Xiaobing Zhou([email protected]) with nickname Xiaobingo,
20+
* Ke Wang([email protected]) with nickname KWang,
21+
* Dongfang Zhao(dzhao8@@hawk.iit.edu) with nickname DZhao,
22+
* Ioan Raicu([email protected]).
23+
*
24+
* ConfEntry.cpp
25+
*
26+
* Created on: Aug 7, 2012
27+
* Author: Xiaobingo
28+
* Contributor: Tony, KWang, DZhao
29+
*/
30+
31+
#include "ConfEntry.h"
32+
33+
#include "Const-impl.h"
34+
35+
#include <stdio.h>
36+
#include <string.h>
37+
38+
namespace iit {
39+
namespace datasys {
40+
namespace zht {
41+
namespace dm {
42+
43+
ConfEntry::ConfEntry() {
44+
45+
}
46+
47+
ConfEntry::ConfEntry(const string& sconfigEntry) {
48+
49+
assign(sconfigEntry);
50+
}
51+
52+
ConfEntry::ConfEntry(const string& name, const string& value) :
53+
_name(name), _value(value) {
54+
55+
}
56+
57+
ConfEntry::~ConfEntry() {
58+
59+
}
60+
61+
string ConfEntry::name() const {
62+
63+
return _name;
64+
}
65+
66+
void ConfEntry::name(const string& name) {
67+
68+
_name = name;
69+
}
70+
71+
string ConfEntry::value() const {
72+
73+
return _value;
74+
}
75+
76+
void ConfEntry::value(const string& value) {
77+
78+
_value = value;
79+
}
80+
81+
string ConfEntry::operator()() const {
82+
83+
return toString();
84+
}
85+
86+
string ConfEntry::toString() const {
87+
88+
char buf[50];
89+
memset(buf, 0, sizeof(buf));
90+
int n = sprintf(buf, getFormat().c_str(), _name.c_str(), _value.c_str());
91+
92+
string result(buf, 0, n);
93+
94+
return result;
95+
}
96+
97+
ConfEntry& ConfEntry::assign(string sconfigEntry) {
98+
99+
const char* delimiter = ",";
100+
101+
string remains = Const::trim(sconfigEntry);
102+
103+
size_t found = remains.find(delimiter);
104+
105+
if (found != string::npos) {
106+
107+
name(Const::trim(remains.substr(0, int(found))));
108+
value(Const::trim(remains.substr(int(found) + 1)));
109+
}
110+
111+
return *this;
112+
}
113+
114+
string ConfEntry::getFormat() {
115+
116+
return "%s,%s";
117+
}
118+
119+
} /* namespace dm */
120+
} /* namespace zht */
121+
} /* namespace datasys */
122+
} /* namespace iit */

src-test/ConfEntry.h

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2010-2020 [email protected](http://datasys.cs.iit.edu/index.html)
3+
* Director: Ioan Raicu([email protected])
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
* This file is part of ZHT library(http://datasys.cs.iit.edu/projects/ZHT/index.html).
18+
* Tonglin Li([email protected]) with nickname Tony,
19+
* Xiaobing Zhou([email protected]) with nickname Xiaobingo,
20+
* Ke Wang([email protected]) with nickname KWang,
21+
* Dongfang Zhao(dzhao8@@hawk.iit.edu) with nickname DZhao,
22+
* Ioan Raicu([email protected]).
23+
*
24+
* ConfEntry.h
25+
*
26+
* Created on: Aug 7, 2012
27+
* Author: Xiaobingo
28+
* Contributor: Tony, KWang, DZhao
29+
*/
30+
31+
#ifndef CONFIGENTRY_H_
32+
#define CONFIGENTRY_H_
33+
34+
#include <string>
35+
using namespace std;
36+
37+
namespace iit {
38+
namespace datasys {
39+
namespace zht {
40+
namespace dm {
41+
42+
/*
43+
*
44+
*/
45+
class ConfEntry {
46+
public:
47+
ConfEntry();
48+
ConfEntry(const string& sConfigEntry);
49+
ConfEntry(const string& name, const string& value);
50+
virtual ~ConfEntry();
51+
52+
string name() const;
53+
void name(const string& name);
54+
55+
string value() const;
56+
void value(const string& value);
57+
58+
string operator()() const;
59+
string toString() const;
60+
ConfEntry& assign(string sconfigEntry);
61+
62+
static string getFormat();
63+
64+
private:
65+
string _name;
66+
string _value;
67+
};
68+
69+
} /* namespace dm */
70+
} /* namespace zht */
71+
} /* namespace datasys */
72+
} /* namespace iit */
73+
#endif /* CONFIGENTRY_H_ */

0 commit comments

Comments
 (0)