Skip to content

Commit

Permalink
Added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Sep 1, 2014
1 parent 763aa7f commit 58c051f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions JsonGenerator/IndentedPrint.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace ArduinoJson
{
namespace Generator
{
// Decorator on top of Print to allow indented output.
// This class is used by JsonPrintable::prettyPrintTo() but can also be used
// for your own purpose, like logging.
class IndentedPrint : public Print
{
public:
Expand All @@ -25,8 +28,13 @@ namespace ArduinoJson

virtual size_t write(uint8_t);

// Adds one level of indentation
void indent();

// Removes one level of indentation
void unindent();

// Set the number of space printed for each level of indentation
void setTabSize(uint8_t n);

private:
Expand Down
1 change: 1 addition & 0 deletions JsonGenerator/JsonPrettyPrint.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace ArduinoJson
{
namespace Generator
{
// Converts a compact JSON string into an indented one.
class JsonPrettyPrint : public Print
{
public:
Expand Down
13 changes: 12 additions & 1 deletion JsonGenerator/JsonPrintable.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,27 @@ namespace ArduinoJson
{
namespace Generator
{
// Contains methods to generate a JSON string.
// Implemented by both JsonObject and JsonArray
class JsonPrintable : public Printable
{
public:

// Generates the compact JSON string and sends it to a Print stream
virtual size_t printTo(Print& p) const = 0;

// Generates the compact JSON string and writes it in a buffer
size_t printTo(char* buffer, size_t bufferSize) const;

size_t prettyPrintTo(IndentedPrint& p) const;
// Generates the indented JSON string and sends it to a Print stream
size_t prettyPrintTo(Print& p) const;

// Generates the indented JSON string and sends it to a IndentedPrint stream
// This overload allows a finer control of the output because you can customize
// the IndentedPrint.
size_t prettyPrintTo(IndentedPrint& p) const;

// Generates the indented JSON string and writes it in a buffer
size_t prettyPrintTo(char* buffer, size_t bufferSize) const;
};
}
Expand Down

0 comments on commit 58c051f

Please sign in to comment.