Skip to content

Commit

Permalink
Changed ::String to ArduinoJson::String (issue #275)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed May 6, 2016
1 parent 78728c6 commit c5d19a4
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
ArduinoJson: change log
=======================

HEAD
----

* Changed `::String` to `ArduinoJson::String` (issue #275)
* Changed `::Print` to `ArduinoJson::Print` too

v5.3.0
------

Expand Down
10 changes: 10 additions & 0 deletions include/ArduinoJson/Configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
#define ARDUINOJSON_USE_INT64 0
#endif

// arduino has its own implementation of String to replace std::string
#ifndef ARDUINOJSON_USE_ARDUINO_STRING
#define ARDUINOJSON_USE_ARDUINO_STRING 1
#endif

// arduino doesn't support STL stream
#ifndef ARDUINOJSON_ENABLE_STD_STREAM
#define ARDUINOJSON_ENABLE_STD_STREAM 0
Expand Down Expand Up @@ -62,6 +67,11 @@
#endif
#endif

// on a computer, we can use std::string
#ifndef ARDUINOJSON_USE_ARDUINO_STRING
#define ARDUINOJSON_USE_ARDUINO_STRING 0
#endif

// on a computer, we can assume that the STL is there
#ifndef ARDUINOJSON_ENABLE_STD_STREAM
#define ARDUINOJSON_ENABLE_STD_STREAM 1
Expand Down
2 changes: 1 addition & 1 deletion include/ArduinoJson/Internals/DummyPrint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma once

#include "../Arduino/Print.hpp"
#include "../Print.hpp"

namespace ArduinoJson {
namespace Internals {
Expand Down
4 changes: 2 additions & 2 deletions include/ArduinoJson/Internals/DynamicStringBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#pragma once

#include "../Arduino/Print.hpp"
#include "../Arduino/String.hpp"
#include "../Print.hpp"
#include "../String.hpp"

namespace ArduinoJson {
namespace Internals {
Expand Down
2 changes: 1 addition & 1 deletion include/ArduinoJson/Internals/Encoding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma once

#include "../Arduino/Print.hpp"
#include "../Print.hpp"

namespace ArduinoJson {
namespace Internals {
Expand Down
2 changes: 1 addition & 1 deletion include/ArduinoJson/Internals/IndentedPrint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma once

#include "../Arduino/Print.hpp"
#include "../Print.hpp"

namespace ArduinoJson {
namespace Internals {
Expand Down
4 changes: 2 additions & 2 deletions include/ArduinoJson/Internals/JsonWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

#pragma once

#include "../Arduino/Print.hpp"
#include "../Polyfills/isNaN.hpp"
#include "../Polyfills/isInfinity.hpp"
#include "../Polyfills/isNaN.hpp"
#include "../Polyfills/normalize.hpp"
#include "../Print.hpp"
#include "Encoding.hpp"
#include "ForceInline.hpp"
#include "JsonFloat.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/ArduinoJson/Internals/StaticStringBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma once

#include "../Arduino/Print.hpp"
#include "../Print.hpp"

namespace ArduinoJson {
namespace Internals {
Expand Down
2 changes: 1 addition & 1 deletion include/ArduinoJson/Internals/StreamPrintAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#if ARDUINOJSON_ENABLE_STD_STREAM

#include "../Arduino/Print.hpp"
#include "../Print.hpp"

#include <ostream>

Expand Down
2 changes: 1 addition & 1 deletion include/ArduinoJson/JsonBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <stdint.h> // for uint8_t
#include <string.h>

#include "Arduino/String.hpp"
#include "String.hpp"
#include "JsonVariant.hpp"

#if defined(__clang__)
Expand Down
2 changes: 1 addition & 1 deletion include/ArduinoJson/JsonObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma once

#include "Arduino/String.hpp"
#include "String.hpp"
#include "Internals/JsonBufferAllocated.hpp"
#include "Internals/JsonPrintable.hpp"
#include "Internals/List.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/ArduinoJson/JsonObjectKey.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma once

#include "Arduino/String.hpp"
#include "String.hpp"

namespace ArduinoJson {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <stddef.h>
#include <stdint.h>

namespace ArduinoJson {
// This class reproduces Arduino's Print class
class Print {
public:
Expand All @@ -29,6 +30,7 @@ class Print {

size_t println() { return write('\r') + write('\n'); }
};
}

#else

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@

#pragma once

#ifndef ARDUINO
#include "Configuration.hpp"

#include <string>
typedef std::string String;
#if ARDUINOJSON_USE_ARDUINO_STRING

#include <WString.h>

#else

#include <WString.h>
#include <string>

namespace ArduinoJson {
typedef std::string String;
}

#endif
2 changes: 1 addition & 1 deletion test/StringBuilderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!

#include <ArduinoJson.h>
#include <gtest/gtest.h>
#include <ArduinoJson/Internals/StaticStringBuilder.hpp>

using namespace ArduinoJson::Internals;

Expand Down

0 comments on commit c5d19a4

Please sign in to comment.