2017-02-14 16:37:32 +08:00
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
|
2017-02-17 23:11:57 +08:00
|
|
|
#include "logging/default.hpp"
|
|
|
|
#include "logging/streams/stdout.hpp"
|
2017-02-14 16:37:32 +08:00
|
|
|
#include "query/preprocessor.hpp"
|
|
|
|
#include "utils/command_line/arguments.hpp"
|
2017-02-18 18:54:37 +08:00
|
|
|
#include "utils/string/file.hpp"
|
2017-02-14 16:37:32 +08:00
|
|
|
#include "utils/type_discovery.hpp"
|
|
|
|
#include "utils/variadic/variadic.hpp"
|
|
|
|
|
|
|
|
using utils::println;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Useful when somebody wants to get a hash for some query.
|
|
|
|
*
|
|
|
|
* Usage:
|
|
|
|
* ./query_hash -q "CREATE (n {name: \"test\n"}) RETURN n"
|
|
|
|
*/
|
2017-02-18 18:54:37 +08:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
logging::init_sync();
|
|
|
|
logging::log->pipe(std::make_unique<Stdout>());
|
|
|
|
|
|
|
|
// init args
|
|
|
|
REGISTER_ARGS(argc, argv);
|
|
|
|
|
|
|
|
// take query from input args
|
|
|
|
auto query = GET_ARG("-q", "CREATE (n) RETURN n").get_string();
|
|
|
|
|
|
|
|
// run preprocessing
|
|
|
|
QueryPreprocessor preprocessor;
|
|
|
|
auto preprocessed = preprocessor.preprocess(query);
|
|
|
|
|
|
|
|
// print query, stripped query, hash and variable values (propertie values)
|
|
|
|
println("Query: ", query);
|
|
|
|
println("Stripped query: ", preprocessed.query);
|
|
|
|
println("Query hash: ", preprocessed.hash);
|
|
|
|
println("Property values:");
|
2017-03-08 21:11:05 +08:00
|
|
|
for (int i = 0; i < preprocessed.arguments.Size(); ++i)
|
|
|
|
println(" ", preprocessed.arguments.At(i));
|
2017-02-18 18:54:37 +08:00
|
|
|
println("");
|
|
|
|
|
|
|
|
return 0;
|
2017-02-14 16:37:32 +08:00
|
|
|
}
|