-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Is it possible toGet()
an element of a Store as a vector<string>
? I see that Get()
has a specific function for when you get it as a string
, but there is no such specialist function for vector<string>
, so it's maybe not correctly setup yet? Or maybe I just don't understand how to define the vector in the config file correctly?
What I've found is
- You should define a vector inside
[]
, and use,
as a separator - Quotes are optional
- Given the output of
Print()
&Get()
it seems that[Monday, Tuesday]
or["Monday", "Tuesday"]
are both valid syntax
And specifically the errors
- I don't see a way of getting the first element of the vector without a prefix of
[
- If you have a space, everything after the space (before the next
,
or]
) is ignored
Click for a test program & output
g++ -std=c++14 ../../test_store2.cxx -o test_store2 -I include/ -L lib/ -lStore && ./test_store2
test_store2.cxx
#include "Store.h"
#include <iostream>
#include <string>
#include <vector>
void testit(ToolFramework::Store s, std::string variable) {
std::vector<std::string> v;
std::cout << std::endl << variable << "? " << s.Get(variable, v) << std::endl;
for(const auto & val : v)
std::cout << val << std::endl;
}
int main() {
//Setup a store & fill it
ToolFramework::Store s1;
s1.Initialise("testconfig");
s1.Print();
for(int i = 0; i <= 20; i++) {
std::stringstream ss;
ss << "test" << i;
testit(s1, ss.str());
}
}
testconfig
test1 Monday
test2 [Monday]
test3 ["Monday"]
test4 [ Monday ]
test5 [ Monday]
test6 [ "Monday"]
test7 [ "Monday" ]
test8 Monday Tuesday
test9 [Monday Tuesday]
test10 [Monday, Tuesday]
test11 ["Monday", "Tuesday"]
test12 ["Monday Tuesday"]
Giving output
test1 => "Monday"
test10 => "[Monday, Tuesday]"
test11 => "["Monday", "Tuesday"]"
test12 => "["Monday Tuesday"]"
test2 => "[Monday]"
test3 => "["Monday"]"
test4 => "[ Monday ]"
test5 => "[ Monday]"
test6 => "[ "Monday"]"
test7 => "[ "Monday" ]"
test8 => "Monday Tuesday"
test9 => "[Monday Tuesday]"
test0? 0
test1? 0
test2? 1
[Monday
test3? 1
[Monday
test4? 1
[
test5? 1
[
test6? 1
[
test7? 1
[
test8? 0
test9? 1
[Monday
test10? 1
[Monday
Tuesday
test11? 1
[Monday
Tuesday
test12? 1
[Monday
Metadata
Metadata
Assignees
Labels
No labels