mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-18 04:52:22 +02:00
Reduced the size of JsonValue to 6 bytes !
This commit is contained in:
@ -12,11 +12,6 @@ size_t JsonValue::printBoolTo(const Content& c, Print& p)
|
|||||||
return p.print(c.asBool ? "true" : "false");
|
return p.print(c.asBool ? "true" : "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t JsonValue::printDoubleTo(const Content& c, Print& p)
|
|
||||||
{
|
|
||||||
return p.print(c.asDouble.value, c.asDouble.digits);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t JsonValue::printLongTo(const Content& c, Print& p)
|
size_t JsonValue::printLongTo(const Content& c, Print& p)
|
||||||
{
|
{
|
||||||
return p.print(c.asLong);
|
return p.print(c.asLong);
|
||||||
|
@ -49,9 +49,8 @@ namespace ArduinoJson
|
|||||||
template<int DIGITS>
|
template<int DIGITS>
|
||||||
void set(double value)
|
void set(double value)
|
||||||
{
|
{
|
||||||
printToImpl = &printDoubleTo;
|
printToImpl = &printDoubleTo<DIGITS>;
|
||||||
content.asDouble.value = value;
|
content.asDouble = value;
|
||||||
content.asDouble.digits = DIGITS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t printTo(Print& p) const
|
size_t printTo(Print& p) const
|
||||||
@ -67,22 +66,23 @@ namespace ArduinoJson
|
|||||||
long asLong;
|
long asLong;
|
||||||
Printable* asPrintable;
|
Printable* asPrintable;
|
||||||
const char* asString;
|
const char* asString;
|
||||||
|
double asDouble;
|
||||||
struct {
|
|
||||||
double value;
|
|
||||||
uint8_t digits;
|
|
||||||
} asDouble;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Content content;
|
Content content;
|
||||||
|
|
||||||
size_t(*printToImpl)(const Content&, Print& p);
|
size_t(*printToImpl)(const Content&, Print&);
|
||||||
|
|
||||||
static size_t printBoolTo(const Content&, Print& p);
|
static size_t printBoolTo(const Content&, Print&);
|
||||||
static size_t printDoubleTo(const Content&, Print& p);
|
static size_t printLongTo(const Content&, Print&);
|
||||||
static size_t printLongTo(const Content&, Print& p);
|
static size_t printPrintableTo(const Content&, Print&);
|
||||||
static size_t printPrintableTo(const Content&, Print& p);
|
static size_t printStringTo(const Content&, Print&);
|
||||||
static size_t printStringTo(const Content&, Print& p);
|
|
||||||
|
template<int DIGITS>
|
||||||
|
static size_t printDoubleTo(const Content& c, Print& p)
|
||||||
|
{
|
||||||
|
return p.print(c.asDouble, DIGITS);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user