Essentia  2.1-beta5-dev
jsonconvert.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2016 Music Technology Group - Universitat Pompeu Fabra
3  *
4  * This file is part of Essentia
5  *
6  * Essentia is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License as published by the Free
8  * Software Foundation (FSF), either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the Affero GNU General Public License
17  * version 3 along with this program. If not, see http://www.gnu.org/licenses/
18  */
19 
20 
21 #ifndef JSON_CONVERT_H
22 #define JSON_CONVERT_H
23 
24 #include <string>
25 #include "yamlast.h"
26 
27 namespace essentia {
28 
29 class JsonConvert {
30  private:
31  size_t _pos;
32  std::string _str;
33  std::string _result;
34  size_t _size;
35 
36  public:
37  JsonConvert(const std::string& s) : _pos(0), _str(s), _result(""), _size(s.size()) {}
38  virtual ~JsonConvert() {}
39  std::string convert();
40 
41 
42  protected:
43  void skipSpaces();
44  int countBackSlashes();
45  std::string parseStringValue();
46  std::string parseNumValue();
47  std::string parseListValue();
48  std::string parseDictKeyAndValue(const int& level);
49 
50  public:
51  std::string parseDict(const int& level=0);
52 };
53 
54 
55 class JsonException : public YamlException {
56  public:
57  JsonException(const std::string& msg) : YamlException(msg) {}
58 };
59 
60 } // namespace essentia
61 
62 #endif // JSON_CONVERT_H
size_t _size
Definition: jsonconvert.h:34
virtual ~JsonConvert()
Definition: jsonconvert.h:38
Definition: jsonconvert.h:55
std::string _result
Definition: jsonconvert.h:33
std::string parseListValue()
std::string convert()
std::string parseDict(const int &level=0)
JsonConvert(const std::string &s)
Definition: jsonconvert.h:37
std::string parseNumValue()
Definition: algorithm.h:28
Definition: yamlast.h:32
std::string _str
Definition: jsonconvert.h:32
Definition: jsonconvert.h:29
std::string parseDictKeyAndValue(const int &level)
JsonException(const std::string &msg)
Definition: jsonconvert.h:57
std::string parseStringValue()
size_t _pos
Definition: jsonconvert.h:31