├── .gitignore ├── JSONCompare ├── CMakeLists.txt ├── JSONCompare.cpp ├── JSONgrep.cpp ├── TraverseJSON.cpp └── TraverseJSON.h ├── LANGUAGE-REFERENCE.adoc ├── LICENSE ├── README.md ├── TUTORIAL.adoc ├── libs ├── rapidjson │ ├── allocators.h │ ├── cursorstreamwrapper.h │ ├── document.h │ ├── encodedstream.h │ ├── encodings.h │ ├── error │ │ ├── en.h │ │ └── error.h │ ├── filereadstream.h │ ├── filewritestream.h │ ├── fwd.h │ ├── internal │ │ ├── biginteger.h │ │ ├── clzll.h │ │ ├── diyfp.h │ │ ├── dtoa.h │ │ ├── ieee754.h │ │ ├── itoa.h │ │ ├── meta.h │ │ ├── pow10.h │ │ ├── regex.h │ │ ├── stack.h │ │ ├── strfunc.h │ │ ├── strtod.h │ │ └── swap.h │ ├── istreamwrapper.h │ ├── license.txt │ ├── memorybuffer.h │ ├── memorystream.h │ ├── msinttypes │ │ ├── inttypes.h │ │ └── stdint.h │ ├── ostreamwrapper.h │ ├── pointer.h │ ├── prettywriter.h │ ├── rapidjson.h │ ├── reader.h │ ├── schema.h │ ├── stream.h │ ├── stringbuffer.h │ ├── uri.h │ └── writer.h └── shared │ └── version.h ├── tests ├── expected │ ├── employee_query1.unq │ ├── employee_query1.unq.errors │ ├── employee_query10.unq │ ├── employee_query10.unq.errors │ ├── employee_query10.unq.errors~ │ ├── employee_query10a.unq │ ├── employee_query10a.unq.errors │ ├── employee_query11.unq │ ├── employee_query11.unq.errors │ ├── employee_query11a.unq │ ├── employee_query11a.unq.errors │ ├── employee_query12.unq │ ├── employee_query12.unq.errors │ ├── employee_query12a.unq │ ├── employee_query12a.unq.errors │ ├── employee_query12b.unq │ ├── employee_query12b.unq.errors │ ├── employee_query13.unq │ ├── employee_query13.unq.errors │ ├── employee_query14.unq │ ├── employee_query14.unq.errors │ ├── employee_query14a.unq │ ├── employee_query14a.unq.errors │ ├── employee_query15.unq │ ├── employee_query15.unq.errors │ ├── employee_query15a.unq │ ├── employee_query15a.unq.errors │ ├── employee_query15b.unq │ ├── employee_query15b.unq.errors │ ├── employee_query16.unq │ ├── employee_query16.unq.errors │ ├── employee_query16a.unq │ ├── employee_query16a.unq.errors │ ├── employee_query17.unq │ ├── employee_query17.unq.errors │ ├── employee_query17a.unq │ ├── employee_query17a.unq.errors │ ├── employee_query17b.unq │ ├── employee_query17b.unq.errors │ ├── employee_query17c.unq │ ├── employee_query17c.unq.errors │ ├── employee_query17d.unq │ ├── employee_query17d.unq.errors │ ├── employee_query18.unq │ ├── employee_query18.unq.errors │ ├── employee_query19.unq │ ├── employee_query19.unq.errors │ ├── employee_query2.unq │ ├── employee_query2.unq.errors │ ├── employee_query20.unq │ ├── employee_query20.unq.errors │ ├── employee_query20a.unq │ ├── employee_query20a.unq.errors │ ├── employee_query21.unq │ ├── employee_query21.unq.errors │ ├── employee_query3.unq │ ├── employee_query3.unq.errors │ ├── employee_query4.unq │ ├── employee_query4.unq.errors │ ├── employee_query5.unq │ ├── employee_query5.unq.errors │ ├── employee_query6.unq │ ├── employee_query6.unq.errors │ ├── employee_query7.unq │ ├── employee_query7.unq.errors │ ├── employee_query8.unq │ ├── employee_query8.unq.errors │ ├── employee_query9.unq │ ├── employee_query9.unq.errors │ ├── employee_tolowerkeys.unq │ ├── employee_tolowerkeys.unq.errors │ ├── extra_test1.unq │ ├── extra_test2.unq │ ├── parsing_aggregate.unq │ ├── parsing_aggregate.unq.errors │ ├── parsing_aggregateCond.unq │ ├── parsing_aggregateCond.unq.errors │ ├── parsing_aggregatebadcond.unq │ ├── parsing_aggregatebadcond.unq.errors │ ├── parsing_compare_field_names.unq │ ├── parsing_compare_field_names.unq.errors │ ├── parsing_conditions.unq │ ├── parsing_conditions.unq.errors │ ├── parsing_emptyquotes.unq │ ├── parsing_emptyquotes.unq.errors │ ├── parsing_float.unq │ ├── parsing_float.unq.errors │ ├── parsing_functiondefinedtwice.unq │ ├── parsing_functiondefinedtwice.unq.errors │ ├── parsing_functionnotdefined.unq │ ├── parsing_functionnotdefined.unq.errors │ ├── parsing_integer.unq │ ├── parsing_integer.unq.errors │ ├── parsing_openbacktick.unq │ ├── parsing_openbacktick.unq.errors │ ├── parsing_openquote.unq │ ├── parsing_openquote.unq.errors │ ├── parsing_opensinglequote.unq │ ├── parsing_opensinglequote.unq.errors │ ├── parsing_stringconst.unq │ ├── parsing_stringconst.unq.errors │ ├── parsing_stringconst2.unq │ ├── parsing_stringconst2.unq.errors │ ├── parsing_var_good.unq │ ├── parsing_var_good.unq.errors │ ├── stackoverflow_18592173.unq │ ├── stackoverflow_18592173.unq.errors │ ├── stackoverflow_19441454.unq │ ├── stackoverflow_19441454.unq.errors │ ├── stackoverflow_19529688.unq │ ├── stackoverflow_19529688.unq.errors │ ├── stackoverflow_26701538.unq │ ├── stackoverflow_26701538.unq.errors │ ├── stackoverflow_32381023.unq │ ├── stackoverflow_32381023.unq.errors │ ├── stackoverflow_32931471.unq │ ├── stackoverflow_32931471.unq.errors │ ├── stackoverflow_32931471a.unq │ ├── stackoverflow_32931471a.unq.errors │ ├── stackoverflow_33895076.unq │ ├── stackoverflow_33895076.unq.errors │ ├── stackoverflow_35876490.unq │ ├── stackoverflow_35876490.unq.errors │ ├── stackoverflow_38121740.unq │ ├── stackoverflow_38121740.unq.errors │ ├── stackoverflow_49284942.unq │ ├── stackoverflow_49284942.unq.errors │ ├── stackoverflow_53768947.unq │ ├── stackoverflow_53768947.unq.errors │ ├── stackoverflow_54199974.unq │ ├── stackoverflow_54199974.unq.errors │ ├── stackoverflow_60642449.unq │ ├── stackoverflow_60642449.unq.errors │ ├── stackoverflow_61331916.unq │ ├── stackoverflow_61331916.unq.errors │ ├── stackoverflow_63264954.unq │ ├── stackoverflow_63264954.unq.errors │ ├── stackoverflow_69137721.unq │ ├── stackoverflow_69137721.unq.errors │ ├── stackoverflow_69289006.unq │ ├── stackoverflow_69289006.unq.errors │ ├── stackoverflow_70097992.unq │ ├── stackoverflow_70097992.unq.errors │ ├── stackoverflow_71517326.unq │ ├── stackoverflow_71517326.unq.errors │ ├── stackoverflow_73048140.unq │ └── stackoverflow_73048140.unq.errors ├── extra │ ├── test1.json │ ├── test1.unq │ ├── test2.json │ └── test2.unq ├── parsing │ ├── aggregate.unq │ ├── aggregateCond.unq │ ├── aggregatebadcond.unq │ ├── compare_field_names.unq │ ├── conditions.unq │ ├── emptyquotes.unq │ ├── float.unq │ ├── functiondefinedtwice.unq │ ├── functionnotdefined.unq │ ├── integer.unq │ ├── openbacktick.unq │ ├── openquote.unq │ ├── opensinglequote.unq │ ├── stringconst.unq │ ├── stringconst2.unq │ └── var_good.unq ├── stackoverflow │ ├── 18592173.json │ ├── 18592173.unq │ ├── 19441454.json │ ├── 19441454.unq │ ├── 19529688.json │ ├── 19529688.unq │ ├── 26701538.json │ ├── 26701538.unq │ ├── 32381023.json │ ├── 32381023.unq │ ├── 32931471.json │ ├── 32931471.unq │ ├── 32931471a.json │ ├── 32931471a.unq │ ├── 33895076.json │ ├── 33895076.unq │ ├── 35876490.json │ ├── 35876490.unq │ ├── 38121740.json │ ├── 38121740.unq │ ├── 49284942.json │ ├── 49284942.unq │ ├── 53768947.json │ ├── 53768947.unq │ ├── 54199974.json │ ├── 54199974.unq │ ├── 60642449.json │ ├── 60642449.unq │ ├── 61331916.json │ ├── 61331916.unq │ ├── 63264954.json │ ├── 63264954.unq │ ├── 69137721.json │ ├── 69137721.unq │ ├── 69289006.json │ ├── 69289006.unq │ ├── 70097992.json │ ├── 70097992.unq │ ├── 71517326.json │ ├── 71517326.unq │ ├── 73048140.json │ └── 73048140.unq └── tests.sh ├── tutorial-samples └── employees │ ├── employee1.json │ ├── employee2.json │ ├── employee3.json │ ├── employee4.json │ ├── employee5.json │ └── queries │ ├── query1.unq │ ├── query10.unq │ ├── query10a.unq │ ├── query11.unq │ ├── query11a.unq │ ├── query12.unq │ ├── query12a.unq │ ├── query12b.unq │ ├── query13.unq │ ├── query14.unq │ ├── query14a.unq │ ├── query15.unq │ ├── query15a.unq │ ├── query15b.unq │ ├── query16.unq │ ├── query16a.unq │ ├── query17.unq │ ├── query17a.unq │ ├── query17b.unq │ ├── query17c.unq │ ├── query17d.unq │ ├── query18.unq │ ├── query19.unq │ ├── query2.unq │ ├── query20.unq │ ├── query20a.unq │ ├── query21.unq │ ├── query3.unq │ ├── query4.unq │ ├── query5.unq │ ├── query6.unq │ ├── query7.unq │ ├── query8.unq │ ├── query9.unq │ └── tolowerkeys.unq ├── unq ├── CMakeLists.txt ├── include │ ├── TemplateParser.h │ ├── TemplateQuery.h │ ├── json-utils.h │ ├── params.h │ ├── utils.h │ └── xcitedb-stubs.h └── src │ ├── TemplateParser.cpp │ ├── TemplateQuery.cpp │ ├── json-utils.cpp │ ├── params.cpp │ ├── unqlite_main.cpp │ └── utils.cpp └── unquery.1 /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /JSONCompare/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.6.2) 2 | 3 | project(JSONCompare) 4 | 5 | set(CMAKE_CXX_STANDARD 17) 6 | 7 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") 8 | 9 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin/Release) 10 | 11 | include_directories(include 12 | ../libs 13 | ../libs/shared 14 | ../libs/rapidjson 15 | ) 16 | 17 | set(SOURCES 18 | TraverseJSON.cpp 19 | ) 20 | 21 | add_executable(JSONCompare JSONCompare.cpp ${SOURCES}) 22 | 23 | add_executable(JSONGrep JSONgrep.cpp ${SOURCES}) 24 | 25 | target_link_libraries(JSONGrep stdc++fs) 26 | target_link_libraries(JSONCompare stdc++fs) 27 | 28 | 29 | -------------------------------------------------------------------------------- /JSONCompare/JSONCompare.cpp: -------------------------------------------------------------------------------- 1 | #include "TraverseJSON.h" 2 | #include "rapidjson/document.h" 3 | #include "rapidjson/filereadstream.h" 4 | #include "rapidjson/error/en.h" 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | using namespace rapidjson; 11 | 12 | bool readJSON(Document& json, const string& filename) 13 | { 14 | FILE* fp = fopen(filename.c_str(), "r"); 15 | if (!fp) { 16 | return false; 17 | } 18 | 19 | char readBuffer[65536]; 20 | FileReadStream jsonfile(fp, readBuffer, sizeof(readBuffer)); 21 | json.ParseStream(jsonfile); 22 | if (json.HasParseError()) { 23 | fprintf(stderr, "Schema file '%s' is not a valid JSON\n", filename.c_str()); 24 | fprintf(stderr, "Error(offset %u): %s\n", 25 | static_cast(json.GetErrorOffset()), 26 | GetParseError_En(json.GetParseError())); 27 | fclose(fp); 28 | exit(EXIT_FAILURE); 29 | } 30 | fclose(fp); 31 | return true; 32 | } 33 | 34 | void handleFile(const string& expected_filename, const string& actual_filename, TraverseJSON& traversal) 35 | { 36 | //cerr<<"Comapre expected="<value.GetArray(); 70 | auto actual_bills = actual_it->value.GetArray(); 71 | if (expected_bills.Size()!=actual_bills.Size()) { 72 | cerr<<"Error: different number of bills\n"; 73 | return; 74 | } 75 | for (int i=0; i "<: report only key names that match regex"<: skip keys that match regex"<: when mismatch is reported, print fields in the same amendment that match regex"< "< 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | using namespace rapidjson; 15 | 16 | bool readJSON(Document& json, const string& filename) 17 | { 18 | FILE* fp = fopen(filename.c_str(), "r"); 19 | if (!fp) { 20 | cerr<<"Error opening file: "<(json.GetErrorOffset()), 31 | GetParseError_En(json.GetParseError())); 32 | fclose(fp); 33 | return false; 34 | } 35 | fclose(fp); 36 | return true; 37 | 38 | } 39 | 40 | void help() 41 | { 42 | cerr<<"Syntax: JSONGrep [flags] "<: report only key names that match regex"<: skip keys that match regex"< "< 6 | #include 7 | #include 8 | 9 | static std::string kTypeNames[] = { "Null", "False", "True", "Object", "Array", "String", "Number" }; 10 | 11 | enum class MISMATCH_T { 12 | DIFFERENT_VALUE, 13 | FIELD_NOT_EXPECTED, 14 | FIELD_NOT_ACTUAL, 15 | FOUND_VALUE, 16 | NO_EXPECTED_FILE, 17 | NO_ACTUAL_FILE 18 | }; 19 | 20 | class Path { 21 | public: 22 | Path(const std::string& path, rapidjson::Value* obj = NULL, std::string key = std::string()) 23 | : _path(path), _obj(obj), _key(key) {} 24 | const std::string& get() const { 25 | return _path; 26 | } 27 | const std::string& getKey() const { 28 | return _key; 29 | } 30 | rapidjson::Value* getObject() const { 31 | return _obj; 32 | } 33 | Path addKey(std::string key) const { 34 | return Path(_path+(_path.empty()?"":".")+key, _obj, key); 35 | } 36 | Path addIndex(int i) const { 37 | return Path(_path+"["+std::to_string(i)+"]", _obj); 38 | } 39 | Path addObjectWithID(rapidjson::Value* v) const { 40 | auto it = v->FindMember("id"); 41 | if (it==v->MemberEnd() || !it->value.IsString()) { 42 | return Path(_path+"[id=#notfound]", v); 43 | } 44 | std::string id = it->value.GetString(); 45 | return Path(_path+"[id="+id+"]", v); 46 | } 47 | 48 | std::string _path; 49 | std::string _key; 50 | rapidjson::Value* _obj; 51 | }; 52 | 53 | class TraverseJSON 54 | { 55 | public: 56 | void searchJSON(const Path& path, rapidjson::Value& value, const std::string& search_str); 57 | void compareBill(rapidjson::Value& expected, rapidjson::Value& actual); 58 | void compareValues(const Path& path, rapidjson::Value& expected, rapidjson::Value& actual); 59 | void compareGenericJson(rapidjson::Value& expected, rapidjson::Value& actual); 60 | void report(MISMATCH_T type, const Path& path, const std::string& key, const std::string& msg); 61 | void report_summary(); 62 | bool testCond(rapidjson::Value& value, const std::string& cond); 63 | 64 | 65 | std::regex opt_report = std::regex(".*"); 66 | std::string opt_report_str; 67 | std::regex opt_ignore; 68 | std::regex opt_context; 69 | std::string opt_cond; 70 | bool opt_hide_path = false; 71 | bool opt_hide_filename = false; 72 | bool show_context = false; 73 | std::map count_diffs; 74 | std::string filename; 75 | }; 76 | 77 | 78 | #endif //TRAVERSEJSON_H 79 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # unqery: a command line tool for querying and transforming JSON data 2 | 3 | ## About 4 | 5 | The query language `Unquery` is a fast, powerful and flexible language for querying structured documents. It was originally developed as the query language for [XCiteDB](http://www.xcitedb.com), a fast and reliable noSQL database for structured documents, supporting XML, JSON, and other features such as temporal versioning and branches. 6 | 7 | This repository contains *unq*, a stand-alone command-line tool for querying, transforming and analyzing JSON files using `Unquery`. It reads either a single or multiple JSON files and an Unquery query, and produce a single JSON output based on the query. 8 | 9 | ## Building unq 10 | 11 | To build the tool, you'll need cmake version 3.6.2 or higher. You can install it with the package manager on most Linux distros, or follow the directions [here](https://cmake.org/install/). 12 | 13 | To build 14 | ```shell 15 | cd unq 16 | cmake . 17 | make 18 | ``` 19 | 20 | The executable would be in bin/Release/unq. 21 | 22 | ## Running unq 23 | 24 | To run `unq`, you'll need to provide the query, either as a file (with the option `-f`) or as a command-line option (with the option `-c`), and a list of files to query. For example, if you want to collect the value of the field `firstName` from all the json files in the current directory, the query you need is: 25 | ``` 26 | ["firstName"] 27 | ``` 28 | 29 | You can store the above query in a file, say `query.unq`, and then run: 30 | ``` 31 | unq -f query.unq *.json 32 | ``` 33 | 34 | Or alternatively, you can write: 35 | ``` 36 | unq -c '["firstName"]' *.json 37 | ``` 38 | 39 | It also allows to query CSV files by converting them on-the-fly to JSON and then processing the query. Example for a command line for processing CSV: 40 | 41 | ``` 42 | unq -f query.unq -csv -delim ";" users.csv 43 | ``` 44 | 45 | ## Frequently Asked Questions? 46 | 47 | ### Why do we need another json query language? 48 | 49 | *There already over a dozen different quey languages for json. Why do we need yet another one?* 50 | 51 | While there are a lot of query languages for json, Unquery is different. And, we believe, better. The approach we used for designing Unquery is based on two principles: 52 | * Any Unquery query is a well-formed json. 53 | * The structure of the query matches the structure of the result. 54 | 55 | The advantages of Unquery are: 56 | * Readability: because te structure of the query matches the structure of the result, it is easy to unserstand what the query does. 57 | * Succint: complex queries can be writen using relatively shot queries. 58 | * Simple: there are only few constructs the user need to learn to write complex queries. 59 | * Powerfull: we do not compromise on the expressive power of the language. 60 | * Recursive structure: json is recursive, and allows unlimited nesting depth of objects and arrays. Similarly, Unquery is capable of querying nested arrays and objects with ease. 61 | * Guarantee to produce well-formed json. 62 | * Fully embrace json: query json files with queries written in json, and results in json. 63 | * Fast. The implementation is written in C++, and use RapidJSON, the fastest c++ json library, to parse json files. 64 | * The same query language is used in XCiteDB, a powerfull database for XML and JSON. 65 | 66 | ### Are there any disadvantages? 67 | 68 | *What are the disadvantages of Unquery, compared to other query languages?* 69 | 70 | Unquery does have some disadvantages as well: 71 | * The queries are written in json, and may come with some syntactic overhead. Mostly, lots of double quotes, which are required for strings. 72 | * It can only produce well-formed json. So if you need non-json results, it wouldn't be a good match. 73 | * The implmentation is in C++ (and not Javascript). So it cannot run on the client's side inside the browser. 74 | 75 | ### Is the implementation complete? 76 | 77 | *It looks like unq is still being developped. Is it ready to be used?* 78 | 79 | The implementation is fully working. All the features shown in the tutorial (and many more) are already implemented. It is still a beta version, and may still have bugs. The more you use it, the better it would become. 80 | 81 | ### What about documentation? 82 | 83 | *Where is the reference manual?* 84 | 85 | The full language manual is at here: [Language Reference](https://github.com/xcite-db/Unquery/blob/main/LANGUAGE-REFERENCE.adoc) 86 | 87 | Also, check out the [tutorial](https://github.com/xcite-db/Unquery/blob/main/TUTORIAL.adoc) for more examples. 88 | 89 | ### Other programming languages 90 | 91 | *Having a command line utility is cool. But I want to use it in a Python/NodeJS/C++ project. Do you plan to have language bindings for those languages?* 92 | 93 | Yes. 94 | 95 | ### License 96 | 97 | *Can I use it? Do I need to pay?* 98 | 99 | unq is an open source project, disctributed under the terms Apache 2.0. So it is completely free. 100 | -------------------------------------------------------------------------------- /libs/rapidjson/cursorstreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_CURSORSTREAMWRAPPER_H_ 16 | #define RAPIDJSON_CURSORSTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | 20 | #if defined(__GNUC__) 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(effc++) 23 | #endif 24 | 25 | #if defined(_MSC_VER) && _MSC_VER <= 1800 26 | RAPIDJSON_DIAG_PUSH 27 | RAPIDJSON_DIAG_OFF(4702) // unreachable code 28 | RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated 29 | #endif 30 | 31 | RAPIDJSON_NAMESPACE_BEGIN 32 | 33 | 34 | //! Cursor stream wrapper for counting line and column number if error exists. 35 | /*! 36 | \tparam InputStream Any stream that implements Stream Concept 37 | */ 38 | template > 39 | class CursorStreamWrapper : public GenericStreamWrapper { 40 | public: 41 | typedef typename Encoding::Ch Ch; 42 | 43 | CursorStreamWrapper(InputStream& is): 44 | GenericStreamWrapper(is), line_(1), col_(0) {} 45 | 46 | // counting line and column number 47 | Ch Take() { 48 | Ch ch = this->is_.Take(); 49 | if(ch == '\n') { 50 | line_ ++; 51 | col_ = 0; 52 | } else { 53 | col_ ++; 54 | } 55 | return ch; 56 | } 57 | 58 | //! Get the error line number, if error exists. 59 | size_t GetLine() const { return line_; } 60 | //! Get the error column number, if error exists. 61 | size_t GetColumn() const { return col_; } 62 | 63 | private: 64 | size_t line_; //!< Current Line 65 | size_t col_; //!< Current Column 66 | }; 67 | 68 | #if defined(_MSC_VER) && _MSC_VER <= 1800 69 | RAPIDJSON_DIAG_POP 70 | #endif 71 | 72 | #if defined(__GNUC__) 73 | RAPIDJSON_DIAG_POP 74 | #endif 75 | 76 | RAPIDJSON_NAMESPACE_END 77 | 78 | #endif // RAPIDJSON_CURSORSTREAMWRAPPER_H_ 79 | -------------------------------------------------------------------------------- /libs/rapidjson/filereadstream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_FILEREADSTREAM_H_ 16 | #define RAPIDJSON_FILEREADSTREAM_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | RAPIDJSON_DIAG_PUSH 23 | RAPIDJSON_DIAG_OFF(padded) 24 | RAPIDJSON_DIAG_OFF(unreachable-code) 25 | RAPIDJSON_DIAG_OFF(missing-noreturn) 26 | #endif 27 | 28 | RAPIDJSON_NAMESPACE_BEGIN 29 | 30 | //! File byte stream for input using fread(). 31 | /*! 32 | \note implements Stream concept 33 | */ 34 | class FileReadStream { 35 | public: 36 | typedef char Ch; //!< Character type (byte). 37 | 38 | //! Constructor. 39 | /*! 40 | \param fp File pointer opened for read. 41 | \param buffer user-supplied buffer. 42 | \param bufferSize size of buffer in bytes. Must >=4 bytes. 43 | */ 44 | FileReadStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { 45 | RAPIDJSON_ASSERT(fp_ != 0); 46 | RAPIDJSON_ASSERT(bufferSize >= 4); 47 | Read(); 48 | } 49 | 50 | Ch Peek() const { return *current_; } 51 | Ch Take() { Ch c = *current_; Read(); return c; } 52 | size_t Tell() const { return count_ + static_cast(current_ - buffer_); } 53 | 54 | // Not implemented 55 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 56 | void Flush() { RAPIDJSON_ASSERT(false); } 57 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 58 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 59 | 60 | // For encoding detection only. 61 | const Ch* Peek4() const { 62 | return (current_ + 4 - !eof_ <= bufferLast_) ? current_ : 0; 63 | } 64 | 65 | private: 66 | void Read() { 67 | if (current_ < bufferLast_) 68 | ++current_; 69 | else if (!eof_) { 70 | count_ += readCount_; 71 | readCount_ = std::fread(buffer_, 1, bufferSize_, fp_); 72 | bufferLast_ = buffer_ + readCount_ - 1; 73 | current_ = buffer_; 74 | 75 | if (readCount_ < bufferSize_) { 76 | buffer_[readCount_] = '\0'; 77 | ++bufferLast_; 78 | eof_ = true; 79 | } 80 | } 81 | } 82 | 83 | std::FILE* fp_; 84 | Ch *buffer_; 85 | size_t bufferSize_; 86 | Ch *bufferLast_; 87 | Ch *current_; 88 | size_t readCount_; 89 | size_t count_; //!< Number of characters read 90 | bool eof_; 91 | }; 92 | 93 | RAPIDJSON_NAMESPACE_END 94 | 95 | #ifdef __clang__ 96 | RAPIDJSON_DIAG_POP 97 | #endif 98 | 99 | #endif // RAPIDJSON_FILESTREAM_H_ 100 | -------------------------------------------------------------------------------- /libs/rapidjson/filewritestream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_FILEWRITESTREAM_H_ 16 | #define RAPIDJSON_FILEWRITESTREAM_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | RAPIDJSON_DIAG_PUSH 23 | RAPIDJSON_DIAG_OFF(unreachable-code) 24 | #endif 25 | 26 | RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Wrapper of C file stream for output using fwrite(). 29 | /*! 30 | \note implements Stream concept 31 | */ 32 | class FileWriteStream { 33 | public: 34 | typedef char Ch; //!< Character type. Only support char. 35 | 36 | FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) { 37 | RAPIDJSON_ASSERT(fp_ != 0); 38 | } 39 | 40 | void Put(char c) { 41 | if (current_ >= bufferEnd_) 42 | Flush(); 43 | 44 | *current_++ = c; 45 | } 46 | 47 | void PutN(char c, size_t n) { 48 | size_t avail = static_cast(bufferEnd_ - current_); 49 | while (n > avail) { 50 | std::memset(current_, c, avail); 51 | current_ += avail; 52 | Flush(); 53 | n -= avail; 54 | avail = static_cast(bufferEnd_ - current_); 55 | } 56 | 57 | if (n > 0) { 58 | std::memset(current_, c, n); 59 | current_ += n; 60 | } 61 | } 62 | 63 | void Flush() { 64 | if (current_ != buffer_) { 65 | size_t result = std::fwrite(buffer_, 1, static_cast(current_ - buffer_), fp_); 66 | if (result < static_cast(current_ - buffer_)) { 67 | // failure deliberately ignored at this time 68 | // added to avoid warn_unused_result build errors 69 | } 70 | current_ = buffer_; 71 | } 72 | } 73 | 74 | // Not implemented 75 | char Peek() const { RAPIDJSON_ASSERT(false); return 0; } 76 | char Take() { RAPIDJSON_ASSERT(false); return 0; } 77 | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } 78 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 79 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } 80 | 81 | private: 82 | // Prohibit copy constructor & assignment operator. 83 | FileWriteStream(const FileWriteStream&); 84 | FileWriteStream& operator=(const FileWriteStream&); 85 | 86 | std::FILE* fp_; 87 | char *buffer_; 88 | char *bufferEnd_; 89 | char *current_; 90 | }; 91 | 92 | //! Implement specialized version of PutN() with memset() for better performance. 93 | template<> 94 | inline void PutN(FileWriteStream& stream, char c, size_t n) { 95 | stream.PutN(c, n); 96 | } 97 | 98 | RAPIDJSON_NAMESPACE_END 99 | 100 | #ifdef __clang__ 101 | RAPIDJSON_DIAG_POP 102 | #endif 103 | 104 | #endif // RAPIDJSON_FILESTREAM_H_ 105 | -------------------------------------------------------------------------------- /libs/rapidjson/fwd.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_FWD_H_ 16 | #define RAPIDJSON_FWD_H_ 17 | 18 | #include "rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | 22 | // encodings.h 23 | 24 | template struct UTF8; 25 | template struct UTF16; 26 | template struct UTF16BE; 27 | template struct UTF16LE; 28 | template struct UTF32; 29 | template struct UTF32BE; 30 | template struct UTF32LE; 31 | template struct ASCII; 32 | template struct AutoUTF; 33 | 34 | template 35 | struct Transcoder; 36 | 37 | // allocators.h 38 | 39 | class CrtAllocator; 40 | 41 | template 42 | class MemoryPoolAllocator; 43 | 44 | // stream.h 45 | 46 | template 47 | struct GenericStringStream; 48 | 49 | typedef GenericStringStream > StringStream; 50 | 51 | template 52 | struct GenericInsituStringStream; 53 | 54 | typedef GenericInsituStringStream > InsituStringStream; 55 | 56 | // stringbuffer.h 57 | 58 | template 59 | class GenericStringBuffer; 60 | 61 | typedef GenericStringBuffer, CrtAllocator> StringBuffer; 62 | 63 | // filereadstream.h 64 | 65 | class FileReadStream; 66 | 67 | // filewritestream.h 68 | 69 | class FileWriteStream; 70 | 71 | // memorybuffer.h 72 | 73 | template 74 | struct GenericMemoryBuffer; 75 | 76 | typedef GenericMemoryBuffer MemoryBuffer; 77 | 78 | // memorystream.h 79 | 80 | struct MemoryStream; 81 | 82 | // reader.h 83 | 84 | template 85 | struct BaseReaderHandler; 86 | 87 | template 88 | class GenericReader; 89 | 90 | typedef GenericReader, UTF8, CrtAllocator> Reader; 91 | 92 | // writer.h 93 | 94 | template 95 | class Writer; 96 | 97 | // prettywriter.h 98 | 99 | template 100 | class PrettyWriter; 101 | 102 | // document.h 103 | 104 | template 105 | class GenericMember; 106 | 107 | template 108 | class GenericMemberIterator; 109 | 110 | template 111 | struct GenericStringRef; 112 | 113 | template 114 | class GenericValue; 115 | 116 | typedef GenericValue, MemoryPoolAllocator > Value; 117 | 118 | template 119 | class GenericDocument; 120 | 121 | typedef GenericDocument, MemoryPoolAllocator, CrtAllocator> Document; 122 | 123 | // pointer.h 124 | 125 | template 126 | class GenericPointer; 127 | 128 | typedef GenericPointer Pointer; 129 | 130 | // schema.h 131 | 132 | template 133 | class IGenericRemoteSchemaDocumentProvider; 134 | 135 | template 136 | class GenericSchemaDocument; 137 | 138 | typedef GenericSchemaDocument SchemaDocument; 139 | typedef IGenericRemoteSchemaDocumentProvider IRemoteSchemaDocumentProvider; 140 | 141 | template < 142 | typename SchemaDocumentType, 143 | typename OutputHandler, 144 | typename StateAllocator> 145 | class GenericSchemaValidator; 146 | 147 | typedef GenericSchemaValidator, void>, CrtAllocator> SchemaValidator; 148 | 149 | RAPIDJSON_NAMESPACE_END 150 | 151 | #endif // RAPIDJSON_RAPIDJSONFWD_H_ 152 | -------------------------------------------------------------------------------- /libs/rapidjson/internal/clzll.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_CLZLL_H_ 16 | #define RAPIDJSON_CLZLL_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(_MSC_VER) && !defined(UNDER_CE) 21 | #include 22 | #if defined(_WIN64) 23 | #pragma intrinsic(_BitScanReverse64) 24 | #else 25 | #pragma intrinsic(_BitScanReverse) 26 | #endif 27 | #endif 28 | 29 | RAPIDJSON_NAMESPACE_BEGIN 30 | namespace internal { 31 | 32 | inline uint32_t clzll(uint64_t x) { 33 | // Passing 0 to __builtin_clzll is UB in GCC and results in an 34 | // infinite loop in the software implementation. 35 | RAPIDJSON_ASSERT(x != 0); 36 | 37 | #if defined(_MSC_VER) && !defined(UNDER_CE) 38 | unsigned long r = 0; 39 | #if defined(_WIN64) 40 | _BitScanReverse64(&r, x); 41 | #else 42 | // Scan the high 32 bits. 43 | if (_BitScanReverse(&r, static_cast(x >> 32))) 44 | return 63 - (r + 32); 45 | 46 | // Scan the low 32 bits. 47 | _BitScanReverse(&r, static_cast(x & 0xFFFFFFFF)); 48 | #endif // _WIN64 49 | 50 | return 63 - r; 51 | #elif (defined(__GNUC__) && __GNUC__ >= 4) || RAPIDJSON_HAS_BUILTIN(__builtin_clzll) 52 | // __builtin_clzll wrapper 53 | return static_cast(__builtin_clzll(x)); 54 | #else 55 | // naive version 56 | uint32_t r = 0; 57 | while (!(x & (static_cast(1) << 63))) { 58 | x <<= 1; 59 | ++r; 60 | } 61 | 62 | return r; 63 | #endif // _MSC_VER 64 | } 65 | 66 | #define RAPIDJSON_CLZLL RAPIDJSON_NAMESPACE::internal::clzll 67 | 68 | } // namespace internal 69 | RAPIDJSON_NAMESPACE_END 70 | 71 | #endif // RAPIDJSON_CLZLL_H_ 72 | -------------------------------------------------------------------------------- /libs/rapidjson/internal/ieee754.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_IEEE754_ 16 | #define RAPIDJSON_IEEE754_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | class Double { 24 | public: 25 | Double() {} 26 | Double(double d) : d_(d) {} 27 | Double(uint64_t u) : u_(u) {} 28 | 29 | double Value() const { return d_; } 30 | uint64_t Uint64Value() const { return u_; } 31 | 32 | double NextPositiveDouble() const { 33 | RAPIDJSON_ASSERT(!Sign()); 34 | return Double(u_ + 1).Value(); 35 | } 36 | 37 | bool Sign() const { return (u_ & kSignMask) != 0; } 38 | uint64_t Significand() const { return u_ & kSignificandMask; } 39 | int Exponent() const { return static_cast(((u_ & kExponentMask) >> kSignificandSize) - kExponentBias); } 40 | 41 | bool IsNan() const { return (u_ & kExponentMask) == kExponentMask && Significand() != 0; } 42 | bool IsInf() const { return (u_ & kExponentMask) == kExponentMask && Significand() == 0; } 43 | bool IsNanOrInf() const { return (u_ & kExponentMask) == kExponentMask; } 44 | bool IsNormal() const { return (u_ & kExponentMask) != 0 || Significand() == 0; } 45 | bool IsZero() const { return (u_ & (kExponentMask | kSignificandMask)) == 0; } 46 | 47 | uint64_t IntegerSignificand() const { return IsNormal() ? Significand() | kHiddenBit : Significand(); } 48 | int IntegerExponent() const { return (IsNormal() ? Exponent() : kDenormalExponent) - kSignificandSize; } 49 | uint64_t ToBias() const { return (u_ & kSignMask) ? ~u_ + 1 : u_ | kSignMask; } 50 | 51 | static int EffectiveSignificandSize(int order) { 52 | if (order >= -1021) 53 | return 53; 54 | else if (order <= -1074) 55 | return 0; 56 | else 57 | return order + 1074; 58 | } 59 | 60 | private: 61 | static const int kSignificandSize = 52; 62 | static const int kExponentBias = 0x3FF; 63 | static const int kDenormalExponent = 1 - kExponentBias; 64 | static const uint64_t kSignMask = RAPIDJSON_UINT64_C2(0x80000000, 0x00000000); 65 | static const uint64_t kExponentMask = RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000); 66 | static const uint64_t kSignificandMask = RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF); 67 | static const uint64_t kHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000); 68 | 69 | union { 70 | double d_; 71 | uint64_t u_; 72 | }; 73 | }; 74 | 75 | } // namespace internal 76 | RAPIDJSON_NAMESPACE_END 77 | 78 | #endif // RAPIDJSON_IEEE754_ 79 | -------------------------------------------------------------------------------- /libs/rapidjson/internal/meta.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_META_H_ 16 | #define RAPIDJSON_INTERNAL_META_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #ifdef __GNUC__ 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(effc++) 23 | #endif 24 | 25 | #if defined(_MSC_VER) && !defined(__clang__) 26 | RAPIDJSON_DIAG_PUSH 27 | RAPIDJSON_DIAG_OFF(6334) 28 | #endif 29 | 30 | #if RAPIDJSON_HAS_CXX11_TYPETRAITS 31 | #include 32 | #endif 33 | 34 | //@cond RAPIDJSON_INTERNAL 35 | RAPIDJSON_NAMESPACE_BEGIN 36 | namespace internal { 37 | 38 | // Helper to wrap/convert arbitrary types to void, useful for arbitrary type matching 39 | template struct Void { typedef void Type; }; 40 | 41 | /////////////////////////////////////////////////////////////////////////////// 42 | // BoolType, TrueType, FalseType 43 | // 44 | template struct BoolType { 45 | static const bool Value = Cond; 46 | typedef BoolType Type; 47 | }; 48 | typedef BoolType TrueType; 49 | typedef BoolType FalseType; 50 | 51 | 52 | /////////////////////////////////////////////////////////////////////////////// 53 | // SelectIf, BoolExpr, NotExpr, AndExpr, OrExpr 54 | // 55 | 56 | template struct SelectIfImpl { template struct Apply { typedef T1 Type; }; }; 57 | template <> struct SelectIfImpl { template struct Apply { typedef T2 Type; }; }; 58 | template struct SelectIfCond : SelectIfImpl::template Apply {}; 59 | template struct SelectIf : SelectIfCond {}; 60 | 61 | template struct AndExprCond : FalseType {}; 62 | template <> struct AndExprCond : TrueType {}; 63 | template struct OrExprCond : TrueType {}; 64 | template <> struct OrExprCond : FalseType {}; 65 | 66 | template struct BoolExpr : SelectIf::Type {}; 67 | template struct NotExpr : SelectIf::Type {}; 68 | template struct AndExpr : AndExprCond::Type {}; 69 | template struct OrExpr : OrExprCond::Type {}; 70 | 71 | 72 | /////////////////////////////////////////////////////////////////////////////// 73 | // AddConst, MaybeAddConst, RemoveConst 74 | template struct AddConst { typedef const T Type; }; 75 | template struct MaybeAddConst : SelectIfCond {}; 76 | template struct RemoveConst { typedef T Type; }; 77 | template struct RemoveConst { typedef T Type; }; 78 | 79 | 80 | /////////////////////////////////////////////////////////////////////////////// 81 | // IsSame, IsConst, IsMoreConst, IsPointer 82 | // 83 | template struct IsSame : FalseType {}; 84 | template struct IsSame : TrueType {}; 85 | 86 | template struct IsConst : FalseType {}; 87 | template struct IsConst : TrueType {}; 88 | 89 | template 90 | struct IsMoreConst 91 | : AndExpr::Type, typename RemoveConst::Type>, 92 | BoolType::Value >= IsConst::Value> >::Type {}; 93 | 94 | template struct IsPointer : FalseType {}; 95 | template struct IsPointer : TrueType {}; 96 | 97 | /////////////////////////////////////////////////////////////////////////////// 98 | // IsBaseOf 99 | // 100 | #if RAPIDJSON_HAS_CXX11_TYPETRAITS 101 | 102 | template struct IsBaseOf 103 | : BoolType< ::std::is_base_of::value> {}; 104 | 105 | #else // simplified version adopted from Boost 106 | 107 | template struct IsBaseOfImpl { 108 | RAPIDJSON_STATIC_ASSERT(sizeof(B) != 0); 109 | RAPIDJSON_STATIC_ASSERT(sizeof(D) != 0); 110 | 111 | typedef char (&Yes)[1]; 112 | typedef char (&No) [2]; 113 | 114 | template 115 | static Yes Check(const D*, T); 116 | static No Check(const B*, int); 117 | 118 | struct Host { 119 | operator const B*() const; 120 | operator const D*(); 121 | }; 122 | 123 | enum { Value = (sizeof(Check(Host(), 0)) == sizeof(Yes)) }; 124 | }; 125 | 126 | template struct IsBaseOf 127 | : OrExpr, BoolExpr > >::Type {}; 128 | 129 | #endif // RAPIDJSON_HAS_CXX11_TYPETRAITS 130 | 131 | 132 | ////////////////////////////////////////////////////////////////////////// 133 | // EnableIf / DisableIf 134 | // 135 | template struct EnableIfCond { typedef T Type; }; 136 | template struct EnableIfCond { /* empty */ }; 137 | 138 | template struct DisableIfCond { typedef T Type; }; 139 | template struct DisableIfCond { /* empty */ }; 140 | 141 | template 142 | struct EnableIf : EnableIfCond {}; 143 | 144 | template 145 | struct DisableIf : DisableIfCond {}; 146 | 147 | // SFINAE helpers 148 | struct SfinaeTag {}; 149 | template struct RemoveSfinaeTag; 150 | template struct RemoveSfinaeTag { typedef T Type; }; 151 | 152 | #define RAPIDJSON_REMOVEFPTR_(type) \ 153 | typename ::RAPIDJSON_NAMESPACE::internal::RemoveSfinaeTag \ 154 | < ::RAPIDJSON_NAMESPACE::internal::SfinaeTag&(*) type>::Type 155 | 156 | #define RAPIDJSON_ENABLEIF(cond) \ 157 | typename ::RAPIDJSON_NAMESPACE::internal::EnableIf \ 158 | ::Type * = NULL 159 | 160 | #define RAPIDJSON_DISABLEIF(cond) \ 161 | typename ::RAPIDJSON_NAMESPACE::internal::DisableIf \ 162 | ::Type * = NULL 163 | 164 | #define RAPIDJSON_ENABLEIF_RETURN(cond,returntype) \ 165 | typename ::RAPIDJSON_NAMESPACE::internal::EnableIf \ 166 | ::Type 168 | 169 | #define RAPIDJSON_DISABLEIF_RETURN(cond,returntype) \ 170 | typename ::RAPIDJSON_NAMESPACE::internal::DisableIf \ 171 | ::Type 173 | 174 | } // namespace internal 175 | RAPIDJSON_NAMESPACE_END 176 | //@endcond 177 | 178 | #if defined(_MSC_VER) && !defined(__clang__) 179 | RAPIDJSON_DIAG_POP 180 | #endif 181 | 182 | #ifdef __GNUC__ 183 | RAPIDJSON_DIAG_POP 184 | #endif 185 | 186 | #endif // RAPIDJSON_INTERNAL_META_H_ 187 | -------------------------------------------------------------------------------- /libs/rapidjson/internal/pow10.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_POW10_ 16 | #define RAPIDJSON_POW10_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | //! Computes integer powers of 10 in double (10.0^n). 24 | /*! This function uses lookup table for fast and accurate results. 25 | \param n non-negative exponent. Must <= 308. 26 | \return 10.0^n 27 | */ 28 | inline double Pow10(int n) { 29 | static const double e[] = { // 1e-0...1e308: 309 * 8 bytes = 2472 bytes 30 | 1e+0, 31 | 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, 32 | 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40, 33 | 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60, 34 | 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80, 35 | 1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100, 36 | 1e+101,1e+102,1e+103,1e+104,1e+105,1e+106,1e+107,1e+108,1e+109,1e+110,1e+111,1e+112,1e+113,1e+114,1e+115,1e+116,1e+117,1e+118,1e+119,1e+120, 37 | 1e+121,1e+122,1e+123,1e+124,1e+125,1e+126,1e+127,1e+128,1e+129,1e+130,1e+131,1e+132,1e+133,1e+134,1e+135,1e+136,1e+137,1e+138,1e+139,1e+140, 38 | 1e+141,1e+142,1e+143,1e+144,1e+145,1e+146,1e+147,1e+148,1e+149,1e+150,1e+151,1e+152,1e+153,1e+154,1e+155,1e+156,1e+157,1e+158,1e+159,1e+160, 39 | 1e+161,1e+162,1e+163,1e+164,1e+165,1e+166,1e+167,1e+168,1e+169,1e+170,1e+171,1e+172,1e+173,1e+174,1e+175,1e+176,1e+177,1e+178,1e+179,1e+180, 40 | 1e+181,1e+182,1e+183,1e+184,1e+185,1e+186,1e+187,1e+188,1e+189,1e+190,1e+191,1e+192,1e+193,1e+194,1e+195,1e+196,1e+197,1e+198,1e+199,1e+200, 41 | 1e+201,1e+202,1e+203,1e+204,1e+205,1e+206,1e+207,1e+208,1e+209,1e+210,1e+211,1e+212,1e+213,1e+214,1e+215,1e+216,1e+217,1e+218,1e+219,1e+220, 42 | 1e+221,1e+222,1e+223,1e+224,1e+225,1e+226,1e+227,1e+228,1e+229,1e+230,1e+231,1e+232,1e+233,1e+234,1e+235,1e+236,1e+237,1e+238,1e+239,1e+240, 43 | 1e+241,1e+242,1e+243,1e+244,1e+245,1e+246,1e+247,1e+248,1e+249,1e+250,1e+251,1e+252,1e+253,1e+254,1e+255,1e+256,1e+257,1e+258,1e+259,1e+260, 44 | 1e+261,1e+262,1e+263,1e+264,1e+265,1e+266,1e+267,1e+268,1e+269,1e+270,1e+271,1e+272,1e+273,1e+274,1e+275,1e+276,1e+277,1e+278,1e+279,1e+280, 45 | 1e+281,1e+282,1e+283,1e+284,1e+285,1e+286,1e+287,1e+288,1e+289,1e+290,1e+291,1e+292,1e+293,1e+294,1e+295,1e+296,1e+297,1e+298,1e+299,1e+300, 46 | 1e+301,1e+302,1e+303,1e+304,1e+305,1e+306,1e+307,1e+308 47 | }; 48 | RAPIDJSON_ASSERT(n >= 0 && n <= 308); 49 | return e[n]; 50 | } 51 | 52 | } // namespace internal 53 | RAPIDJSON_NAMESPACE_END 54 | 55 | #endif // RAPIDJSON_POW10_ 56 | -------------------------------------------------------------------------------- /libs/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ 16 | #define RAPIDJSON_INTERNAL_STRFUNC_H_ 17 | 18 | #include "../stream.h" 19 | #include 20 | 21 | RAPIDJSON_NAMESPACE_BEGIN 22 | namespace internal { 23 | 24 | //! Custom strlen() which works on different character types. 25 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 26 | \param s Null-terminated input string. 27 | \return Number of characters in the string. 28 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 29 | */ 30 | template 31 | inline SizeType StrLen(const Ch* s) { 32 | RAPIDJSON_ASSERT(s != 0); 33 | const Ch* p = s; 34 | while (*p) ++p; 35 | return SizeType(p - s); 36 | } 37 | 38 | template <> 39 | inline SizeType StrLen(const char* s) { 40 | return SizeType(std::strlen(s)); 41 | } 42 | 43 | template <> 44 | inline SizeType StrLen(const wchar_t* s) { 45 | return SizeType(std::wcslen(s)); 46 | } 47 | 48 | //! Custom strcmpn() which works on different character types. 49 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 50 | \param s1 Null-terminated input string. 51 | \param s2 Null-terminated input string. 52 | \return 0 if equal 53 | */ 54 | template 55 | inline int StrCmp(const Ch* s1, const Ch* s2) { 56 | RAPIDJSON_ASSERT(s1 != 0); 57 | RAPIDJSON_ASSERT(s2 != 0); 58 | while(*s1 && (*s1 == *s2)) { s1++; s2++; } 59 | return static_cast(*s1) < static_cast(*s2) ? -1 : static_cast(*s1) > static_cast(*s2); 60 | } 61 | 62 | //! Returns number of code points in a encoded string. 63 | template 64 | bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) { 65 | RAPIDJSON_ASSERT(s != 0); 66 | RAPIDJSON_ASSERT(outCount != 0); 67 | GenericStringStream is(s); 68 | const typename Encoding::Ch* end = s + length; 69 | SizeType count = 0; 70 | while (is.src_ < end) { 71 | unsigned codepoint; 72 | if (!Encoding::Decode(is, &codepoint)) 73 | return false; 74 | count++; 75 | } 76 | *outCount = count; 77 | return true; 78 | } 79 | 80 | } // namespace internal 81 | RAPIDJSON_NAMESPACE_END 82 | 83 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ 84 | -------------------------------------------------------------------------------- /libs/rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(__clang__) 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(c++98-compat) 23 | #endif 24 | 25 | RAPIDJSON_NAMESPACE_BEGIN 26 | namespace internal { 27 | 28 | //! Custom swap() to avoid dependency on C++ header 29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 30 | \note This has the same semantics as std::swap(). 31 | */ 32 | template 33 | inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT { 34 | T tmp = a; 35 | a = b; 36 | b = tmp; 37 | } 38 | 39 | } // namespace internal 40 | RAPIDJSON_NAMESPACE_END 41 | 42 | #if defined(__clang__) 43 | RAPIDJSON_DIAG_POP 44 | #endif 45 | 46 | #endif // RAPIDJSON_INTERNAL_SWAP_H_ 47 | -------------------------------------------------------------------------------- /libs/rapidjson/istreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_ISTREAMWRAPPER_H_ 16 | #define RAPIDJSON_ISTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | #include 21 | 22 | #ifdef __clang__ 23 | RAPIDJSON_DIAG_PUSH 24 | RAPIDJSON_DIAG_OFF(padded) 25 | #elif defined(_MSC_VER) 26 | RAPIDJSON_DIAG_PUSH 27 | RAPIDJSON_DIAG_OFF(4351) // new behavior: elements of array 'array' will be default initialized 28 | #endif 29 | 30 | RAPIDJSON_NAMESPACE_BEGIN 31 | 32 | //! Wrapper of \c std::basic_istream into RapidJSON's Stream concept. 33 | /*! 34 | The classes can be wrapped including but not limited to: 35 | 36 | - \c std::istringstream 37 | - \c std::stringstream 38 | - \c std::wistringstream 39 | - \c std::wstringstream 40 | - \c std::ifstream 41 | - \c std::fstream 42 | - \c std::wifstream 43 | - \c std::wfstream 44 | 45 | \tparam StreamType Class derived from \c std::basic_istream. 46 | */ 47 | 48 | template 49 | class BasicIStreamWrapper { 50 | public: 51 | typedef typename StreamType::char_type Ch; 52 | 53 | //! Constructor. 54 | /*! 55 | \param stream stream opened for read. 56 | */ 57 | BasicIStreamWrapper(StreamType &stream) : stream_(stream), buffer_(peekBuffer_), bufferSize_(4), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { 58 | Read(); 59 | } 60 | 61 | //! Constructor. 62 | /*! 63 | \param stream stream opened for read. 64 | \param buffer user-supplied buffer. 65 | \param bufferSize size of buffer in bytes. Must >=4 bytes. 66 | */ 67 | BasicIStreamWrapper(StreamType &stream, char* buffer, size_t bufferSize) : stream_(stream), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { 68 | RAPIDJSON_ASSERT(bufferSize >= 4); 69 | Read(); 70 | } 71 | 72 | Ch Peek() const { return *current_; } 73 | Ch Take() { Ch c = *current_; Read(); return c; } 74 | size_t Tell() const { return count_ + static_cast(current_ - buffer_); } 75 | 76 | // Not implemented 77 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 78 | void Flush() { RAPIDJSON_ASSERT(false); } 79 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 80 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 81 | 82 | // For encoding detection only. 83 | const Ch* Peek4() const { 84 | return (current_ + 4 - !eof_ <= bufferLast_) ? current_ : 0; 85 | } 86 | 87 | private: 88 | BasicIStreamWrapper(); 89 | BasicIStreamWrapper(const BasicIStreamWrapper&); 90 | BasicIStreamWrapper& operator=(const BasicIStreamWrapper&); 91 | 92 | void Read() { 93 | if (current_ < bufferLast_) 94 | ++current_; 95 | else if (!eof_) { 96 | count_ += readCount_; 97 | readCount_ = bufferSize_; 98 | bufferLast_ = buffer_ + readCount_ - 1; 99 | current_ = buffer_; 100 | 101 | if (!stream_.read(buffer_, static_cast(bufferSize_))) { 102 | readCount_ = static_cast(stream_.gcount()); 103 | *(bufferLast_ = buffer_ + readCount_) = '\0'; 104 | eof_ = true; 105 | } 106 | } 107 | } 108 | 109 | StreamType &stream_; 110 | Ch peekBuffer_[4], *buffer_; 111 | size_t bufferSize_; 112 | Ch *bufferLast_; 113 | Ch *current_; 114 | size_t readCount_; 115 | size_t count_; //!< Number of characters read 116 | bool eof_; 117 | }; 118 | 119 | typedef BasicIStreamWrapper IStreamWrapper; 120 | typedef BasicIStreamWrapper WIStreamWrapper; 121 | 122 | #if defined(__clang__) || defined(_MSC_VER) 123 | RAPIDJSON_DIAG_POP 124 | #endif 125 | 126 | RAPIDJSON_NAMESPACE_END 127 | 128 | #endif // RAPIDJSON_ISTREAMWRAPPER_H_ 129 | -------------------------------------------------------------------------------- /libs/rapidjson/memorybuffer.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_MEMORYBUFFER_H_ 16 | #define RAPIDJSON_MEMORYBUFFER_H_ 17 | 18 | #include "stream.h" 19 | #include "internal/stack.h" 20 | 21 | RAPIDJSON_NAMESPACE_BEGIN 22 | 23 | //! Represents an in-memory output byte stream. 24 | /*! 25 | This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream. 26 | 27 | It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file. 28 | 29 | Differences between MemoryBuffer and StringBuffer: 30 | 1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer. 31 | 2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator. 32 | 33 | \tparam Allocator type for allocating memory buffer. 34 | \note implements Stream concept 35 | */ 36 | template 37 | struct GenericMemoryBuffer { 38 | typedef char Ch; // byte 39 | 40 | GenericMemoryBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 41 | 42 | void Put(Ch c) { *stack_.template Push() = c; } 43 | void Flush() {} 44 | 45 | void Clear() { stack_.Clear(); } 46 | void ShrinkToFit() { stack_.ShrinkToFit(); } 47 | Ch* Push(size_t count) { return stack_.template Push(count); } 48 | void Pop(size_t count) { stack_.template Pop(count); } 49 | 50 | const Ch* GetBuffer() const { 51 | return stack_.template Bottom(); 52 | } 53 | 54 | size_t GetSize() const { return stack_.GetSize(); } 55 | 56 | static const size_t kDefaultCapacity = 256; 57 | mutable internal::Stack stack_; 58 | }; 59 | 60 | typedef GenericMemoryBuffer<> MemoryBuffer; 61 | 62 | //! Implement specialized version of PutN() with memset() for better performance. 63 | template<> 64 | inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) { 65 | std::memset(memoryBuffer.stack_.Push(n), c, n * sizeof(c)); 66 | } 67 | 68 | RAPIDJSON_NAMESPACE_END 69 | 70 | #endif // RAPIDJSON_MEMORYBUFFER_H_ 71 | -------------------------------------------------------------------------------- /libs/rapidjson/memorystream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_MEMORYSTREAM_H_ 16 | #define RAPIDJSON_MEMORYSTREAM_H_ 17 | 18 | #include "stream.h" 19 | 20 | #ifdef __clang__ 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(unreachable-code) 23 | RAPIDJSON_DIAG_OFF(missing-noreturn) 24 | #endif 25 | 26 | RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Represents an in-memory input byte stream. 29 | /*! 30 | This class is mainly for being wrapped by EncodedInputStream or AutoUTFInputStream. 31 | 32 | It is similar to FileReadBuffer but the source is an in-memory buffer instead of a file. 33 | 34 | Differences between MemoryStream and StringStream: 35 | 1. StringStream has encoding but MemoryStream is a byte stream. 36 | 2. MemoryStream needs size of the source buffer and the buffer don't need to be null terminated. StringStream assume null-terminated string as source. 37 | 3. MemoryStream supports Peek4() for encoding detection. StringStream is specified with an encoding so it should not have Peek4(). 38 | \note implements Stream concept 39 | */ 40 | struct MemoryStream { 41 | typedef char Ch; // byte 42 | 43 | MemoryStream(const Ch *src, size_t size) : src_(src), begin_(src), end_(src + size), size_(size) {} 44 | 45 | Ch Peek() const { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_; } 46 | Ch Take() { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_++; } 47 | size_t Tell() const { return static_cast(src_ - begin_); } 48 | 49 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 50 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 51 | void Flush() { RAPIDJSON_ASSERT(false); } 52 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 53 | 54 | // For encoding detection only. 55 | const Ch* Peek4() const { 56 | return Tell() + 4 <= size_ ? src_ : 0; 57 | } 58 | 59 | const Ch* src_; //!< Current read position. 60 | const Ch* begin_; //!< Original head of the string. 61 | const Ch* end_; //!< End of stream. 62 | size_t size_; //!< Size of the stream. 63 | }; 64 | 65 | RAPIDJSON_NAMESPACE_END 66 | 67 | #ifdef __clang__ 68 | RAPIDJSON_DIAG_POP 69 | #endif 70 | 71 | #endif // RAPIDJSON_MEMORYBUFFER_H_ 72 | -------------------------------------------------------------------------------- /libs/rapidjson/ostreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_OSTREAMWRAPPER_H_ 16 | #define RAPIDJSON_OSTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | RAPIDJSON_DIAG_PUSH 23 | RAPIDJSON_DIAG_OFF(padded) 24 | #endif 25 | 26 | RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Wrapper of \c std::basic_ostream into RapidJSON's Stream concept. 29 | /*! 30 | The classes can be wrapped including but not limited to: 31 | 32 | - \c std::ostringstream 33 | - \c std::stringstream 34 | - \c std::wpstringstream 35 | - \c std::wstringstream 36 | - \c std::ifstream 37 | - \c std::fstream 38 | - \c std::wofstream 39 | - \c std::wfstream 40 | 41 | \tparam StreamType Class derived from \c std::basic_ostream. 42 | */ 43 | 44 | template 45 | class BasicOStreamWrapper { 46 | public: 47 | typedef typename StreamType::char_type Ch; 48 | BasicOStreamWrapper(StreamType& stream) : stream_(stream) {} 49 | 50 | void Put(Ch c) { 51 | stream_.put(c); 52 | } 53 | 54 | void Flush() { 55 | stream_.flush(); 56 | } 57 | 58 | // Not implemented 59 | char Peek() const { RAPIDJSON_ASSERT(false); return 0; } 60 | char Take() { RAPIDJSON_ASSERT(false); return 0; } 61 | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } 62 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 63 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } 64 | 65 | private: 66 | BasicOStreamWrapper(const BasicOStreamWrapper&); 67 | BasicOStreamWrapper& operator=(const BasicOStreamWrapper&); 68 | 69 | StreamType& stream_; 70 | }; 71 | 72 | typedef BasicOStreamWrapper OStreamWrapper; 73 | typedef BasicOStreamWrapper WOStreamWrapper; 74 | 75 | #ifdef __clang__ 76 | RAPIDJSON_DIAG_POP 77 | #endif 78 | 79 | RAPIDJSON_NAMESPACE_END 80 | 81 | #endif // RAPIDJSON_OSTREAMWRAPPER_H_ 82 | -------------------------------------------------------------------------------- /libs/rapidjson/stream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #include "rapidjson.h" 16 | 17 | #ifndef RAPIDJSON_STREAM_H_ 18 | #define RAPIDJSON_STREAM_H_ 19 | 20 | #include "encodings.h" 21 | 22 | RAPIDJSON_NAMESPACE_BEGIN 23 | 24 | /////////////////////////////////////////////////////////////////////////////// 25 | // Stream 26 | 27 | /*! \class rapidjson::Stream 28 | \brief Concept for reading and writing characters. 29 | 30 | For read-only stream, no need to implement PutBegin(), Put(), Flush() and PutEnd(). 31 | 32 | For write-only stream, only need to implement Put() and Flush(). 33 | 34 | \code 35 | concept Stream { 36 | typename Ch; //!< Character type of the stream. 37 | 38 | //! Read the current character from stream without moving the read cursor. 39 | Ch Peek() const; 40 | 41 | //! Read the current character from stream and moving the read cursor to next character. 42 | Ch Take(); 43 | 44 | //! Get the current read cursor. 45 | //! \return Number of characters read from start. 46 | size_t Tell(); 47 | 48 | //! Begin writing operation at the current read pointer. 49 | //! \return The begin writer pointer. 50 | Ch* PutBegin(); 51 | 52 | //! Write a character. 53 | void Put(Ch c); 54 | 55 | //! Flush the buffer. 56 | void Flush(); 57 | 58 | //! End the writing operation. 59 | //! \param begin The begin write pointer returned by PutBegin(). 60 | //! \return Number of characters written. 61 | size_t PutEnd(Ch* begin); 62 | } 63 | \endcode 64 | */ 65 | 66 | //! Provides additional information for stream. 67 | /*! 68 | By using traits pattern, this type provides a default configuration for stream. 69 | For custom stream, this type can be specialized for other configuration. 70 | See TEST(Reader, CustomStringStream) in readertest.cpp for example. 71 | */ 72 | template 73 | struct StreamTraits { 74 | //! Whether to make local copy of stream for optimization during parsing. 75 | /*! 76 | By default, for safety, streams do not use local copy optimization. 77 | Stream that can be copied fast should specialize this, like StreamTraits. 78 | */ 79 | enum { copyOptimization = 0 }; 80 | }; 81 | 82 | //! Reserve n characters for writing to a stream. 83 | template 84 | inline void PutReserve(Stream& stream, size_t count) { 85 | (void)stream; 86 | (void)count; 87 | } 88 | 89 | //! Write character to a stream, presuming buffer is reserved. 90 | template 91 | inline void PutUnsafe(Stream& stream, typename Stream::Ch c) { 92 | stream.Put(c); 93 | } 94 | 95 | //! Put N copies of a character to a stream. 96 | template 97 | inline void PutN(Stream& stream, Ch c, size_t n) { 98 | PutReserve(stream, n); 99 | for (size_t i = 0; i < n; i++) 100 | PutUnsafe(stream, c); 101 | } 102 | 103 | /////////////////////////////////////////////////////////////////////////////// 104 | // GenericStreamWrapper 105 | 106 | //! A Stream Wrapper 107 | /*! \tThis string stream is a wrapper for any stream by just forwarding any 108 | \treceived message to the origin stream. 109 | \note implements Stream concept 110 | */ 111 | 112 | #if defined(_MSC_VER) && _MSC_VER <= 1800 113 | RAPIDJSON_DIAG_PUSH 114 | RAPIDJSON_DIAG_OFF(4702) // unreachable code 115 | RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated 116 | #endif 117 | 118 | template > 119 | class GenericStreamWrapper { 120 | public: 121 | typedef typename Encoding::Ch Ch; 122 | GenericStreamWrapper(InputStream& is): is_(is) {} 123 | 124 | Ch Peek() const { return is_.Peek(); } 125 | Ch Take() { return is_.Take(); } 126 | size_t Tell() { return is_.Tell(); } 127 | Ch* PutBegin() { return is_.PutBegin(); } 128 | void Put(Ch ch) { is_.Put(ch); } 129 | void Flush() { is_.Flush(); } 130 | size_t PutEnd(Ch* ch) { return is_.PutEnd(ch); } 131 | 132 | // wrapper for MemoryStream 133 | const Ch* Peek4() const { return is_.Peek4(); } 134 | 135 | // wrapper for AutoUTFInputStream 136 | UTFType GetType() const { return is_.GetType(); } 137 | bool HasBOM() const { return is_.HasBOM(); } 138 | 139 | protected: 140 | InputStream& is_; 141 | }; 142 | 143 | #if defined(_MSC_VER) && _MSC_VER <= 1800 144 | RAPIDJSON_DIAG_POP 145 | #endif 146 | 147 | /////////////////////////////////////////////////////////////////////////////// 148 | // StringStream 149 | 150 | //! Read-only string stream. 151 | /*! \note implements Stream concept 152 | */ 153 | template 154 | struct GenericStringStream { 155 | typedef typename Encoding::Ch Ch; 156 | 157 | GenericStringStream(const Ch *src) : src_(src), head_(src) {} 158 | 159 | Ch Peek() const { return *src_; } 160 | Ch Take() { return *src_++; } 161 | size_t Tell() const { return static_cast(src_ - head_); } 162 | 163 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 164 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 165 | void Flush() { RAPIDJSON_ASSERT(false); } 166 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 167 | 168 | const Ch* src_; //!< Current read position. 169 | const Ch* head_; //!< Original head of the string. 170 | }; 171 | 172 | template 173 | struct StreamTraits > { 174 | enum { copyOptimization = 1 }; 175 | }; 176 | 177 | //! String stream with UTF8 encoding. 178 | typedef GenericStringStream > StringStream; 179 | 180 | /////////////////////////////////////////////////////////////////////////////// 181 | // InsituStringStream 182 | 183 | //! A read-write string stream. 184 | /*! This string stream is particularly designed for in-situ parsing. 185 | \note implements Stream concept 186 | */ 187 | template 188 | struct GenericInsituStringStream { 189 | typedef typename Encoding::Ch Ch; 190 | 191 | GenericInsituStringStream(Ch *src) : src_(src), dst_(0), head_(src) {} 192 | 193 | // Read 194 | Ch Peek() { return *src_; } 195 | Ch Take() { return *src_++; } 196 | size_t Tell() { return static_cast(src_ - head_); } 197 | 198 | // Write 199 | void Put(Ch c) { RAPIDJSON_ASSERT(dst_ != 0); *dst_++ = c; } 200 | 201 | Ch* PutBegin() { return dst_ = src_; } 202 | size_t PutEnd(Ch* begin) { return static_cast(dst_ - begin); } 203 | void Flush() {} 204 | 205 | Ch* Push(size_t count) { Ch* begin = dst_; dst_ += count; return begin; } 206 | void Pop(size_t count) { dst_ -= count; } 207 | 208 | Ch* src_; 209 | Ch* dst_; 210 | Ch* head_; 211 | }; 212 | 213 | template 214 | struct StreamTraits > { 215 | enum { copyOptimization = 1 }; 216 | }; 217 | 218 | //! Insitu string stream with UTF8 encoding. 219 | typedef GenericInsituStringStream > InsituStringStream; 220 | 221 | RAPIDJSON_NAMESPACE_END 222 | 223 | #endif // RAPIDJSON_STREAM_H_ 224 | -------------------------------------------------------------------------------- /libs/rapidjson/stringbuffer.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_STRINGBUFFER_H_ 16 | #define RAPIDJSON_STRINGBUFFER_H_ 17 | 18 | #include "stream.h" 19 | #include "internal/stack.h" 20 | 21 | #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 22 | #include // std::move 23 | #endif 24 | 25 | #include "internal/stack.h" 26 | 27 | #if defined(__clang__) 28 | RAPIDJSON_DIAG_PUSH 29 | RAPIDJSON_DIAG_OFF(c++98-compat) 30 | #endif 31 | 32 | RAPIDJSON_NAMESPACE_BEGIN 33 | 34 | //! Represents an in-memory output stream. 35 | /*! 36 | \tparam Encoding Encoding of the stream. 37 | \tparam Allocator type for allocating memory buffer. 38 | \note implements Stream concept 39 | */ 40 | template 41 | class GenericStringBuffer { 42 | public: 43 | typedef typename Encoding::Ch Ch; 44 | 45 | GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 46 | 47 | #if RAPIDJSON_HAS_CXX11_RVALUE_REFS 48 | GenericStringBuffer(GenericStringBuffer&& rhs) : stack_(std::move(rhs.stack_)) {} 49 | GenericStringBuffer& operator=(GenericStringBuffer&& rhs) { 50 | if (&rhs != this) 51 | stack_ = std::move(rhs.stack_); 52 | return *this; 53 | } 54 | #endif 55 | 56 | void Put(Ch c) { *stack_.template Push() = c; } 57 | void PutUnsafe(Ch c) { *stack_.template PushUnsafe() = c; } 58 | void Flush() {} 59 | 60 | void Clear() { stack_.Clear(); } 61 | void ShrinkToFit() { 62 | // Push and pop a null terminator. This is safe. 63 | *stack_.template Push() = '\0'; 64 | stack_.ShrinkToFit(); 65 | stack_.template Pop(1); 66 | } 67 | 68 | void Reserve(size_t count) { stack_.template Reserve(count); } 69 | Ch* Push(size_t count) { return stack_.template Push(count); } 70 | Ch* PushUnsafe(size_t count) { return stack_.template PushUnsafe(count); } 71 | void Pop(size_t count) { stack_.template Pop(count); } 72 | 73 | const Ch* GetString() const { 74 | // Push and pop a null terminator. This is safe. 75 | *stack_.template Push() = '\0'; 76 | stack_.template Pop(1); 77 | 78 | return stack_.template Bottom(); 79 | } 80 | 81 | //! Get the size of string in bytes in the string buffer. 82 | size_t GetSize() const { return stack_.GetSize(); } 83 | 84 | //! Get the length of string in Ch in the string buffer. 85 | size_t GetLength() const { return stack_.GetSize() / sizeof(Ch); } 86 | 87 | static const size_t kDefaultCapacity = 256; 88 | mutable internal::Stack stack_; 89 | 90 | private: 91 | // Prohibit copy constructor & assignment operator. 92 | GenericStringBuffer(const GenericStringBuffer&); 93 | GenericStringBuffer& operator=(const GenericStringBuffer&); 94 | }; 95 | 96 | //! String buffer with UTF8 encoding 97 | typedef GenericStringBuffer > StringBuffer; 98 | 99 | template 100 | inline void PutReserve(GenericStringBuffer& stream, size_t count) { 101 | stream.Reserve(count); 102 | } 103 | 104 | template 105 | inline void PutUnsafe(GenericStringBuffer& stream, typename Encoding::Ch c) { 106 | stream.PutUnsafe(c); 107 | } 108 | 109 | //! Implement specialized version of PutN() with memset() for better performance. 110 | template<> 111 | inline void PutN(GenericStringBuffer >& stream, char c, size_t n) { 112 | std::memset(stream.stack_.Push(n), c, n * sizeof(c)); 113 | } 114 | 115 | RAPIDJSON_NAMESPACE_END 116 | 117 | #if defined(__clang__) 118 | RAPIDJSON_DIAG_POP 119 | #endif 120 | 121 | #endif // RAPIDJSON_STRINGBUFFER_H_ 122 | -------------------------------------------------------------------------------- /libs/shared/version.h: -------------------------------------------------------------------------------- 1 | #ifndef VERSION_H 2 | #define VERSION_H 3 | #include 4 | 5 | #define MAJOR_VERSION 0 6 | #define MINOR_VERSION 6 7 | #define PATCH_VERSION 37 8 | 9 | namespace xcite { 10 | inline std::string get_version() 11 | { 12 | return std::to_string(MAJOR_VERSION)+"."+std::to_string(MINOR_VERSION)+"."+std::to_string(PATCH_VERSION); 13 | } 14 | 15 | } 16 | 17 | 18 | #endif //VERSION_H 19 | -------------------------------------------------------------------------------- /tests/expected/employee_query1.unq: -------------------------------------------------------------------------------- 1 | "John" -------------------------------------------------------------------------------- /tests/expected/employee_query1.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query1.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query10.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "FirstName": "John", 4 | "LastName": "Smith" 5 | }, 6 | { 7 | "FirstName": "Elena", 8 | "LastName": "Brioche" 9 | } 10 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query10.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query10.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query10.unq.errors~: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query10.unq.errors~ -------------------------------------------------------------------------------- /tests/expected/employee_query10a.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "num": 2, 4 | "FirstName": "John", 5 | "LastName": "Smith" 6 | }, 7 | { 8 | "num": 1, 9 | "FirstName": "Dganit", 10 | "LastName": "Tirosh" 11 | }, 12 | { 13 | "num": 2, 14 | "FirstName": "Elena", 15 | "LastName": "Brioche" 16 | } 17 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query10a.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query10a.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query11.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "FullAddress": "123 Oak Street Austin TX, 78705" 4 | }, 5 | { 6 | "FullAddress": "500 Temple Street Oakland CA, 94001" 7 | }, 8 | { 9 | "FullAddress": "701H Highlander Avenue Oakland CA, 94001" 10 | }, 11 | { 12 | "FullAddress": "2 Manticore Ct Atlantic City NJ, 12345" 13 | }, 14 | { 15 | "FullAddress": "17 Whoknows street Nowhere NY, 10001" 16 | } 17 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query11.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query11.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query11a.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "FullAddress": "123 Oak Street Austin TX, 78705" 4 | }, 5 | { 6 | "FullAddress": "500 Temple Street Oakland CA, 94001" 7 | }, 8 | { 9 | "FullAddress": "701H Highlander Avenue Oakland CA, 94001" 10 | }, 11 | { 12 | "FullAddress": "2 Manticore Ct Atlantic City NJ, 12345" 13 | }, 14 | { 15 | "FullAddress": "17 Whoknows street Nowhere NY, 10001" 16 | } 17 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query11a.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query11a.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query12.unq: -------------------------------------------------------------------------------- 1 | { 2 | "Childen": [ 3 | "Jake Smith", 4 | "Jenna Smith", 5 | "Galit Tirosh-Ron", 6 | "Suzette Macaron", 7 | "Galette Macaron" 8 | ] 9 | } -------------------------------------------------------------------------------- /tests/expected/employee_query12.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query12.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query12a.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Children": [ 4 | "Jake Smith", 5 | "Jenna Smith" 6 | ] 7 | }, 8 | { 9 | "Children": [ 10 | "Galit Tirosh-Ron" 11 | ] 12 | }, 13 | { 14 | "Children": [ 15 | "Suzette Macaron", 16 | "Galette Macaron" 17 | ] 18 | } 19 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query12a.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query12a.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query12b.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Dependants": [ 4 | "Jane Smith", 5 | "Jake Smith" 6 | ] 7 | }, 8 | { 9 | "Dependants": [ 10 | "Yaniv Tirosh-Ron", 11 | "Galit Tirosh-Ron" 12 | ] 13 | }, 14 | { 15 | "Dependants": [ 16 | "Jacques Macaron", 17 | "Suzette Macaron" 18 | ] 19 | }, 20 | { 21 | "Dependants": [ 22 | "Shrodinger ", 23 | "Cogito Ergo-Sum" 24 | ] 25 | } 26 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query12b.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query12b.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query13.unq: -------------------------------------------------------------------------------- 1 | { 2 | "names": [ 3 | "John Smith", 4 | "Jane Smith", 5 | "Jake Smith", 6 | "Jenna Smith", 7 | "Dganit Tirosh", 8 | "Yaniv Tirosh-Ron", 9 | "Galit Tirosh-Ron", 10 | "Arthur McLaud", 11 | "Elena Brioche", 12 | "Jacques Macaron", 13 | "Suzette Macaron", 14 | "Galette Macaron", 15 | "Rene Descartes", 16 | "Shrodinger ", 17 | "Cogito Ergo-Sum" 18 | ] 19 | } -------------------------------------------------------------------------------- /tests/expected/employee_query13.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query13.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query14.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "FirstName": "John", 4 | "LastName": "Smith", 5 | "NumOfChildren": 2 6 | }, 7 | { 8 | "FirstName": "Dganit", 9 | "LastName": "Tirosh", 10 | "NumOfChildren": 1 11 | }, 12 | { 13 | "FirstName": "Arthur", 14 | "LastName": "McLaud" 15 | }, 16 | { 17 | "FirstName": "Elena", 18 | "LastName": "Brioche", 19 | "NumOfChildren": 2 20 | }, 21 | { 22 | "FirstName": "Rene", 23 | "LastName": "Descartes" 24 | } 25 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query14.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query14.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query14a.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "FirstName": "John", 4 | "LastName": "Smith" 5 | }, 6 | { 7 | "FirstName": "Elena", 8 | "LastName": "Brioche" 9 | } 10 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query14a.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query14a.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query15.unq: -------------------------------------------------------------------------------- 1 | { 2 | "Brioche": { 3 | "ID": "1004", 4 | "FirstName": "Elena", 5 | "LastName": "Brioche", 6 | "Title": "Senior Developer", 7 | "Salary": 150000, 8 | "Address": { 9 | "Street": "2 Manticore Ct", 10 | "City": "Atlantic City", 11 | "State": "NJ", 12 | "Zip": 12345 13 | }, 14 | "Dependants": [ 15 | { 16 | "FirstName": "Jacques", 17 | "LastName": "Macaron", 18 | "Relation": "Spouse" 19 | }, 20 | { 21 | "FirstName": "Suzette", 22 | "LastName": "Macaron", 23 | "Relation": "Child" 24 | }, 25 | { 26 | "FirstName": "Galette", 27 | "LastName": "Macaron", 28 | "Relation": "Child" 29 | } 30 | ] 31 | }, 32 | "Descartes": { 33 | "ID": "1005", 34 | "FirstName": "Rene", 35 | "LastName": "Descartes", 36 | "Title": "Janitor", 37 | "Salary": 700000, 38 | "Address": { 39 | "Street": "17 Whoknows street", 40 | "City": "Nowhere", 41 | "State": "NY", 42 | "Zip": 10001 43 | }, 44 | "Dependants": [ 45 | { 46 | "FirstName": "Shrodinger", 47 | "Relation": "Cat" 48 | }, 49 | { 50 | "FirstName": "Cogito", 51 | "LastName": "Ergo-Sum", 52 | "Relation": "Tortoise" 53 | } 54 | ] 55 | }, 56 | "McLaud": { 57 | "ID": "1003", 58 | "FirstName": "Arthur", 59 | "LastName": "McLaud", 60 | "Title": "Developer", 61 | "Salary": 120000, 62 | "Address": { 63 | "Street": "701H Highlander Avenue", 64 | "City": "Oakland", 65 | "State": "CA", 66 | "Zip": 94001 67 | } 68 | }, 69 | "Smith": { 70 | "ID": "1001", 71 | "FirstName": "John", 72 | "LastName": "Smith", 73 | "Title": "CTO", 74 | "Salary": 320000, 75 | "Address": { 76 | "Street": "123 Oak Street", 77 | "City": "Austin", 78 | "State": "TX", 79 | "Zip": 78705 80 | }, 81 | "Dependants": [ 82 | { 83 | "FirstName": "Jane", 84 | "LastName": "Smith", 85 | "Relation": "Spouse" 86 | }, 87 | { 88 | "FirstName": "Jake", 89 | "LastName": "Smith", 90 | "Relation": "Child" 91 | }, 92 | { 93 | "FirstName": "Jenna", 94 | "LastName": "Smith", 95 | "Relation": "Child" 96 | } 97 | ] 98 | }, 99 | "Tirosh": { 100 | "ID": "1002", 101 | "FirstName": "Dganit", 102 | "LastName": "Tirosh", 103 | "Title": "CEO", 104 | "Salary": 500000, 105 | "Address": { 106 | "Street": "500 Temple Street", 107 | "City": "Oakland", 108 | "State": "CA", 109 | "Zip": 94001 110 | }, 111 | "Dependants": [ 112 | { 113 | "FirstName": "Yaniv", 114 | "LastName": "Tirosh-Ron", 115 | "Relation": "Spouse" 116 | }, 117 | { 118 | "FirstName": "Galit", 119 | "LastName": "Tirosh-Ron", 120 | "Relation": "Child" 121 | } 122 | ] 123 | } 124 | } -------------------------------------------------------------------------------- /tests/expected/employee_query15.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query15.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query15a.unq: -------------------------------------------------------------------------------- 1 | { 2 | "Brioche Elena": { 3 | "ID": "1004", 4 | "FirstName": "Elena", 5 | "LastName": "Brioche", 6 | "Title": "Senior Developer", 7 | "Salary": 150000, 8 | "Address": { 9 | "Street": "2 Manticore Ct", 10 | "City": "Atlantic City", 11 | "State": "NJ", 12 | "Zip": 12345 13 | }, 14 | "Dependants": [ 15 | { 16 | "FirstName": "Jacques", 17 | "LastName": "Macaron", 18 | "Relation": "Spouse" 19 | }, 20 | { 21 | "FirstName": "Suzette", 22 | "LastName": "Macaron", 23 | "Relation": "Child" 24 | }, 25 | { 26 | "FirstName": "Galette", 27 | "LastName": "Macaron", 28 | "Relation": "Child" 29 | } 30 | ] 31 | }, 32 | "Descartes Rene": { 33 | "ID": "1005", 34 | "FirstName": "Rene", 35 | "LastName": "Descartes", 36 | "Title": "Janitor", 37 | "Salary": 700000, 38 | "Address": { 39 | "Street": "17 Whoknows street", 40 | "City": "Nowhere", 41 | "State": "NY", 42 | "Zip": 10001 43 | }, 44 | "Dependants": [ 45 | { 46 | "FirstName": "Shrodinger", 47 | "Relation": "Cat" 48 | }, 49 | { 50 | "FirstName": "Cogito", 51 | "LastName": "Ergo-Sum", 52 | "Relation": "Tortoise" 53 | } 54 | ] 55 | }, 56 | "McLaud Arthur": { 57 | "ID": "1003", 58 | "FirstName": "Arthur", 59 | "LastName": "McLaud", 60 | "Title": "Developer", 61 | "Salary": 120000, 62 | "Address": { 63 | "Street": "701H Highlander Avenue", 64 | "City": "Oakland", 65 | "State": "CA", 66 | "Zip": 94001 67 | } 68 | }, 69 | "Smith John": { 70 | "ID": "1001", 71 | "FirstName": "John", 72 | "LastName": "Smith", 73 | "Title": "CTO", 74 | "Salary": 320000, 75 | "Address": { 76 | "Street": "123 Oak Street", 77 | "City": "Austin", 78 | "State": "TX", 79 | "Zip": 78705 80 | }, 81 | "Dependants": [ 82 | { 83 | "FirstName": "Jane", 84 | "LastName": "Smith", 85 | "Relation": "Spouse" 86 | }, 87 | { 88 | "FirstName": "Jake", 89 | "LastName": "Smith", 90 | "Relation": "Child" 91 | }, 92 | { 93 | "FirstName": "Jenna", 94 | "LastName": "Smith", 95 | "Relation": "Child" 96 | } 97 | ] 98 | }, 99 | "Tirosh Dganit": { 100 | "ID": "1002", 101 | "FirstName": "Dganit", 102 | "LastName": "Tirosh", 103 | "Title": "CEO", 104 | "Salary": 500000, 105 | "Address": { 106 | "Street": "500 Temple Street", 107 | "City": "Oakland", 108 | "State": "CA", 109 | "Zip": 94001 110 | }, 111 | "Dependants": [ 112 | { 113 | "FirstName": "Yaniv", 114 | "LastName": "Tirosh-Ron", 115 | "Relation": "Spouse" 116 | }, 117 | { 118 | "FirstName": "Galit", 119 | "LastName": "Tirosh-Ron", 120 | "Relation": "Child" 121 | } 122 | ] 123 | } 124 | } -------------------------------------------------------------------------------- /tests/expected/employee_query15a.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query15a.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query15b.unq: -------------------------------------------------------------------------------- 1 | { 2 | "Brioche": [ 3 | { 4 | "ID": "1004", 5 | "FirstName": "Elena", 6 | "LastName": "Brioche", 7 | "Title": "Senior Developer", 8 | "Salary": 150000, 9 | "Address": { 10 | "Street": "2 Manticore Ct", 11 | "City": "Atlantic City", 12 | "State": "NJ", 13 | "Zip": 12345 14 | }, 15 | "Dependants": [ 16 | { 17 | "FirstName": "Jacques", 18 | "LastName": "Macaron", 19 | "Relation": "Spouse" 20 | }, 21 | { 22 | "FirstName": "Suzette", 23 | "LastName": "Macaron", 24 | "Relation": "Child" 25 | }, 26 | { 27 | "FirstName": "Galette", 28 | "LastName": "Macaron", 29 | "Relation": "Child" 30 | } 31 | ] 32 | } 33 | ], 34 | "Descartes": [ 35 | { 36 | "ID": "1005", 37 | "FirstName": "Rene", 38 | "LastName": "Descartes", 39 | "Title": "Janitor", 40 | "Salary": 700000, 41 | "Address": { 42 | "Street": "17 Whoknows street", 43 | "City": "Nowhere", 44 | "State": "NY", 45 | "Zip": 10001 46 | }, 47 | "Dependants": [ 48 | { 49 | "FirstName": "Shrodinger", 50 | "Relation": "Cat" 51 | }, 52 | { 53 | "FirstName": "Cogito", 54 | "LastName": "Ergo-Sum", 55 | "Relation": "Tortoise" 56 | } 57 | ] 58 | } 59 | ], 60 | "McLaud": [ 61 | { 62 | "ID": "1003", 63 | "FirstName": "Arthur", 64 | "LastName": "McLaud", 65 | "Title": "Developer", 66 | "Salary": 120000, 67 | "Address": { 68 | "Street": "701H Highlander Avenue", 69 | "City": "Oakland", 70 | "State": "CA", 71 | "Zip": 94001 72 | } 73 | } 74 | ], 75 | "Smith": [ 76 | { 77 | "ID": "1001", 78 | "FirstName": "John", 79 | "LastName": "Smith", 80 | "Title": "CTO", 81 | "Salary": 320000, 82 | "Address": { 83 | "Street": "123 Oak Street", 84 | "City": "Austin", 85 | "State": "TX", 86 | "Zip": 78705 87 | }, 88 | "Dependants": [ 89 | { 90 | "FirstName": "Jane", 91 | "LastName": "Smith", 92 | "Relation": "Spouse" 93 | }, 94 | { 95 | "FirstName": "Jake", 96 | "LastName": "Smith", 97 | "Relation": "Child" 98 | }, 99 | { 100 | "FirstName": "Jenna", 101 | "LastName": "Smith", 102 | "Relation": "Child" 103 | } 104 | ] 105 | } 106 | ], 107 | "Tirosh": [ 108 | { 109 | "ID": "1002", 110 | "FirstName": "Dganit", 111 | "LastName": "Tirosh", 112 | "Title": "CEO", 113 | "Salary": 500000, 114 | "Address": { 115 | "Street": "500 Temple Street", 116 | "City": "Oakland", 117 | "State": "CA", 118 | "Zip": 94001 119 | }, 120 | "Dependants": [ 121 | { 122 | "FirstName": "Yaniv", 123 | "LastName": "Tirosh-Ron", 124 | "Relation": "Spouse" 125 | }, 126 | { 127 | "FirstName": "Galit", 128 | "LastName": "Tirosh-Ron", 129 | "Relation": "Child" 130 | } 131 | ] 132 | } 133 | ] 134 | } -------------------------------------------------------------------------------- /tests/expected/employee_query15b.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query15b.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query16.unq: -------------------------------------------------------------------------------- 1 | { 2 | "dependants": { 3 | "Cat": [ 4 | { 5 | "FirstName": "Shrodinger", 6 | "Relation": "Cat" 7 | } 8 | ], 9 | "Child": [ 10 | { 11 | "FirstName": "Jake", 12 | "LastName": "Smith", 13 | "Relation": "Child" 14 | }, 15 | { 16 | "FirstName": "Jenna", 17 | "LastName": "Smith", 18 | "Relation": "Child" 19 | }, 20 | { 21 | "FirstName": "Galit", 22 | "LastName": "Tirosh-Ron", 23 | "Relation": "Child" 24 | }, 25 | { 26 | "FirstName": "Suzette", 27 | "LastName": "Macaron", 28 | "Relation": "Child" 29 | }, 30 | { 31 | "FirstName": "Galette", 32 | "LastName": "Macaron", 33 | "Relation": "Child" 34 | } 35 | ], 36 | "Spouse": [ 37 | { 38 | "FirstName": "Jane", 39 | "LastName": "Smith", 40 | "Relation": "Spouse" 41 | }, 42 | { 43 | "FirstName": "Yaniv", 44 | "LastName": "Tirosh-Ron", 45 | "Relation": "Spouse" 46 | }, 47 | { 48 | "FirstName": "Jacques", 49 | "LastName": "Macaron", 50 | "Relation": "Spouse" 51 | } 52 | ], 53 | "Tortoise": [ 54 | { 55 | "FirstName": "Cogito", 56 | "LastName": "Ergo-Sum", 57 | "Relation": "Tortoise" 58 | } 59 | ] 60 | } 61 | } -------------------------------------------------------------------------------- /tests/expected/employee_query16.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query16.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query16a.unq: -------------------------------------------------------------------------------- 1 | { 2 | "dependants": { 3 | "Cat": 1, 4 | "Child": 5, 5 | "Spouse": 3, 6 | "Tortoise": 1 7 | } 8 | } -------------------------------------------------------------------------------- /tests/expected/employee_query16a.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query16a.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query17.unq: -------------------------------------------------------------------------------- 1 | { 2 | "1001": { 3 | "Filename": "../tutorial-samples/employees/employee1.json", 4 | "ID": "1001", 5 | "FirstName": "John", 6 | "LastName": "Smith", 7 | "Title": "CTO", 8 | "Salary": 320000, 9 | "Address": { 10 | "Street": "123 Oak Street", 11 | "City": "Austin", 12 | "State": "TX", 13 | "Zip": 78705 14 | }, 15 | "Dependants": [ 16 | { 17 | "FirstName": "Jane", 18 | "LastName": "Smith", 19 | "Relation": "Spouse" 20 | }, 21 | { 22 | "FirstName": "Jake", 23 | "LastName": "Smith", 24 | "Relation": "Child" 25 | }, 26 | { 27 | "FirstName": "Jenna", 28 | "LastName": "Smith", 29 | "Relation": "Child" 30 | } 31 | ] 32 | }, 33 | "1002": { 34 | "Filename": "../tutorial-samples/employees/employee2.json", 35 | "ID": "1002", 36 | "FirstName": "Dganit", 37 | "LastName": "Tirosh", 38 | "Title": "CEO", 39 | "Salary": 500000, 40 | "Address": { 41 | "Street": "500 Temple Street", 42 | "City": "Oakland", 43 | "State": "CA", 44 | "Zip": 94001 45 | }, 46 | "Dependants": [ 47 | { 48 | "FirstName": "Yaniv", 49 | "LastName": "Tirosh-Ron", 50 | "Relation": "Spouse" 51 | }, 52 | { 53 | "FirstName": "Galit", 54 | "LastName": "Tirosh-Ron", 55 | "Relation": "Child" 56 | } 57 | ] 58 | }, 59 | "1003": { 60 | "Filename": "../tutorial-samples/employees/employee3.json", 61 | "ID": "1003", 62 | "FirstName": "Arthur", 63 | "LastName": "McLaud", 64 | "Title": "Developer", 65 | "Salary": 120000, 66 | "Address": { 67 | "Street": "701H Highlander Avenue", 68 | "City": "Oakland", 69 | "State": "CA", 70 | "Zip": 94001 71 | } 72 | }, 73 | "1004": { 74 | "Filename": "../tutorial-samples/employees/employee4.json", 75 | "ID": "1004", 76 | "FirstName": "Elena", 77 | "LastName": "Brioche", 78 | "Title": "Senior Developer", 79 | "Salary": 150000, 80 | "Address": { 81 | "Street": "2 Manticore Ct", 82 | "City": "Atlantic City", 83 | "State": "NJ", 84 | "Zip": 12345 85 | }, 86 | "Dependants": [ 87 | { 88 | "FirstName": "Jacques", 89 | "LastName": "Macaron", 90 | "Relation": "Spouse" 91 | }, 92 | { 93 | "FirstName": "Suzette", 94 | "LastName": "Macaron", 95 | "Relation": "Child" 96 | }, 97 | { 98 | "FirstName": "Galette", 99 | "LastName": "Macaron", 100 | "Relation": "Child" 101 | } 102 | ] 103 | }, 104 | "1005": { 105 | "Filename": "../tutorial-samples/employees/employee5.json", 106 | "ID": "1005", 107 | "FirstName": "Rene", 108 | "LastName": "Descartes", 109 | "Title": "Janitor", 110 | "Salary": 700000, 111 | "Address": { 112 | "Street": "17 Whoknows street", 113 | "City": "Nowhere", 114 | "State": "NY", 115 | "Zip": 10001 116 | }, 117 | "Dependants": [ 118 | { 119 | "FirstName": "Shrodinger", 120 | "Relation": "Cat" 121 | }, 122 | { 123 | "FirstName": "Cogito", 124 | "LastName": "Ergo-Sum", 125 | "Relation": "Tortoise" 126 | } 127 | ] 128 | } 129 | } -------------------------------------------------------------------------------- /tests/expected/employee_query17.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query17.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query17a.unq: -------------------------------------------------------------------------------- 1 | { 2 | "1001": { 3 | "FirstName": "John", 4 | "LastName": "Smith", 5 | "Title": "CTO", 6 | "Salary": 320000, 7 | "Address": { 8 | "Street": "123 Oak Street", 9 | "City": "Austin", 10 | "State": "TX", 11 | "Zip": 78705 12 | }, 13 | "Dependants": [ 14 | { 15 | "FirstName": "Jane", 16 | "LastName": "Smith", 17 | "Relation": "Spouse" 18 | }, 19 | { 20 | "FirstName": "Jake", 21 | "LastName": "Smith", 22 | "Relation": "Child" 23 | }, 24 | { 25 | "FirstName": "Jenna", 26 | "LastName": "Smith", 27 | "Relation": "Child" 28 | } 29 | ] 30 | }, 31 | "1002": { 32 | "FirstName": "Dganit", 33 | "LastName": "Tirosh", 34 | "Title": "CEO", 35 | "Salary": 500000, 36 | "Address": { 37 | "Street": "500 Temple Street", 38 | "City": "Oakland", 39 | "State": "CA", 40 | "Zip": 94001 41 | }, 42 | "Dependants": [ 43 | { 44 | "FirstName": "Yaniv", 45 | "LastName": "Tirosh-Ron", 46 | "Relation": "Spouse" 47 | }, 48 | { 49 | "FirstName": "Galit", 50 | "LastName": "Tirosh-Ron", 51 | "Relation": "Child" 52 | } 53 | ] 54 | }, 55 | "1003": { 56 | "FirstName": "Arthur", 57 | "LastName": "McLaud", 58 | "Title": "Developer", 59 | "Salary": 120000, 60 | "Address": { 61 | "Street": "701H Highlander Avenue", 62 | "City": "Oakland", 63 | "State": "CA", 64 | "Zip": 94001 65 | } 66 | }, 67 | "1004": { 68 | "FirstName": "Elena", 69 | "LastName": "Brioche", 70 | "Title": "Senior Developer", 71 | "Salary": 150000, 72 | "Address": { 73 | "Street": "2 Manticore Ct", 74 | "City": "Atlantic City", 75 | "State": "NJ", 76 | "Zip": 12345 77 | }, 78 | "Dependants": [ 79 | { 80 | "FirstName": "Jacques", 81 | "LastName": "Macaron", 82 | "Relation": "Spouse" 83 | }, 84 | { 85 | "FirstName": "Suzette", 86 | "LastName": "Macaron", 87 | "Relation": "Child" 88 | }, 89 | { 90 | "FirstName": "Galette", 91 | "LastName": "Macaron", 92 | "Relation": "Child" 93 | } 94 | ] 95 | }, 96 | "1005": { 97 | "FirstName": "Rene", 98 | "LastName": "Descartes", 99 | "Title": "Janitor", 100 | "Salary": 700000, 101 | "Address": { 102 | "Street": "17 Whoknows street", 103 | "City": "Nowhere", 104 | "State": "NY", 105 | "Zip": 10001 106 | }, 107 | "Dependants": [ 108 | { 109 | "FirstName": "Shrodinger", 110 | "Relation": "Cat" 111 | }, 112 | { 113 | "FirstName": "Cogito", 114 | "LastName": "Ergo-Sum", 115 | "Relation": "Tortoise" 116 | } 117 | ] 118 | } 119 | } -------------------------------------------------------------------------------- /tests/expected/employee_query17a.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query17a.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query17b.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "employee": { 4 | "Filename": "../tutorial-samples/employees/employee1.json", 5 | "ID": "1001", 6 | "FirstName": "John", 7 | "LastName": "Smith", 8 | "Title": "CTO", 9 | "Salary": 320000, 10 | "Address": { 11 | "Street": "123 Oak Street", 12 | "City": "Austin", 13 | "State": "TX", 14 | "Zip": 78705 15 | }, 16 | "Dependants": [ 17 | { 18 | "FirstName": "Jane", 19 | "LastName": "Smith", 20 | "Relation": "Spouse" 21 | }, 22 | { 23 | "FirstName": "Jake", 24 | "LastName": "Smith", 25 | "Relation": "Child" 26 | }, 27 | { 28 | "FirstName": "Jenna", 29 | "LastName": "Smith", 30 | "Relation": "Child" 31 | } 32 | ] 33 | } 34 | }, 35 | { 36 | "employee": { 37 | "Filename": "../tutorial-samples/employees/employee2.json", 38 | "ID": "1002", 39 | "FirstName": "Dganit", 40 | "LastName": "Tirosh", 41 | "Title": "CEO", 42 | "Salary": 500000, 43 | "Address": { 44 | "Street": "500 Temple Street", 45 | "City": "Oakland", 46 | "State": "CA", 47 | "Zip": 94001 48 | }, 49 | "Dependants": [ 50 | { 51 | "FirstName": "Yaniv", 52 | "LastName": "Tirosh-Ron", 53 | "Relation": "Spouse" 54 | }, 55 | { 56 | "FirstName": "Galit", 57 | "LastName": "Tirosh-Ron", 58 | "Relation": "Child" 59 | } 60 | ] 61 | } 62 | }, 63 | { 64 | "employee": { 65 | "Filename": "../tutorial-samples/employees/employee3.json", 66 | "ID": "1003", 67 | "FirstName": "Arthur", 68 | "LastName": "McLaud", 69 | "Title": "Developer", 70 | "Salary": 120000, 71 | "Address": { 72 | "Street": "701H Highlander Avenue", 73 | "City": "Oakland", 74 | "State": "CA", 75 | "Zip": 94001 76 | } 77 | } 78 | }, 79 | { 80 | "employee": { 81 | "Filename": "../tutorial-samples/employees/employee4.json", 82 | "ID": "1004", 83 | "FirstName": "Elena", 84 | "LastName": "Brioche", 85 | "Title": "Senior Developer", 86 | "Salary": 150000, 87 | "Address": { 88 | "Street": "2 Manticore Ct", 89 | "City": "Atlantic City", 90 | "State": "NJ", 91 | "Zip": 12345 92 | }, 93 | "Dependants": [ 94 | { 95 | "FirstName": "Jacques", 96 | "LastName": "Macaron", 97 | "Relation": "Spouse" 98 | }, 99 | { 100 | "FirstName": "Suzette", 101 | "LastName": "Macaron", 102 | "Relation": "Child" 103 | }, 104 | { 105 | "FirstName": "Galette", 106 | "LastName": "Macaron", 107 | "Relation": "Child" 108 | } 109 | ] 110 | } 111 | }, 112 | { 113 | "employee": { 114 | "Filename": "../tutorial-samples/employees/employee5.json", 115 | "ID": "1005", 116 | "FirstName": "Rene", 117 | "LastName": "Descartes", 118 | "Title": "Janitor", 119 | "Salary": 700000, 120 | "Address": { 121 | "Street": "17 Whoknows street", 122 | "City": "Nowhere", 123 | "State": "NY", 124 | "Zip": 10001 125 | }, 126 | "Dependants": [ 127 | { 128 | "FirstName": "Shrodinger", 129 | "Relation": "Cat" 130 | }, 131 | { 132 | "FirstName": "Cogito", 133 | "LastName": "Ergo-Sum", 134 | "Relation": "Tortoise" 135 | } 136 | ] 137 | } 138 | } 139 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query17b.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query17b.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query17c.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "Filename": "../tutorial-samples/employees/employee1.json", 4 | "ID": "1001", 5 | "FirstName": "John", 6 | "LastName": "Smith", 7 | "Title": "CTO", 8 | "Salary": 320000, 9 | "Address": { 10 | "Street": "123 Oak Street", 11 | "City": "Austin", 12 | "State": "TX", 13 | "Zip": 78705 14 | }, 15 | "Dependants": [ 16 | { 17 | "FirstName": "Jane", 18 | "LastName": "Smith", 19 | "Relation": "Spouse" 20 | }, 21 | { 22 | "FirstName": "Jake", 23 | "LastName": "Smith", 24 | "Relation": "Child" 25 | }, 26 | { 27 | "FirstName": "Jenna", 28 | "LastName": "Smith", 29 | "Relation": "Child" 30 | } 31 | ] 32 | }, 33 | { 34 | "Filename": "../tutorial-samples/employees/employee2.json", 35 | "ID": "1002", 36 | "FirstName": "Dganit", 37 | "LastName": "Tirosh", 38 | "Title": "CEO", 39 | "Salary": 500000, 40 | "Address": { 41 | "Street": "500 Temple Street", 42 | "City": "Oakland", 43 | "State": "CA", 44 | "Zip": 94001 45 | }, 46 | "Dependants": [ 47 | { 48 | "FirstName": "Yaniv", 49 | "LastName": "Tirosh-Ron", 50 | "Relation": "Spouse" 51 | }, 52 | { 53 | "FirstName": "Galit", 54 | "LastName": "Tirosh-Ron", 55 | "Relation": "Child" 56 | } 57 | ] 58 | }, 59 | { 60 | "Filename": "../tutorial-samples/employees/employee3.json", 61 | "ID": "1003", 62 | "FirstName": "Arthur", 63 | "LastName": "McLaud", 64 | "Title": "Developer", 65 | "Salary": 120000, 66 | "Address": { 67 | "Street": "701H Highlander Avenue", 68 | "City": "Oakland", 69 | "State": "CA", 70 | "Zip": 94001 71 | } 72 | }, 73 | { 74 | "Filename": "../tutorial-samples/employees/employee4.json", 75 | "ID": "1004", 76 | "FirstName": "Elena", 77 | "LastName": "Brioche", 78 | "Title": "Senior Developer", 79 | "Salary": 150000, 80 | "Address": { 81 | "Street": "2 Manticore Ct", 82 | "City": "Atlantic City", 83 | "State": "NJ", 84 | "Zip": 12345 85 | }, 86 | "Dependants": [ 87 | { 88 | "FirstName": "Jacques", 89 | "LastName": "Macaron", 90 | "Relation": "Spouse" 91 | }, 92 | { 93 | "FirstName": "Suzette", 94 | "LastName": "Macaron", 95 | "Relation": "Child" 96 | }, 97 | { 98 | "FirstName": "Galette", 99 | "LastName": "Macaron", 100 | "Relation": "Child" 101 | } 102 | ] 103 | }, 104 | { 105 | "Filename": "../tutorial-samples/employees/employee5.json", 106 | "ID": "1005", 107 | "FirstName": "Rene", 108 | "LastName": "Descartes", 109 | "Title": "Janitor", 110 | "Salary": 700000, 111 | "Address": { 112 | "Street": "17 Whoknows street", 113 | "City": "Nowhere", 114 | "State": "NY", 115 | "Zip": 10001 116 | }, 117 | "Dependants": [ 118 | { 119 | "FirstName": "Shrodinger", 120 | "Relation": "Cat" 121 | }, 122 | { 123 | "FirstName": "Cogito", 124 | "LastName": "Ergo-Sum", 125 | "Relation": "Tortoise" 126 | } 127 | ] 128 | } 129 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query17c.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query17c.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query17d.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "ID": "1001", 4 | "FirstName": "John", 5 | "LastName": "Smith", 6 | "Title": "CTO", 7 | "Salary": 320000, 8 | "Address": { 9 | "Street": "123 Oak Street", 10 | "City": "Austin", 11 | "State": "TX", 12 | "Zip": 78705 13 | } 14 | }, 15 | { 16 | "ID": "1002", 17 | "FirstName": "Dganit", 18 | "LastName": "Tirosh", 19 | "Title": "CEO", 20 | "Salary": 500000, 21 | "Address": { 22 | "Street": "500 Temple Street", 23 | "City": "Oakland", 24 | "State": "CA", 25 | "Zip": 94001 26 | } 27 | }, 28 | { 29 | "ID": "1003", 30 | "FirstName": "Arthur", 31 | "LastName": "McLaud", 32 | "Title": "Developer", 33 | "Salary": 120000, 34 | "Address": { 35 | "Street": "701H Highlander Avenue", 36 | "City": "Oakland", 37 | "State": "CA", 38 | "Zip": 94001 39 | } 40 | }, 41 | { 42 | "ID": "1004", 43 | "FirstName": "Elena", 44 | "LastName": "Brioche", 45 | "Title": "Senior Developer", 46 | "Salary": 150000, 47 | "Address": { 48 | "Street": "2 Manticore Ct", 49 | "City": "Atlantic City", 50 | "State": "NJ", 51 | "Zip": 12345 52 | } 53 | }, 54 | { 55 | "ID": "1005", 56 | "FirstName": "Rene", 57 | "LastName": "Descartes", 58 | "Title": "Janitor", 59 | "Salary": 700000, 60 | "Address": { 61 | "Street": "17 Whoknows street", 62 | "City": "Nowhere", 63 | "State": "NY", 64 | "Zip": 10001 65 | } 66 | } 67 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query17d.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query17d.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query18.unq: -------------------------------------------------------------------------------- 1 | { 2 | "all_dependants": [ 3 | { 4 | "FirstName": "Jane", 5 | "LastName": "Smith", 6 | "Relation": "Spouse", 7 | "Employee": "John Smith" 8 | }, 9 | { 10 | "FirstName": "Jake", 11 | "LastName": "Smith", 12 | "Relation": "Child", 13 | "Employee": "John Smith" 14 | }, 15 | { 16 | "FirstName": "Jenna", 17 | "LastName": "Smith", 18 | "Relation": "Child", 19 | "Employee": "John Smith" 20 | }, 21 | { 22 | "FirstName": "Yaniv", 23 | "LastName": "Tirosh-Ron", 24 | "Relation": "Spouse", 25 | "Employee": "Dganit Tirosh" 26 | }, 27 | { 28 | "FirstName": "Galit", 29 | "LastName": "Tirosh-Ron", 30 | "Relation": "Child", 31 | "Employee": "Dganit Tirosh" 32 | }, 33 | { 34 | "FirstName": "Jacques", 35 | "LastName": "Macaron", 36 | "Relation": "Spouse", 37 | "Employee": "Elena Brioche" 38 | }, 39 | { 40 | "FirstName": "Suzette", 41 | "LastName": "Macaron", 42 | "Relation": "Child", 43 | "Employee": "Elena Brioche" 44 | }, 45 | { 46 | "FirstName": "Galette", 47 | "LastName": "Macaron", 48 | "Relation": "Child", 49 | "Employee": "Elena Brioche" 50 | }, 51 | { 52 | "FirstName": "Shrodinger", 53 | "Relation": "Cat", 54 | "Employee": "Rene Descartes" 55 | }, 56 | { 57 | "FirstName": "Cogito", 58 | "LastName": "Ergo-Sum", 59 | "Relation": "Tortoise", 60 | "Employee": "Rene Descartes" 61 | } 62 | ] 63 | } -------------------------------------------------------------------------------- /tests/expected/employee_query18.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query18.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query19.unq: -------------------------------------------------------------------------------- 1 | { 2 | "employees": [ 3 | { 4 | "FirstName": "John", 5 | "LastName": "Smith", 6 | "State": "Texas" 7 | }, 8 | { 9 | "FirstName": "Dganit", 10 | "LastName": "Tirosh", 11 | "State": "California" 12 | }, 13 | { 14 | "FirstName": "Arthur", 15 | "LastName": "McLaud", 16 | "State": "California" 17 | }, 18 | { 19 | "FirstName": "Elena", 20 | "LastName": "Brioche", 21 | "State": "New Jersey" 22 | }, 23 | { 24 | "FirstName": "Rene", 25 | "LastName": "Descartes", 26 | "State": "New York" 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /tests/expected/employee_query19.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query19.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query2.unq: -------------------------------------------------------------------------------- 1 | "Austin" -------------------------------------------------------------------------------- /tests/expected/employee_query2.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query2.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query20.unq: -------------------------------------------------------------------------------- 1 | [ 2 | "John Smith", 3 | "Jane Smith", 4 | "Jake Smith", 5 | "Jenna Smith", 6 | "Dganit Tirosh", 7 | "Yaniv Tirosh-Ron", 8 | "Galit Tirosh-Ron", 9 | "Arthur McLaud", 10 | "Elena Brioche", 11 | "Jacques Macaron", 12 | "Suzette Macaron", 13 | "Galette Macaron", 14 | "Rene Descartes", 15 | "Shrodinger ", 16 | "Cogito Ergo-Sum" 17 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query20.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query20.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query20a.unq: -------------------------------------------------------------------------------- 1 | [ 2 | "Address", 3 | "City", 4 | "Dependants", 5 | "FirstName", 6 | "ID", 7 | "LastName", 8 | "Relation", 9 | "Salary", 10 | "State", 11 | "Street", 12 | "Title", 13 | "Zip" 14 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query20a.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query20a.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query21.unq: -------------------------------------------------------------------------------- 1 | [ 2 | [ 3 | "Jane", 4 | "Jake", 5 | "Jenna" 6 | ], 7 | [ 8 | "Yaniv", 9 | "Galit" 10 | ], 11 | [ 12 | "Jacques", 13 | "Suzette", 14 | "Galette" 15 | ], 16 | [ 17 | "Shrodinger", 18 | "Cogito" 19 | ] 20 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query21.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query21.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query3.unq: -------------------------------------------------------------------------------- 1 | "Jane" -------------------------------------------------------------------------------- /tests/expected/employee_query3.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query3.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query4.unq: -------------------------------------------------------------------------------- 1 | { 2 | "fullname": "John Smith", 3 | "title": "CTO", 4 | "city": "Austin" 5 | } -------------------------------------------------------------------------------- /tests/expected/employee_query4.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query4.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query5.unq: -------------------------------------------------------------------------------- 1 | { 2 | "name": "John Smith", 3 | "employment": { 4 | "title": "CTO", 5 | "salary": 320000 6 | } 7 | } -------------------------------------------------------------------------------- /tests/expected/employee_query5.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query5.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query6.unq: -------------------------------------------------------------------------------- 1 | [ 2 | "John", 3 | "Dganit", 4 | "Arthur", 5 | "Elena", 6 | "Rene" 7 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query6.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query6.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query7.unq: -------------------------------------------------------------------------------- 1 | [ 2 | "Arthur", 3 | "Dganit", 4 | "Elena", 5 | "John", 6 | "Rene" 7 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query7.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query7.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query8.unq: -------------------------------------------------------------------------------- 1 | [ 2 | "Smith", 3 | "Tirosh", 4 | "Descartes" 5 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query8.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query8.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_query9.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "FirstName": "Arthur", 4 | "LastName": "McLaud", 5 | "Title": "Developer" 6 | }, 7 | { 8 | "FirstName": "Elena", 9 | "LastName": "Brioche", 10 | "Title": "Senior Developer" 11 | } 12 | ] -------------------------------------------------------------------------------- /tests/expected/employee_query9.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_query9.unq.errors -------------------------------------------------------------------------------- /tests/expected/employee_tolowerkeys.unq: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "address": { 4 | "city": "Austin", 5 | "state": "TX", 6 | "street": "123 Oak Street", 7 | "zip": 78705 8 | }, 9 | "dependants": [ 10 | { 11 | "firstname": "Jane", 12 | "lastname": "Smith", 13 | "relation": "Spouse" 14 | }, 15 | { 16 | "firstname": "Jake", 17 | "lastname": "Smith", 18 | "relation": "Child" 19 | }, 20 | { 21 | "firstname": "Jenna", 22 | "lastname": "Smith", 23 | "relation": "Child" 24 | } 25 | ], 26 | "firstname": "John", 27 | "id": "1001", 28 | "lastname": "Smith", 29 | "salary": 320000, 30 | "title": "CTO" 31 | }, 32 | { 33 | "address": { 34 | "city": "Oakland", 35 | "state": "CA", 36 | "street": "500 Temple Street", 37 | "zip": 94001 38 | }, 39 | "dependants": [ 40 | { 41 | "firstname": "Yaniv", 42 | "lastname": "Tirosh-Ron", 43 | "relation": "Spouse" 44 | }, 45 | { 46 | "firstname": "Galit", 47 | "lastname": "Tirosh-Ron", 48 | "relation": "Child" 49 | } 50 | ], 51 | "firstname": "Dganit", 52 | "id": "1002", 53 | "lastname": "Tirosh", 54 | "salary": 500000, 55 | "title": "CEO" 56 | }, 57 | { 58 | "address": { 59 | "city": "Oakland", 60 | "state": "CA", 61 | "street": "701H Highlander Avenue", 62 | "zip": 94001 63 | }, 64 | "firstname": "Arthur", 65 | "id": "1003", 66 | "lastname": "McLaud", 67 | "salary": 120000, 68 | "title": "Developer" 69 | }, 70 | { 71 | "address": { 72 | "city": "Atlantic City", 73 | "state": "NJ", 74 | "street": "2 Manticore Ct", 75 | "zip": 12345 76 | }, 77 | "dependants": [ 78 | { 79 | "firstname": "Jacques", 80 | "lastname": "Macaron", 81 | "relation": "Spouse" 82 | }, 83 | { 84 | "firstname": "Suzette", 85 | "lastname": "Macaron", 86 | "relation": "Child" 87 | }, 88 | { 89 | "firstname": "Galette", 90 | "lastname": "Macaron", 91 | "relation": "Child" 92 | } 93 | ], 94 | "firstname": "Elena", 95 | "id": "1004", 96 | "lastname": "Brioche", 97 | "salary": 150000, 98 | "title": "Senior Developer" 99 | }, 100 | { 101 | "address": { 102 | "city": "Nowhere", 103 | "state": "NY", 104 | "street": "17 Whoknows street", 105 | "zip": 10001 106 | }, 107 | "dependants": [ 108 | { 109 | "firstname": "Shrodinger", 110 | "relation": "Cat" 111 | }, 112 | { 113 | "firstname": "Cogito", 114 | "lastname": "Ergo-Sum", 115 | "relation": "Tortoise" 116 | } 117 | ], 118 | "firstname": "Rene", 119 | "id": "1005", 120 | "lastname": "Descartes", 121 | "salary": 700000, 122 | "title": "Janitor" 123 | } 124 | ] -------------------------------------------------------------------------------- /tests/expected/employee_tolowerkeys.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/employee_tolowerkeys.unq.errors -------------------------------------------------------------------------------- /tests/expected/extra_test1.unq: -------------------------------------------------------------------------------- 1 | "yes" -------------------------------------------------------------------------------- /tests/expected/extra_test2.unq: -------------------------------------------------------------------------------- 1 | { 2 | "date": "2022-07-14" 3 | } -------------------------------------------------------------------------------- /tests/expected/parsing_aggregate.unq: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /tests/expected/parsing_aggregate.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/parsing_aggregate.unq.errors -------------------------------------------------------------------------------- /tests/expected/parsing_aggregateCond.unq: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /tests/expected/parsing_aggregateCond.unq.errors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/parsing_aggregateCond.unq.errors -------------------------------------------------------------------------------- /tests/expected/parsing_aggregatebadcond.unq: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xcite-db/Unquery/cb6c8c46e3575a0a05185f921f03e663625ddd78/tests/expected/parsing_aggregatebadcond.unq -------------------------------------------------------------------------------- /tests/expected/parsing_aggregatebadcond.unq.errors: -------------------------------------------------------------------------------- 1 | Error parsing Q! Query: Error at: $max(Salary)5" -------------------------------------------------------------------------------- /tests/parsing/aggregatebadcond.unq: -------------------------------------------------------------------------------- 1 | "$max(Salary)field2,field1,field2)" 2 | -------------------------------------------------------------------------------- /tests/parsing/conditions.unq: -------------------------------------------------------------------------------- 1 | { 2 | "cond1":"ID?Title='CTO'", 3 | "cond2":"ID?(Title='President'|Title='CTO')", 4 | "cond3":"ID?(Title)='CTO'", 5 | "cond4":"ID?((Title)='CTO')", 6 | "cond5":"ID?!(Title='President'|Title='CEO')", 7 | "cond6":"ID?((Title='President')|(Title='CTO'))&(Salary>10000)", 8 | "cond7":"ID?((Title='President')|(Title='CTO'))&(Salary<10000)" 9 | } 10 | -------------------------------------------------------------------------------- /tests/parsing/emptyquotes.unq: -------------------------------------------------------------------------------- 1 | "" 2 | -------------------------------------------------------------------------------- /tests/parsing/float.unq: -------------------------------------------------------------------------------- 1 | "1.5" -------------------------------------------------------------------------------- /tests/parsing/functiondefinedtwice.unq: -------------------------------------------------------------------------------- 1 | { 2 | "#func fn_x":"FirstName", 3 | "#func fn_x":"LastName", 4 | "x":"$fn_x" 5 | } 6 | -------------------------------------------------------------------------------- /tests/parsing/functionnotdefined.unq: -------------------------------------------------------------------------------- 1 | { 2 | "#func fn_x":"FirstName", 3 | "x":"$fn_x", 4 | "y":"$fn_y" 5 | } 6 | -------------------------------------------------------------------------------- /tests/parsing/integer.unq: -------------------------------------------------------------------------------- 1 | "5" -------------------------------------------------------------------------------- /tests/parsing/openbacktick.unq: -------------------------------------------------------------------------------- 1 | "`" -------------------------------------------------------------------------------- /tests/parsing/openquote.unq: -------------------------------------------------------------------------------- 1 | "\"" -------------------------------------------------------------------------------- /tests/parsing/opensinglequote.unq: -------------------------------------------------------------------------------- 1 | "'" -------------------------------------------------------------------------------- /tests/parsing/stringconst.unq: -------------------------------------------------------------------------------- 1 | "'testing123'" -------------------------------------------------------------------------------- /tests/parsing/stringconst2.unq: -------------------------------------------------------------------------------- 1 | "\"testing123\"" -------------------------------------------------------------------------------- /tests/parsing/var_good.unq: -------------------------------------------------------------------------------- 1 | { 2 | "#var x":"'hello'", 3 | "x1":"$var(x)", 4 | "x2":"%x" 5 | } -------------------------------------------------------------------------------- /tests/stackoverflow/18592173.json: -------------------------------------------------------------------------------- 1 | // https://stackoverflow.com/questions/18592173/select-objects-based-on-value-of-variable-in-object-using-jq 2 | { 3 | "FOO": { 4 | "name": "Donald", 5 | "location": "Stockholm" 6 | }, 7 | "BAR": { 8 | "name": "Walt", 9 | "location": "Stockholm" 10 | }, 11 | "BAZ": { 12 | "name": "Jack", 13 | "location": "Whereever" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/stackoverflow/18592173.unq: -------------------------------------------------------------------------------- 1 | /* 2 | Source: 3 | https://stackoverflow.com/questions/18592173/select-objects-based-on-value-of-variable-in-object-using-jq 4 | 5 | The corresponding jq query: 6 | jq '.[] | select(.location=="Stockholm") | .name' json 7 | 8 | */ 9 | { "#return:{}": ["name?location='Stockholm'"]} 10 | -------------------------------------------------------------------------------- /tests/stackoverflow/19441454.json: -------------------------------------------------------------------------------- 1 | { 2 | "d": { 3 | "e": { 4 | "bar": 2 5 | } 6 | }, 7 | "a": { 8 | "b": { 9 | "c": { 10 | "foo": 1 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/stackoverflow/19441454.unq: -------------------------------------------------------------------------------- 1 | /* 2 | Source: 3 | https://stackoverflow.com/questions/19441454/json-parsing-on-cli-using-jq 4 | */ 5 | { 6 | "#return:**?$key='foo'":"." 7 | } 8 | -------------------------------------------------------------------------------- /tests/stackoverflow/19529688.json: -------------------------------------------------------------------------------- 1 | //File 1 2 | { 3 | "value1": 200, 4 | "timestamp": 1382461861, 5 | "value": { 6 | "aaa": { 7 | "value1": "v1", 8 | "value2": "v2" 9 | }, 10 | "bbb": { 11 | "value1": "v1", 12 | "value2": "v2" 13 | }, 14 | "ccc": { 15 | "value1": "v1", 16 | "value2": "v2" 17 | } 18 | } 19 | } 20 | // File 2 21 | { 22 | "status": 200, 23 | "timestamp": 1382461861, 24 | "value": { 25 | "aaa": { 26 | "value3": "v3", 27 | "value4": 4 28 | }, 29 | "bbb": { 30 | "value3": "v3" 31 | }, 32 | "ddd": { 33 | "value3": "v3", 34 | "value4": 4 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/stackoverflow/19529688.unq: -------------------------------------------------------------------------------- 1 | /* 2 | source: 3 | https://stackoverflow.com/questions/19529688/how-to-merge-2-json-objects-from-2-files-using-jq 4 | */ 5 | 6 | { 7 | "value:value{}": { 8 | "$key": { 9 | "{}:":"." 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/stackoverflow/26701538.json: -------------------------------------------------------------------------------- 1 | // https://stackoverflow.com/questions/26701538/how-to-filter-an-array-of-objects-based-on-values-in-an-inner-array-with-jq 2 | 3 | [ 4 | { 5 | "Id": "cb94e7a42732b598ad18a8f27454a886c1aa8bbba6167646d8f064cd86191e2b", 6 | "Names": [ 7 | "condescending_jones", 8 | "loving_hoover" 9 | ] 10 | }, 11 | { 12 | "Id": "186db739b7509eb0114a09e14bcd16bf637019860d23c4fc20e98cbe068b55aa", 13 | "Names": [ 14 | "foo_data" 15 | ] 16 | }, 17 | { 18 | "Id": "a4b7e6f5752d8dcb906a5901f7ab82e403b9dff4eaaeebea767a04bac4aada19", 19 | "Names": [ 20 | "jovial_wozniak" 21 | ] 22 | }, 23 | { 24 | "Id": "76b71c496556912012c20dc3cbd37a54a1f05bffad3d5e92466900a003fbb623", 25 | "Names": [ 26 | "bar_data" 27 | ] 28 | } 29 | ] 30 | -------------------------------------------------------------------------------- /tests/stackoverflow/26701538.unq: -------------------------------------------------------------------------------- 1 | /* 2 | source: 3 | https://stackoverflow.com/questions/26701538/how-to-filter-an-array-of-objects-based-on-values-in-an-inner-array-with-jq 4 | 5 | Corresponding jq query: 6 | . - map(select(.Names[] | contains ("data"))) | .[] .Id 7 | 8 | */ 9 | { 10 | "#return:[]" : [{ 11 | "#notexists:Names[]": ". contains 'data'", 12 | "#return":"Id" 13 | }] 14 | } 15 | -------------------------------------------------------------------------------- /tests/stackoverflow/32381023.json: -------------------------------------------------------------------------------- 1 | { 2 | "StatusInfos": null, 3 | "ReadReplicaSourceDBInstanceIdentifier": null, 4 | "DBInstanceIdentifier": "test1" 5 | } 6 | { 7 | "StatusInfos": null, 8 | "ReadReplicaSourceDBInstanceIdentifier": null, 9 | "DBInstanceIdentifier": "test2" 10 | } 11 | { 12 | "StatusInfos": [ 13 | { 14 | "Status": "replicating", 15 | "StatusType": "read replication", 16 | "Normal": true 17 | } 18 | ], 19 | "ReadReplicaSourceDBInstanceIdentifier": "test1", 20 | "DBInstanceIdentifier": "read-rep-test1" 21 | } 22 | { 23 | "StatusInfos": [ 24 | { 25 | "Status": "replicating", 26 | "StatusType": "read replication", 27 | "Normal": true 28 | } 29 | ], 30 | "ReadReplicaSourceDBInstanceIdentifier": "test2", 31 | "DBInstanceIdentifier": "read-rep-test2" 32 | } 33 | -------------------------------------------------------------------------------- /tests/stackoverflow/32381023.unq: -------------------------------------------------------------------------------- 1 | /* 2 | Source: 3 | https://stackoverflow.com/questions/32381023/jq-select-or-if 4 | 5 | */ 6 | [ 7 | { 8 | "#returnif:StatusInfos[]?StatusType='read replication'": { 9 | "RepStatus":"Status", 10 | "RepStatusType":"StatusType", 11 | "ReadReplicaSourceDBInstanceIdentifier":"../ReadReplicaSourceDBInstanceIdentifier", 12 | "DBInstanceIdentifier":"../DBInstanceIdentifier" 13 | }, 14 | "#return":"." 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /tests/stackoverflow/32931471.json: -------------------------------------------------------------------------------- 1 | { 2 | "Tags": [ 3 | { "Key": "Team", "Value": "AA" }, 4 | { "Key": "Division", "Value": "BB" } 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /tests/stackoverflow/32931471.unq: -------------------------------------------------------------------------------- 1 | /* 2 | Source: 3 | https://stackoverflow.com/questions/32931471/jq-missing-json-object-detection 4 | 5 | */ 6 | { 7 | "#returnif:Tags[]?Key='Name'":"Value", 8 | "#return":"'N/A'" 9 | } 10 | -------------------------------------------------------------------------------- /tests/stackoverflow/32931471a.json: -------------------------------------------------------------------------------- 1 | { 2 | "Tags": [ 3 | { "Key": "Team", "Value": "AA" }, 4 | { "Key": "Division", "Value": "BB" }, 5 | { "Key": "Name", "Value": "CC" } 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /tests/stackoverflow/32931471a.unq: -------------------------------------------------------------------------------- 1 | /* 2 | Source: 3 | https://stackoverflow.com/questions/32931471/jq-missing-json-object-detection 4 | 5 | */ 6 | { 7 | "#returnif:Tags[]?Key='Name'":"Value", 8 | "#return":"'N/A'" 9 | } 10 | -------------------------------------------------------------------------------- /tests/stackoverflow/33895076.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "timestamp": 1448369447295, 4 | "group": "employees", 5 | "uid": "elgalu" 6 | }, 7 | { 8 | "timestamp": 1448369447296, 9 | "group": "employees", 10 | "uid": "mike" 11 | }, 12 | { 13 | "timestamp": 1448369786667, 14 | "group": "services", 15 | "uid": "pacts" 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /tests/stackoverflow/33895076.unq: -------------------------------------------------------------------------------- 1 | /* 2 | Source: 3 | https://stackoverflow.com/questions/33895076/exclude-column-from-jq-json-output 4 | 5 | */ 6 | { 7 | "#return:[]": [{ 8 | "{}:" : ".?$key!='timestamp'" 9 | }] 10 | } -------------------------------------------------------------------------------- /tests/stackoverflow/35876490.json: -------------------------------------------------------------------------------- 1 | { 2 | "blah0": "zeroblah", 3 | "Array": [ 4 | { 5 | "blah1": [ 6 | "key1:val1" 7 | ], 8 | "foobar0": "barfoo0", 9 | "foobar1": "barfoo1" 10 | }, 11 | { 12 | "blah2": [ 13 | "key2:val2" 14 | ], 15 | "foobar2": "barfoo2", 16 | "foobar3": "barfoo3" 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/stackoverflow/35876490.unq: -------------------------------------------------------------------------------- 1 | /* 2 | Source: 3 | https://stackoverflow.com/questions/35876490/how-to-remove-an-array-element-with-jq 4 | */ 5 | { 6 | "blah0:":".", 7 | "Array:Array[]?$index=0":["."] 8 | } 9 | -------------------------------------------------------------------------------- /tests/stackoverflow/38121740.json: -------------------------------------------------------------------------------- 1 | { 2 | "theList": [ 3 | { 4 | "id": 1, 5 | "name": "Horst" 6 | }, 7 | { 8 | "id": 2, 9 | "name": "Fritz" 10 | }, 11 | { 12 | "id": 3, 13 | "name": "Walter" 14 | }, 15 | { 16 | "id": 4, 17 | "name": "Gerhart" 18 | }, 19 | { 20 | "id": 5, 21 | "name": "Harmut" 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /tests/stackoverflow/38121740.unq: -------------------------------------------------------------------------------- 1 | /* 2 | Source: 3 | https://stackoverflow.com/questions/38121740/how-to-filter-array-of-objects-by-element-property-values-using-jq 4 | 5 | */ 6 | { 7 | "#return:theList[]": [ ".?id=2|id=4"] 8 | } -------------------------------------------------------------------------------- /tests/stackoverflow/49284942.json: -------------------------------------------------------------------------------- 1 | { 2 | "Object1": { 3 | "id": 1, 4 | "name": "object1name" 5 | }, 6 | "Object2": { 7 | "id": 24, 8 | "name": "object2name" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/stackoverflow/49284942.unq: -------------------------------------------------------------------------------- 1 | /* 2 | Source: 3 | https://stackoverflow.com/questions/49284942/jq-build-lookup-table 4 | */ 5 | 6 | { 7 | "#return:{}": { 8 | "$(name)":"id" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/stackoverflow/53768947.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "account": "1", 4 | "cost": [ 5 | { 6 | "usage":"low", 7 | "totalcost": "2.01" 8 | } 9 | ] 10 | }, 11 | { 12 | "account": "2", 13 | "cost": [ 14 | { 15 | "usage":"low", 16 | "totalcost": "2.25" 17 | } 18 | ] 19 | }, 20 | { 21 | "account": "1", 22 | "cost": [ 23 | { 24 | "usage":"low", 25 | "totalcost": "15" 26 | } 27 | ] 28 | }, 29 | { 30 | "anotheraccount": "a", 31 | "cost": [ 32 | { 33 | "usage":"low", 34 | "totalcost": "2" 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /tests/stackoverflow/53768947.unq: -------------------------------------------------------------------------------- 1 | /* 2 | Source: 3 | https://stackoverflow.com/questions/53768947/jq-count-nest-object-values-based-on-group-by 4 | 5 | Proposed jq code: 6 | def sigma( f ): reduce .[] as $o (null; . + ($o | f )) ; 7 | 8 | def group( keyname ): 9 | map(select(has(keyname))) 10 | | group_by( .[keyname] ) 11 | | map({(keyname) : .[0][keyname], 12 | cost: sigma(.cost[].totalcost | tonumber) }) 13 | ; 14 | group("account"), 15 | group("anotheraccount") 16 | */ 17 | 18 | { 19 | "#return:[]:cost[]": { 20 | "$(../account)":"$sum($float(totalcost))" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/stackoverflow/54199974.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | {"date": "2018-08-22","value": 1}, 4 | {"date": "2018-08-30","value": 2}, 5 | {"date": "2018-09-01","value": 3}, 6 | {"date": "2018-09-22","value": 3}, 7 | {"date": "2018-09-28","value": 4}, 8 | {"date": "2018-10-18","value": 5}, 9 | {"date": "2018-10-23","value": 6} 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /tests/stackoverflow/54199974.unq: -------------------------------------------------------------------------------- 1 | /* 2 | Based on: 3 | https://stackoverflow.com/questions/54199974/json-parsing-group-by-date-range-with-jq 4 | 5 | Proposed jq solution: 6 | # $day should be the day (an integer) that defines the cutoff point; 7 | # input should be a Y-M-D string 8 | def bucket($day): 9 | def prev: if .m > 1 then .m -= 1 else .m = 12 | .y -= 1 end; 10 | def fmt: if .m <= 9 then "\(.y)-0\(.m)" else "\(.y)-\(.m)" end; 11 | capture("(?[0-9]+)-(?[0-9]+)-(?[0-9]+)") 12 | | map_values(tonumber) 13 | | if .d >= $day then . else prev end 14 | | fmt ; 15 | 16 | .data 17 | | (.[0].date | capture("(?[0-9]+)$") | .d | tonumber) as $day 18 | | reduce .[] as $pair ({}; 19 | .[$pair.date | bucket($day)] += ($pair.value) ) 20 | 21 | */ 22 | { 23 | "#var dates": [ 24 | "'2018-08-22'", 25 | "'2018-09-22'", 26 | "'2018-10-22'", 27 | "'2018-11-22'" 28 | ], 29 | "#return:data[]": { 30 | "#var i->%dates:[]?$to_time(<results/$basefile 2> results/${basefile}.errors 9 | if [ -s expected/$basefile ]; then 10 | $JSONCOMPARE expected/$basefile results/$basefile 11 | elif [ -s results/$basefile ]; then 12 | echo Query $f, expected not found. 13 | fi 14 | diff -Naur expected/$basefile.errors results/$basefile.errors || true 15 | } 16 | 17 | 18 | rm -rf results 19 | mkdir results 20 | for f in ${EMPLOYEES}/queries/*.unq; do 21 | test_query $f employee_ $EMPLOYEES/employee*.json 22 | done 23 | 24 | for f in parsing/*.unq; do 25 | test_query $f parsing_ $EMPLOYEES/employee1.json 26 | done 27 | 28 | for f in extra/*.unq; do 29 | test_query $f extra_ ${f%.*}.json 30 | done 31 | 32 | for f in stackoverflow/*.unq; do 33 | test_query $f stackoverflow_ ${f%.*}.json 34 | done 35 | -------------------------------------------------------------------------------- /tutorial-samples/employees/employee1.json: -------------------------------------------------------------------------------- 1 | { 2 | "ID":"1001", 3 | "FirstName":"John", 4 | "LastName":"Smith", 5 | "Title":"CTO", 6 | "Salary":320000, 7 | "Address": { 8 | "Street":"123 Oak Street", 9 | "City":"Austin", 10 | "State":"TX", 11 | "Zip":78705 12 | }, 13 | "Dependants": [ 14 | {"FirstName":"Jane", 15 | "LastName":"Smith", 16 | "Relation":"Spouse" 17 | }, 18 | {"FirstName":"Jake", 19 | "LastName":"Smith", 20 | "Relation":"Child" 21 | }, 22 | {"FirstName":"Jenna", 23 | "LastName":"Smith", 24 | "Relation":"Child" 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /tutorial-samples/employees/employee2.json: -------------------------------------------------------------------------------- 1 | { 2 | "ID":"1002", 3 | "FirstName":"Dganit", 4 | "LastName":"Tirosh", 5 | "Title":"CEO", 6 | "Salary":500000, 7 | "Address": { 8 | "Street":"500 Temple Street", 9 | "City":"Oakland", 10 | "State":"CA", 11 | "Zip":94001 12 | }, 13 | "Dependants": [ 14 | {"FirstName":"Yaniv", 15 | "LastName":"Tirosh-Ron", 16 | "Relation":"Spouse" 17 | }, 18 | {"FirstName":"Galit", 19 | "LastName":"Tirosh-Ron", 20 | "Relation":"Child" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /tutorial-samples/employees/employee3.json: -------------------------------------------------------------------------------- 1 | { 2 | "ID":"1003", 3 | "FirstName":"Arthur", 4 | "LastName":"McLaud", 5 | "Title":"Developer", 6 | "Salary":120000, 7 | "Address": { 8 | "Street":"701H Highlander Avenue", 9 | "City":"Oakland", 10 | "State":"CA", 11 | "Zip":94001 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tutorial-samples/employees/employee4.json: -------------------------------------------------------------------------------- 1 | { 2 | "ID":"1004", 3 | "FirstName":"Elena", 4 | "LastName":"Brioche", 5 | "Title":"Senior Developer", 6 | "Salary":150000, 7 | "Address": { 8 | "Street":"2 Manticore Ct", 9 | "City":"Atlantic City", 10 | "State":"NJ", 11 | "Zip":12345 12 | }, 13 | "Dependants": [ 14 | {"FirstName":"Jacques", 15 | "LastName":"Macaron", 16 | "Relation":"Spouse" 17 | }, 18 | {"FirstName":"Suzette", 19 | "LastName":"Macaron", 20 | "Relation":"Child" 21 | }, 22 | {"FirstName":"Galette", 23 | "LastName":"Macaron", 24 | "Relation":"Child" 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /tutorial-samples/employees/employee5.json: -------------------------------------------------------------------------------- 1 | { 2 | "ID":"1005", 3 | "FirstName":"Rene", 4 | "LastName":"Descartes", 5 | "Title":"Janitor", 6 | "Salary":700000, 7 | "Address": { 8 | "Street":"17 Whoknows street", 9 | "City":"Nowhere", 10 | "State":"NY", 11 | "Zip":10001 12 | }, 13 | "Dependants": [ 14 | {"FirstName":"Shrodinger", 15 | "Relation":"Cat" 16 | }, 17 | {"FirstName":"Cogito", 18 | "LastName":"Ergo-Sum", 19 | "Relation":"Tortoise" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query1.unq: -------------------------------------------------------------------------------- 1 | "FirstName" 2 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query10.unq: -------------------------------------------------------------------------------- 1 | [{ 2 | "#if":"$size(Dependants)>=3", 3 | "FirstName":"FirstName", 4 | "LastName":"LastName" 5 | }] 6 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query10a.unq: -------------------------------------------------------------------------------- 1 | [{ 2 | "num:Dependants[]?Relation='Child'":"$count>0", 3 | "FirstName":"FirstName", 4 | "LastName":"LastName" 5 | }] 6 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query11.unq: -------------------------------------------------------------------------------- 1 | [{ 2 | "FullAddress":"Address.Street+' '+Address.City+' '+Address.State+', '+Address.Zip" 3 | }] -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query11a.unq: -------------------------------------------------------------------------------- 1 | [{ 2 | "FullAddress:Address":"Street+' '+City+' '+State+', '+Zip" 3 | }] -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query12.unq: -------------------------------------------------------------------------------- 1 | { 2 | "Childen:Dependants[]?Relation='Child'" : 3 | [ 4 | "FirstName+' '+LastName" 5 | ] 6 | } -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query12a.unq: -------------------------------------------------------------------------------- 1 | [{ 2 | "Children:Dependants[]?Relation='Child'" : 3 | [ 4 | "FirstName+' '+LastName" 5 | ] 6 | }] -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query12b.unq: -------------------------------------------------------------------------------- 1 | [{ 2 | "Dependants:Dependants[]?$index<2": 3 | [ 4 | "FirstName+' '+LastName" 5 | ] 6 | }] -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query13.unq: -------------------------------------------------------------------------------- 1 | { 2 | "names:.||Dependants[]": 3 | [ 4 | "FirstName+' '+LastName" 5 | ] 6 | } -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query14.unq: -------------------------------------------------------------------------------- 1 | [{ 2 | "FirstName:" : ".", 3 | "LastName:" : ".", 4 | "NumOfChildren:Dependants[]":"$count?Relation='Child'" 5 | }] 6 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query14a.unq: -------------------------------------------------------------------------------- 1 | [{ 2 | "#if:Dependants[]?Relation='Child'": "$count>1", 3 | "FirstName:" : ".", 4 | "LastName:" : "." 5 | }] 6 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query15.unq: -------------------------------------------------------------------------------- 1 | { 2 | "$(LastName)":"." 3 | } -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query15a.unq: -------------------------------------------------------------------------------- 1 | { 2 | "$(LastName+' '+FirstName)":"." 3 | } -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query15b.unq: -------------------------------------------------------------------------------- 1 | { 2 | "$(LastName)":["."] 3 | } -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query16.unq: -------------------------------------------------------------------------------- 1 | { 2 | "dependants:Dependants[]": { 3 | "$(Relation)":["."] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query16a.unq: -------------------------------------------------------------------------------- 1 | { 2 | "dependants:Dependants[]": { 3 | "$(Relation)":"$count" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query17.unq: -------------------------------------------------------------------------------- 1 | { 2 | "$(ID):{}": { 3 | "Filename":"$filename", 4 | "$key":"." 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query17a.unq: -------------------------------------------------------------------------------- 1 | { 2 | "$(ID):{}?$key!='ID'": { 3 | "$key":"." 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query17b.unq: -------------------------------------------------------------------------------- 1 | [{ 2 | "employee:{}": { 3 | "Filename":"$filename", 4 | "$key":"." 5 | } 6 | }] 7 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query17c.unq: -------------------------------------------------------------------------------- 1 | [{ 2 | "Filename":"$filename", 3 | "{}:": "." 4 | }] 5 | 6 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query17d.unq: -------------------------------------------------------------------------------- 1 | [{ 2 | "{}:": ".?$key!='Dependants'" 3 | }] 4 | 5 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query18.unq: -------------------------------------------------------------------------------- 1 | { 2 | "#var employee":"FirstName+' '+LastName", 3 | "all_dependants:Dependants[]": [{ 4 | "{}:":".", 5 | "Employee":"$var(employee)" 6 | }] 7 | } 8 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query19.unq: -------------------------------------------------------------------------------- 1 | { 2 | "#var states": { 3 | "CA": "'California'", 4 | "NJ": "'New Jersey'", 5 | "NY": "'New York'", 6 | "TX": "'Texas'" 7 | }, 8 | "employees": [{ 9 | "FirstName:":".", 10 | "LastName:":".", 11 | "State":"$var(states).$(Address.State)" 12 | }] 13 | } -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query2.unq: -------------------------------------------------------------------------------- 1 | "Address.City" 2 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query20.unq: -------------------------------------------------------------------------------- 1 | { 2 | "#return:**?FirstName!":["FirstName+' '+LastName"] 3 | } -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query20a.unq: -------------------------------------------------------------------------------- 1 | { 2 | "#return:**":["$key!=''@unique_ascending"] 3 | } -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query21.unq: -------------------------------------------------------------------------------- 1 | ["Dependants.FirstName"] 2 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query3.unq: -------------------------------------------------------------------------------- 1 | "Dependants[0].FirstName" 2 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query4.unq: -------------------------------------------------------------------------------- 1 | { 2 | "fullname": "FirstName+' '+LastName", 3 | "title":"Title", 4 | "city": "Address.City" 5 | } -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query5.unq: -------------------------------------------------------------------------------- 1 | { 2 | "name": "FirstName+' '+LastName", 3 | "employment": { 4 | "title":"Title", 5 | "salary":"Salary" 6 | } 7 | } -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query6.unq: -------------------------------------------------------------------------------- 1 | ["FirstName"] 2 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query7.unq: -------------------------------------------------------------------------------- 1 | ["FirstName@ascending"] 2 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query8.unq: -------------------------------------------------------------------------------- 1 | ["LastName?Salary>200000"] 2 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/query9.unq: -------------------------------------------------------------------------------- 1 | [{ 2 | "FirstName":"FirstName", 3 | "LastName":"LastName", 4 | "Title":"Title contains 'Developer'" 5 | }] 6 | -------------------------------------------------------------------------------- /tutorial-samples/employees/queries/tolowerkeys.unq: -------------------------------------------------------------------------------- 1 | { 2 | "#func lower_keys" : { 3 | "#returnif:[]" : ["$lower_keys"], 4 | "#returnif:{}" : {"$lower($key)":"$lower_keys"}, 5 | "#return" : "." 6 | }, 7 | 8 | "#return" : ["$lower_keys"] 9 | } 10 | -------------------------------------------------------------------------------- /unq/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.6.2) 2 | project(unq) 3 | 4 | set(CMAKE_CXX_STANDARD 17) 5 | 6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -pthread") 7 | 8 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin/Release) 9 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY lib) 10 | 11 | include_directories(include 12 | ../libs/rapidjson 13 | ../libs 14 | ) 15 | 16 | set(SOURCES 17 | src/TemplateQuery.cpp 18 | src/TemplateParser.cpp 19 | src/params.cpp 20 | src/utils.cpp 21 | src/json-utils.cpp 22 | ) 23 | 24 | add_executable(unq src/unqlite_main.cpp ${SOURCES}) 25 | 26 | # target_link_libraries(XCiteDB libre2.a) 27 | -------------------------------------------------------------------------------- /unq/include/TemplateParser.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 by Sela Mador-Haim 2 | 3 | #ifndef TEMPLATEPARSER_H 4 | #define TEMPLATEPARSER_H 5 | 6 | #include "TemplateQuery.h" 7 | 8 | namespace xcite { 9 | 10 | class ParsingError 11 | { 12 | public: 13 | ParsingError(string msg_): msg(msg_) {} 14 | 15 | virtual string message() { 16 | return "Error parsing Q! Query: "+msg; 17 | } 18 | 19 | string msg; 20 | }; 21 | 22 | typedef std::pair ValueAndCond; 23 | 24 | typedef std::pair KeyAndContext; 25 | 26 | enum class ContextModMode { 27 | None, 28 | Start, 29 | OrStart, 30 | Or 31 | }; 32 | 33 | class TSymTable 34 | { 35 | public: 36 | std::map funcs; 37 | }; 38 | 39 | typedef std::shared_ptr TSymTableP; 40 | 41 | class TParser 42 | { 43 | public: 44 | 45 | TParser(const std::string& str, const TSymTableP& st); 46 | 47 | bool eos() const; 48 | 49 | std::string nextToken(bool consume = true); 50 | void consume(); 51 | void expect(const std::string& expected); 52 | bool lookAhead(const std::string& s); 53 | bool ifNext(const std::string& s); 54 | void throwError(const std::string& msg); 55 | 56 | TQKeyP key(); 57 | TemplateQueryP context_mod(bool frame_flag = true, ContextModMode parse_mode = ContextModMode::None); 58 | ValueAndCond value(); 59 | TQConditionP baseCondition(const TExpressionP& arg1 = {}); 60 | TQConditionP condition(int prec = 0, const TExpressionP& exp = {}); 61 | TExpressionP expression(int prec = 0); 62 | TExpressionP baseExpression(); 63 | bool boolean(); 64 | string pathId(); 65 | string pathWithBrackets(const std::string& token = {}); 66 | void pushPosition(); 67 | void popPosition(); 68 | void restorePosition(); 69 | 70 | private: 71 | std::string _str; 72 | size_t _pos; 73 | size_t _len; 74 | std::vector _positions; 75 | TSymTableP sym_table; 76 | 77 | }; 78 | 79 | TemplateQueryP JSONToTQ(JSONValue& v); 80 | 81 | } // namespace xcite 82 | 83 | #endif //TEMPLATEPARSER_H 84 | -------------------------------------------------------------------------------- /unq/include/json-utils.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_UTILS_H 2 | #define JSON_UTILS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "rapidjson/document.h" 9 | 10 | typedef rapidjson::Value JSONValue; 11 | typedef std::shared_ptr JSONValueP; 12 | 13 | namespace xcite { 14 | 15 | std::string escape_field_name(const std::string& s); 16 | std::string unescape_field_name(const std::string& s); 17 | 18 | class ObjectFieldSet 19 | { 20 | public: 21 | ObjectFieldSet() {} 22 | ObjectFieldSet(const std::string& str); 23 | void add(const std::string& s); 24 | void add(const ObjectFieldSet& o); 25 | bool remove(const std::string& s); 26 | std::string toString() const; 27 | bool operator==(const ObjectFieldSet& o) const { 28 | return fields==o.fields; 29 | } 30 | auto begin() { 31 | return fields.begin(); 32 | } 33 | auto end() { 34 | return fields.end(); 35 | } 36 | private: 37 | std::vector fields; 38 | }; 39 | 40 | std::string valToString(const JSONValue* val); 41 | 42 | std::string valToString(const JSONValueP& val); 43 | 44 | double valToDouble(const JSONValueP& val); 45 | 46 | int64_t valToInt(const JSONValueP& val); 47 | 48 | bool valToBool(const JSONValueP& val); 49 | 50 | std::string joinAllVals(const JSONValue& val, const std::string& delim); 51 | 52 | JSONValueP readCSV(std::istream& is, const std::string& delim, bool with_header); 53 | 54 | } // namespace xcite 55 | 56 | #endif // JSON_UTILS_H 57 | -------------------------------------------------------------------------------- /unq/include/params.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 by Sela Mador-Haim 2 | 3 | #ifndef PARAMS_H 4 | #define PARAMS_H 5 | 6 | #include 7 | #include 8 | 9 | namespace xcite { 10 | 11 | class Params { 12 | public: 13 | Params(int argc, char* argv[]); 14 | std::string nextArg(); 15 | bool isOpt(); 16 | bool isEnd() { 17 | return i>=_args.size(); 18 | } 19 | 20 | std::vector _args; 21 | int i = 1; 22 | }; 23 | 24 | } // namespace xcite 25 | 26 | #endif //PARAMS_H 27 | -------------------------------------------------------------------------------- /unq/include/utils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 by Sela Mador-Haim 2 | 3 | #ifndef UTILS_H_INCLUDED 4 | #define UTILS_H_INCLUDED 5 | #include 6 | #include 7 | 8 | namespace xcite { 9 | 10 | int roman2int(const std::string& roman); 11 | std::string int2roman(int n, bool uppercase); 12 | int letter2int(const std::string& letter); 13 | std::string int2letter(int n, bool uppercase); 14 | 15 | enum class LetterCase { 16 | Upper, 17 | Lower, 18 | Mixed, 19 | None 20 | }; 21 | 22 | LetterCase getCase(const std::string& s); 23 | 24 | int isOpenQuotes(const std::string& s, size_t pos); 25 | int isCloseQuotes(const std::string& s, size_t pos); 26 | std::string stripQuotes(std::string s); 27 | 28 | 29 | std::string normalize_string(const std::string& s); 30 | 31 | std::string get_identifier_part(const std::string& name, const std::string& des); 32 | 33 | // Note: returns true in case its a number, a number and letters combinations (e.g. 10A), a roman numeral, or a letter numeral 34 | bool isNumOrNumeral(const std::string& s); 35 | 36 | bool is_number(const std::string& s); 37 | 38 | size_t find_gen_amendment(const std::string& s); 39 | 40 | size_t find_is_amended(const std::string& s, bool return_start); 41 | 42 | size_t find_action(const std::string& s); 43 | 44 | size_t find_blanket_context(const std::string& s); 45 | 46 | std::string get_blanket_context_level(const std::string& s); 47 | 48 | std::string get_blanket_context_predicate(const std::string& s); 49 | 50 | std::string single_to_double_quotes(const std::string& s); 51 | 52 | std::string normalize_white_spaces(const std::string& s, char sep = ' '); 53 | 54 | std::string clean_designation(const std::string& s); 55 | 56 | std::string strip_nonalnum(const std::string& s); 57 | 58 | std::string to_lowercase(const std::string& s); 59 | 60 | std::string to_uppercase(const std::string& s); 61 | 62 | std::string getExtension(const std::string& filename); 63 | 64 | size_t find_nth_occurance(const std::string& s, char c, int n); 65 | 66 | bool is_legal_id(const std::string& s); 67 | 68 | std::string num2string(long long i, size_t n); 69 | 70 | std::string base64_encode(long long i, size_t n); 71 | 72 | long long base64_decode(const std::string& s); 73 | 74 | time_t stringToTime(const std::string& s, const std::string& f = {}); 75 | 76 | std::string timeToString(time_t t, const std::string& f); 77 | 78 | std::vector split_string(const std::string& s, const std::string& delim); 79 | 80 | } // namespace xcite 81 | 82 | #endif // UTILS_H_INCLUDED 83 | -------------------------------------------------------------------------------- /unq/include/xcitedb-stubs.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 by Sela Mador-Haim 2 | 3 | #include 4 | #include "rapidjson/document.h" 5 | #include "json-utils.h" 6 | #include 7 | #include 8 | #include 9 | 10 | typedef std::string string; 11 | typedef rapidjson::Value JSONValue; 12 | 13 | class WhatEver 14 | { 15 | }; 16 | 17 | typedef int MDB_txn; 18 | 19 | namespace pugi { 20 | const int node_pcdata = 0; 21 | class xml_attribute 22 | { 23 | public: 24 | bool empty() {return false;} 25 | char * value() {return 0;} 26 | }; 27 | 28 | class xml_node 29 | { 30 | public: 31 | string name() const {return {};} 32 | xml_node first_child() {return xml_node();} 33 | xml_node child(const char*) const {return {};} 34 | std::set children() const {return {};} 35 | bool empty() const {return false;} 36 | const char* value() const {return 0;} 37 | int type() const {return 0;} 38 | 39 | void print(std::ostream& os) {} 40 | xml_attribute attribute(const char *) {return {};} 41 | }; 42 | 43 | class xml_document: public xml_node 44 | { 45 | }; 46 | 47 | class xpath_node 48 | { 49 | public: 50 | xml_node node() {return {};} 51 | xml_attribute attribute() {return {};} 52 | }; 53 | 54 | typedef std::vector xpath_node_set; 55 | 56 | class xpath_query 57 | { 58 | public: 59 | xpath_query(const char*) {} 60 | xpath_node_set evaluate_node_set(const xml_node& n) {return {};} 61 | }; 62 | 63 | } 64 | 65 | class DocStructure 66 | { 67 | public: 68 | bool isInFilter(const string& s1, const string& s2) {return true;} 69 | }; 70 | 71 | class XMLDBSettings 72 | { 73 | public: 74 | string date; 75 | string branch; 76 | }; 77 | 78 | class SimpleQuery 79 | { 80 | public: 81 | SimpleQuery(MDB_txn* x, MDB_txn* y) {} 82 | void beginQuery() {} 83 | bool readyForNext() {return true;} 84 | string getNextIdentifier() {return {};} 85 | 86 | string match_start; 87 | }; 88 | 89 | 90 | class XMLReader 91 | { 92 | public: 93 | XMLReader(XMLDBSettings& settings, MDB_txn* txn) {} 94 | string getNodeFromIdentifier(const string& identifier) {return {};} 95 | MDB_txn* get_txn() {return 0;} 96 | MDB_txn* get_base_txn() {return 0;} 97 | bool getNodeXML(const string& s, pugi::xml_document& doc) {return true;} 98 | void addNamespace(pugi::xml_node& n, const string& s) {} 99 | void traverse(pugi::xml_node& n) {} 100 | string getDate() {return {};} 101 | string getBranch() {return {};} 102 | void setDate(const string& data) {} 103 | void setBranch(const string& data) {} 104 | std::pair read_node_revision(const std::string& node_str) {return {};} 105 | DocStructure doc_conf() {return DocStructure();} 106 | bool no_children; 107 | }; 108 | 109 | class JSONMetaReader 110 | { 111 | public: 112 | JSONMetaReader(XMLDBSettings& settings_, MDB_txn* txn_, const std::string& node) {} 113 | void changeNode(const std::string& node) {} 114 | std::string readMetaNode(const std::string& path) {return {};} 115 | std::string readMetaNodeKey(const std::string& path) {return {};} 116 | JSONValue traverse(const string& path, rapidjson::Document& json) {return {};} 117 | string getDate() {return {};} 118 | string getBranch() {return {};} 119 | void setDate(const string& data) {} 120 | void setBranch(const string& data) {} 121 | }; 122 | 123 | inline std::string getMainIdPart(const std::string& id, int parts = 0) {return {};} 124 | 125 | inline string date2key(const string& date) {return {};} 126 | inline string node_date(const string& node) {return {};} -------------------------------------------------------------------------------- /unq/src/json-utils.cpp: -------------------------------------------------------------------------------- 1 | #include "json-utils.h" 2 | #include "utils.h" 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | using namespace rapidjson; 9 | 10 | namespace xcite { 11 | 12 | string escape_field_name(const string& s) 13 | { 14 | string res; 15 | res.reserve(s.size()); 16 | for (char c: s) { 17 | switch(c) { 18 | case '@': 19 | res+="@a"; break; 20 | case '.': 21 | res+="@d"; break; 22 | case ',': 23 | res+="@c"; break; 24 | case '{': 25 | res+="@l"; break; 26 | case '}': 27 | res+="@r"; break; 28 | case '[': 29 | res+="@L"; break; 30 | case ']': 31 | res+="@R"; break; 32 | case '/': 33 | res+="@s"; break; 34 | default: 35 | res.push_back(c); 36 | } 37 | } 38 | return res; 39 | } 40 | 41 | string unescape_field_name(const string& s) 42 | { 43 | string res; 44 | size_t size = s.size(); 45 | res.reserve(size); 46 | for (int i=0; iIsString()) { 125 | return val->GetString(); 126 | } else if (val->IsDouble()) { 127 | return to_string(val->GetDouble()); 128 | } else if (val->IsInt64()) { 129 | return to_string(val->GetInt64()); 130 | } else if (val->IsBool()) { 131 | return val->GetBool()?"true":"false"; 132 | } 133 | 134 | return {}; 135 | } 136 | 137 | std::string valToString(const JSONValueP& val) 138 | { 139 | return valToString(val.get()); 140 | } 141 | 142 | 143 | double valToDouble(const JSONValueP& val) 144 | { 145 | if (val->IsDouble()) { 146 | return val->GetDouble(); 147 | } else if (val->IsInt64()) { 148 | return val->GetInt64(); 149 | } 150 | return {}; 151 | } 152 | 153 | int64_t valToInt(const JSONValueP& val) 154 | { 155 | if (val->IsInt64()) { 156 | return val->GetInt64(); 157 | } else if (val->IsDouble()) { 158 | return val->GetDouble(); 159 | } 160 | return {}; 161 | } 162 | 163 | bool valToBool(const JSONValueP& val) 164 | { 165 | if (val->IsBool()) { 166 | return val->GetBool(); 167 | } else if (val->IsInt64()) { 168 | return val->GetInt64()!=0; 169 | } 170 | return false; 171 | } 172 | 173 | std::string joinAllVals(const JSONValue& val, const string& delim) 174 | { 175 | string res; 176 | if (val.IsArray()) { 177 | for (auto& v: val.GetArray()) { 178 | string new_val = joinAllVals(v, delim); 179 | if (!res.empty() && !new_val.empty()) { 180 | res+=delim; 181 | } 182 | res+=new_val; 183 | } 184 | } else if (val.IsObject()) { 185 | for (auto& i: val.GetObject()) { 186 | string new_val = joinAllVals(i.value, delim); 187 | if (!res.empty() && !new_val.empty()) { 188 | res+=delim; 189 | } 190 | res+=new_val; 191 | } 192 | } else { 193 | res = valToString(&val); 194 | } 195 | return res; 196 | } 197 | 198 | 199 | JSONValueP readCSV(istream& is, const std::string& delim, bool with_header) 200 | { 201 | vector columns; 202 | if (with_header) { 203 | string header; 204 | getline(is, header); 205 | if (header.back()=='\r') { 206 | header.pop_back(); 207 | } 208 | columns = split_string(header,delim); 209 | } 210 | JSONValueP json(new Document); 211 | Document& json_doc = *static_cast(json.get()); 212 | auto& alloc = json_doc.GetAllocator(); 213 | JSONValueP vec(new JSONValue(rapidjson::kArrayType)); 214 | while (!is.eof()) { 215 | string line; 216 | getline(is, line); 217 | if (!line.empty() && line.back()=='\r') { 218 | line.pop_back(); 219 | } 220 | if (line.empty()) { 221 | continue; 222 | } 223 | vector values = split_string(line, delim); 224 | JSONValue obj(rapidjson::kObjectType); 225 | for (int i=0; iPushBack(obj, alloc); 251 | } 252 | *json = *vec; 253 | return json; 254 | 255 | } 256 | 257 | } // namespace xcite 258 | -------------------------------------------------------------------------------- /unq/src/params.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 by Sela Mador-Haim 2 | 3 | #include "params.h" 4 | 5 | using namespace std; 6 | 7 | namespace xcite { 8 | 9 | Params::Params(int argc, char* argv[]) 10 | { 11 | for (int i =0; i