-
Notifications
You must be signed in to change notification settings - Fork 0
/
SubVals.cpp
36 lines (36 loc) · 853 Bytes
/
SubVals.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
#include "Vals.h"
#include "SubVals.h"
using namespace std;
namespace sict{
SubVal::SubVal(std::string& key, Vals& value){
_key = key;
_value = value;
}
void SubVals::add(string key, Vals value){
_vals.push_back(SubVal(key, value));
}
string& SubVals::operator[](int index){
return _vals[index % _vals.size()]._key;
}
bool SubVals::exist(const char* key)const{
bool ret = false;
unsigned i = 0;
for (i = 0; ret == false && i < _vals.size(); i++){
ret = (_vals[i]._key == key);
}
return ret;
}
Vals& SubVals::operator[](const char* key){
Vals* sv = &_nothing;
unsigned i = 0;
for (i = 0; i < _vals.size() && sv->size() == 0; i++){
if (_vals[i]._key == key){
sv = &_vals[i]._value;
}
}
return *sv;
}
int SubVals::size(){
return _vals.size();
}
}