Added an option to iterate over a bulk

This commit is contained in:
WolverinDEV
2020-02-02 19:36:30 +01:00
parent fc934520a5
commit 8f7d980a6a
3 changed files with 48 additions and 11 deletions
+19 -9
View File
@@ -7,6 +7,7 @@
#include <sstream>
#include <src/License.h>
#include <functional>
#include <src/query/Command.h>
#include "PermissionManager.h"
#include "src/query/command_handler.h"
@@ -68,6 +69,19 @@ void eval_test(command_result x) {
}
}
void print_entries(const ts::command_parser& parser) {
size_t index;
std::string_view key{};
std::string value{};
for(const auto& bulk : parser.bulks()) {
std::cout << "----\n";
index = 0;
while(bulk.next_entry(index, key, value)) {
std::cout << " " << key << " => " << value << "\n";
}
}
}
int main() {
ts::command_handler::impl::field<tl("A"), int>::as_bulked<false> a;
std::cout << "Optional: " << a.is_optional() << "\n";
@@ -118,16 +132,12 @@ int main() {
ts::command cmd("notify");
*/
/*
cout << ts::command::parse("test a=b ").build(ts::command::format::BRACE_ESCAPED_QUERY) << endl;
cout << ts::command::parse("test a=").build(ts::command::format::BRACE_ESCAPED_QUERY) << endl;
cout << ts::command::parse("test a").build(ts::command::format::BRACE_ESCAPED_QUERY) << endl;
cout << ts::command::parse("a=c", false).build(ts::command::format::BRACE_ESCAPED_QUERY) << endl;
cout << ts::command::parse("a=c | a=c -x", false).build(ts::command::format::BRACE_ESCAPED_QUERY) << endl;
cout << ts::command::parse("a a=c|a=c").build(ts::command::format::BRACE_ESCAPED_QUERY) << endl;
cout << ts::command::parse("a a=c a=c2 -z | -? a=c").build(ts::command::format::BRACE_ESCAPED_QUERY) << endl;
*/
auto command = ts::command_parser{"a a=c a=c2 -z |-? a=2 key_c=c"};
if(!command.parse(true)) return 1;
print_entries(command);
return 0;
std::cout << "Command v3:\n";
{
auto command = ts::command_parser{"a a=c a=c2 -z | -? a=2 key_c=c"};