Skip to content
Snippets Groups Projects
Commit 54cd60f8 authored by Mirko Wächter's avatar Mirko Wächter
Browse files

Merge branch 'master' of https://gitlab.com/ArmarX/ArmarXGui

parents 9ee71781 20765bb0
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,10 @@ JsonValue::JsonValue(int value)
: type(eNumber), value(ToString(value))
{ }
JsonValue::JsonValue(long value)
: type(eNumber), value(ToString(value))
{ }
JsonValue::JsonValue(float value)
: type(eNumber), value(ToString(value))
{ }
......@@ -59,6 +63,36 @@ JsonValuePtr JsonValue::False()
return value;
}
JsonValuePtr JsonValue::Create(const std::string& value)
{
JsonValuePtr jsonValue(new JsonValue(value));
return jsonValue;
}
JsonValuePtr JsonValue::Create(int value)
{
JsonValuePtr jsonValue(new JsonValue(value));
return jsonValue;
}
JsonValuePtr JsonValue::Create(long value)
{
JsonValuePtr jsonValue(new JsonValue(value));
return jsonValue;
}
JsonValuePtr JsonValue::Create(float value)
{
JsonValuePtr jsonValue(new JsonValue(value));
return jsonValue;
}
JsonValuePtr JsonValue::Create(double value)
{
JsonValuePtr jsonValue(new JsonValue(value));
return jsonValue;
}
JsonValuePtr JsonValue::CreateRaw(JsonValue::Type type, const std::string& value)
{
if (!CheckValue(type, value))
......@@ -142,6 +176,14 @@ std::string JsonValue::ToString(int value)
return oss.str();
}
std::string JsonValue::ToString(long value)
{
std::ostringstream oss;
oss.imbue(std::locale::classic());
oss << value;
return oss.str();
}
std::string JsonValue::ToString(float value)
{
std::ostringstream oss;
......
......@@ -40,12 +40,18 @@ namespace armarx
JsonValue(const std::string& value);
JsonValue(int value);
JsonValue(long value);
JsonValue(float value);
JsonValue(double value);
static JsonValuePtr Null();
static JsonValuePtr True();
static JsonValuePtr False();
static JsonValuePtr Create(const std::string& value);
static JsonValuePtr Create(int value);
static JsonValuePtr Create(long value);
static JsonValuePtr Create(float value);
static JsonValuePtr Create(double value);
static JsonValuePtr CreateRaw(Type type, const std::string& value);
static bool CheckValue(Type type, const std::string& value);
......@@ -55,11 +61,13 @@ namespace armarx
static bool CheckBool(const std::string& value);
static bool CheckNull(const std::string& value);
void writeJson(const JsonWriterPtr& writer);
JsonValuePtr toSharedPtr() const;
static std::string ToString(int value);
static std::string ToString(long value);
static std::string ToString(float value);
static std::string ToString(double value);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment