X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fjson%2Fjson_handler.hpp;fp=src%2Fjson%2Fjson_handler.hpp;h=0000000000000000000000000000000000000000;hb=4e545a8b013e60f2ff59254cb3fe435012d8fe5a;hp=95765ef820b9017f668490e76bb650c2a1fafce5;hpb=82ba4b9999ca8e09461315a919b36a66641a6c7d;p=ric-app%2Fadmin.git diff --git a/src/json/json_handler.hpp b/src/json/json_handler.hpp deleted file mode 100644 index 95765ef..0000000 --- a/src/json/json_handler.hpp +++ /dev/null @@ -1,150 +0,0 @@ - -/* -================================================================================== - - Copyright (c) 2018-2019 AT&T Intellectual Property. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -================================================================================== -*/ -/* - Author : Ashwin Sridharan - - -*/ - -#pragma once -#ifndef JSON_HANDLER -#define JSON_HANDLER - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define MAX_QUEUE_SIZE 100 - -using namespace rapidjson; - - -struct DataContainer { - enum Types {boolean, integer, uinteger, big_integer, ubig_integer, real, str} tag ; - struct { - union { - bool b; - int i; - unsigned int ui; - long int l; - unsigned long int ul; - double f; - } ; - std::string s; - } value; -}; - -class TrieNode; - -class TrieNode{ -public: - - TrieNode (int); - TrieNode( std::string ); - - void set_type(DataContainer::Types); - int get_type(void) const {return _val.tag;} ; - - void set_value(bool val); - void set_value(int val); - void set_value(unsigned int val); - - void set_value(long int ); - void set_value(unsigned long int ); - void set_value(double val); - void set_value(const char *); - void set_value(std::string val); - void set_value(const char * , size_t ); - - void print_id(void); - void print_value(void); - void add_child(TrieNode *); - - DataContainer const * get_value(void) const { return & _val; }; - DataContainer const * get_id(void) const { return & _id;}; - - std::vector & get_children(void){ return _children;} ; - std::string & name(void) {return _name; }; - bool is_child(void){ return _children.size() ? false : true; }; - -private: - std::vector _children; - int val_type; - std::string _name; - DataContainer _id; - DataContainer _val; -}; - -class jsonHandler { - -public: - jsonHandler(void); - - - void load_schema(std::string); - void load_schema(std::string, TrieNode *root); - void load_schema(std::string , std::vector & ); - - void load_buffer(std::string); - void load_buffer(std::string, TrieNode * ); - std::string get_buffer(void); - - int get_values(const char *, int , std::string & , TrieNode *, std::vector & ); - int get_values( std::string & , TrieNode *, std::vector & ); - - int set_values (const char *, int, std::string & , std::vector); - int set_values (std::string & , std::vector); - - bool is_valid(const char *, int, std::string &); - -private: - - void load_file(std::string, std::string &); - - bool traverse_doc(Value &, TrieNode *, bool, std::string &, std::vector & ); - - bool find_member(const std::string, std::string &, std::vector &, Value & ); - - bool find_member(const std::string, std::string &, TrieNode *, Value &); - bool find_member(Value &, std::string &, TrieNode *, Value &); - - bool add_array_objects(std::queue &, Value &); - - bool _is_root, _is_schema, _is_buffer; - - std::unique_ptr _ref_schema_doc; - std::map _key_value_pairs; - std::string _contents; - std::string _buffer; - -}; - - -#endif