summaryrefslogtreecommitdiffstats
path: root/include/lldb/Utility/JSON.h
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-09-06 14:32:30 +0000
committerdim <dim@FreeBSD.org>2015-09-06 14:32:30 +0000
commit80b639cd40df427b9e325318efeec2d885a65f62 (patch)
tree94980f450aa3daec3e1fec217374704ad62cfe45 /include/lldb/Utility/JSON.h
parent8037fa4ee916fa20b3c63cbf531f4ee7e1c76138 (diff)
downloadFreeBSD-src-80b639cd40df427b9e325318efeec2d885a65f62.zip
FreeBSD-src-80b639cd40df427b9e325318efeec2d885a65f62.tar.gz
Vendor import of (stripped) lldb trunk r242221:
https://llvm.org/svn/llvm-project/lldb/trunk@242221
Diffstat (limited to 'include/lldb/Utility/JSON.h')
-rw-r--r--include/lldb/Utility/JSON.h68
1 files changed, 62 insertions, 6 deletions
diff --git a/include/lldb/Utility/JSON.h b/include/lldb/Utility/JSON.h
index 45ddb71..da5e26d 100644
--- a/include/lldb/Utility/JSON.h
+++ b/include/lldb/Utility/JSON.h
@@ -11,6 +11,7 @@
#define utility_JSON_h_
#include "lldb/Core/Stream.h"
+#include "lldb/Utility/StringExtractor.h"
#include <inttypes.h>
#include <map>
@@ -22,6 +23,7 @@
#include "llvm/Support/Casting.h"
namespace lldb_private {
+
class JSONValue
{
public:
@@ -97,8 +99,9 @@ namespace lldb_private {
{
public:
JSONNumber ();
- JSONNumber (int64_t i);
-
+ explicit JSONNumber (uint64_t i);
+ explicit JSONNumber (double d);
+
JSONNumber (const JSONNumber& s) = delete;
JSONNumber&
operator = (const JSONNumber& s) = delete;
@@ -107,10 +110,19 @@ namespace lldb_private {
Write (Stream& s);
typedef std::shared_ptr<JSONNumber> SP;
-
- int64_t
+
+ uint64_t
GetData () { return m_data; }
-
+
+ double
+ GetAsDouble()
+ {
+ if (m_is_integer)
+ return (double)m_data;
+ else
+ return m_double;
+ }
+
static bool classof(const JSONValue *V)
{
return V->GetKind() == JSONValue::Kind::Number;
@@ -120,7 +132,9 @@ namespace lldb_private {
~JSONNumber () = default;
private:
- int64_t m_data;
+ bool m_is_integer;
+ uint64_t m_data;
+ double m_double;
};
class JSONTrue : public JSONValue
@@ -271,6 +285,48 @@ namespace lldb_private {
Vector m_elements;
};
+
+
+ class JSONParser : public StringExtractor
+ {
+ public:
+ enum Token
+ {
+ Invalid,
+ Error,
+ ObjectStart,
+ ObjectEnd,
+ ArrayStart,
+ ArrayEnd,
+ Comma,
+ Colon,
+ String,
+ Integer,
+ Float,
+ True,
+ False,
+ Null,
+ EndOfFile
+ };
+
+ JSONParser (const char *cstr);
+
+ int
+ GetEscapedChar (bool &was_escaped);
+
+ Token
+ GetToken (std::string &value);
+
+ JSONValue::SP
+ ParseJSONValue ();
+
+ protected:
+ JSONValue::SP
+ ParseJSONObject ();
+
+ JSONValue::SP
+ ParseJSONArray ();
+ };
}
#endif // utility_ProcessStructReader_h_
OpenPOWER on IntegriCloud