KPN IoT / senml

Fork of kpn_senml by KPN IoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers senml_json_parser.h Source File

senml_json_parser.h

00001 /*  _  __  ____    _   _ 
00002  * | |/ / |  _ \  | \ | |
00003  * | ' /  | |_) | |  \| |
00004  * | . \  |  __/  | |\  |
00005  * |_|\_\ |_|     |_| \_|
00006  * 
00007  * (c) 2018 KPN
00008  * License: MIT License.
00009  * Author: Jan Bogaerts
00010  * 
00011  * parse json header
00012  */
00013 
00014 #ifndef SENMLSenMLJsonListener
00015 #define SENMLSenMLJsonListener
00016 
00017 #include "senml_JsonListener.h"
00018 #include <senml_base_parser.h>
00019 
00020 /**
00021  * Internal helper class for parsing json data.
00022  */
00023 class SenMLJsonListener: public JsonListener, SenMLBaseParser {
00024 
00025   public:
00026     SenMLJsonListener(SenMLPack* root): JsonListener(), SenMLBaseParser(root) {};
00027 
00028 
00029     virtual void key(String key);
00030     virtual void value(String value);
00031     //virtual void endObject(){};
00032 
00033     //the following need to be implemented cause they are abstract in the base class.
00034     //virtual void startDocument(){};
00035     //virtual void endArray(){};
00036     //virtual void endDocument(){};
00037     //virtual void startArray(){};
00038     //virtual void startObject(){};
00039 
00040 
00041 
00042   private:
00043     int expected;               //name of key who's value is expected next
00044     double baseValue;           //if the current pack defined a base value, add it to all values that we find
00045 
00046     void setValue(const void* value, int length, SenMLDataType dataType);
00047 };
00048 
00049 #endif // SENMLSenMLJsonListener
00050 
00051 
00052 
00053 
00054 
00055 
00056