DataJSON.h
Go to the documentation of this file.
1 /*
2 MIT LICENSE
3 
4 Copyright (c) 2014-2021 Inertial Sense, Inc. - http://inertialsense.com
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
7 
8 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 */
12 
13 #ifndef DATA_JSON_H
14 #define DATA_JSON_H
15 
16 #include <string>
17 #include <map>
18 #include <regex>
19 
20 #include "com_manager.h"
21 #include "ISLogFileBase.h"
22 
23 using namespace std;
24 
25 static inline bool IS_JSON_ESCAPE_CHAR(char c)
26 {
27  switch (c)
28  {
29  case '"':
30  case '\\':
31  case '/':
32  case '\b':
33  case '\f':
34  case '\n':
35  case '\r':
36  case '\t':
37  return true;
38  }
39  return false;
40 }
41 
42 class cDataJSON
43 {
44 public:
45  /*
46  * Write data to json file
47  * pFile the file to write to
48  * dataHdr data header
49  * dataBuf data buffer
50  * prefix prefix if data is written
51  */
52  int WriteDataToFile(cISLogFileBase* pFile, const p_data_hdr_t& dataHdr, const uint8_t* dataBuf, const char* prefix);
53 
62  bool StringJSONToData(string& s, p_data_hdr_t& hdr, uint8_t* buf, uint32_t bufSize);
63 
70  bool DataToStringJSON(const p_data_hdr_t& hdr, const uint8_t* buf, string& json);
71 };
72 
73 #endif // DATA_JSON_H
static bool IS_JSON_ESCAPE_CHAR(char c)
Definition: DataJSON.h:25
XmlRpcServer s


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:57