Baptiste Lepilleur | 7469f1d | 2010-04-20 21:35:19 +0000 | [diff] [blame] | 1 | // Copyright 2007-2010 Baptiste Lepilleur |
| 2 | // Distributed under MIT license, or public domain if desired and |
| 3 | // recognized in your jurisdiction. |
| 4 | // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE |
| 5 | |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 6 | #ifndef JSON_WRITER_H_INCLUDED |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 7 | #define JSON_WRITER_H_INCLUDED |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 8 | |
Baptiste Lepilleur | eadc478 | 2011-05-02 21:09:30 +0000 | [diff] [blame] | 9 | #if !defined(JSON_IS_AMALGAMATION) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 10 | #include "value.h" |
Baptiste Lepilleur | eadc478 | 2011-05-02 21:09:30 +0000 | [diff] [blame] | 11 | #endif // if !defined(JSON_IS_AMALGAMATION) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 12 | #include <vector> |
| 13 | #include <string> |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 14 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 15 | // Disable warning C4251: <data member>: <type> needs to have dll-interface to |
| 16 | // be used by... |
Baptiste Lepilleur | eafd702 | 2013-05-08 20:21:11 +0000 | [diff] [blame] | 17 | #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 18 | #pragma warning(push) |
| 19 | #pragma warning(disable : 4251) |
Baptiste Lepilleur | eafd702 | 2013-05-08 20:21:11 +0000 | [diff] [blame] | 20 | #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) |
| 21 | |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 22 | namespace Json { |
| 23 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 24 | class Value; |
Christopher Dunn | 489707f | 2015-01-22 15:25:30 -0600 | [diff] [blame] | 25 | class StreamWriterBuilder; |
| 26 | |
| 27 | /** |
| 28 | |
| 29 | Usage: |
| 30 | |
| 31 | using namespace Json; |
| 32 | Value value; |
Christopher Dunn | fe3979c | 2015-01-24 13:54:28 -0600 | [diff] [blame] | 33 | StreamWriter::Builder builder; |
Christopher Dunn | c7b39c2 | 2015-01-25 18:45:59 -0600 | [diff] [blame] | 34 | builder.withCommentStyle(StreamWriter::CommentStyle::None); |
Christopher Dunn | 77ce057 | 2015-01-23 07:11:06 -0600 | [diff] [blame] | 35 | std::shared_ptr<StreamWriter> writer( |
| 36 | builder.newStreamWriter(&std::cout)); |
| 37 | writer->write(value); |
| 38 | std::cout.flush(); |
Christopher Dunn | 489707f | 2015-01-22 15:25:30 -0600 | [diff] [blame] | 39 | */ |
Christopher Dunn | 5fbfe3c | 2015-01-22 14:31:32 -0600 | [diff] [blame] | 40 | class JSON_API StreamWriter { |
| 41 | protected: |
| 42 | std::ostream& sout_; // not owned; will not delete |
| 43 | public: |
Christopher Dunn | 648843d | 2015-01-24 13:57:29 -0600 | [diff] [blame] | 44 | /// `All`: Keep all comments. |
| 45 | /// `None`: Drop all comments. |
| 46 | /// Use `Most` to recover the odd behavior of previous versions. |
| 47 | /// Only `All` is currently implemented. |
| 48 | enum class CommentStyle {None, Most, All}; |
Christopher Dunn | 489707f | 2015-01-22 15:25:30 -0600 | [diff] [blame] | 49 | |
Christopher Dunn | fe3979c | 2015-01-24 13:54:28 -0600 | [diff] [blame] | 50 | /// Keep a reference, but do not take ownership of `sout`. |
Christopher Dunn | 5fbfe3c | 2015-01-22 14:31:32 -0600 | [diff] [blame] | 51 | StreamWriter(std::ostream* sout); |
| 52 | virtual ~StreamWriter(); |
| 53 | /// Write Value into document as configured in sub-class. |
| 54 | /// \return zero on success |
| 55 | /// \throw std::exception possibly, depending on configuration |
Christopher Dunn | beb6f35 | 2015-01-23 07:51:40 -0600 | [diff] [blame] | 56 | virtual int write(Value const& root) = 0; |
Christopher Dunn | 5fbfe3c | 2015-01-22 14:31:32 -0600 | [diff] [blame] | 57 | |
Christopher Dunn | 489707f | 2015-01-22 15:25:30 -0600 | [diff] [blame] | 58 | /// Because this Builder is non-virtual, we can safely add |
| 59 | /// methods without a major version bump. |
| 60 | /// \see http://stackoverflow.com/questions/14875052/pure-virtual-functions-and-binary-compatibility |
| 61 | class Builder { |
| 62 | StreamWriterBuilder* own_; |
Christopher Dunn | fe3979c | 2015-01-24 13:54:28 -0600 | [diff] [blame] | 63 | Builder(Builder const&); // noncopyable |
| 64 | void operator=(Builder const&); // noncopyable |
Christopher Dunn | 489707f | 2015-01-22 15:25:30 -0600 | [diff] [blame] | 65 | public: |
Christopher Dunn | fe3979c | 2015-01-24 13:54:28 -0600 | [diff] [blame] | 66 | Builder(); |
Christopher Dunn | 489707f | 2015-01-22 15:25:30 -0600 | [diff] [blame] | 67 | ~Builder(); // delete underlying StreamWriterBuilder |
Christopher Dunn | 5fbfe3c | 2015-01-22 14:31:32 -0600 | [diff] [blame] | 68 | |
Christopher Dunn | c7b39c2 | 2015-01-25 18:45:59 -0600 | [diff] [blame] | 69 | Builder& withCommentStyle(CommentStyle cs); /// default: All |
Christopher Dunn | 4d64940 | 2015-01-22 16:08:21 -0600 | [diff] [blame] | 70 | /** \brief Write in human-friendly style. |
| 71 | |
| 72 | If "", then skip all indentation, newlines, and comments, |
| 73 | which implies CommentStyle::None. |
| 74 | Default: "\t" |
| 75 | */ |
Christopher Dunn | c7b39c2 | 2015-01-25 18:45:59 -0600 | [diff] [blame] | 76 | Builder& withIndentation(std::string indentation); |
Christopher Dunn | d78caa3 | 2015-01-25 18:15:54 -0600 | [diff] [blame] | 77 | /** \brief Drop the "null" string from the writer's output for nullValues. |
| 78 | * Strictly speaking, this is not valid JSON. But when the output is being |
| 79 | * fed to a browser's Javascript, it makes for smaller output and the |
| 80 | * browser can handle the output just fine. |
| 81 | */ |
Christopher Dunn | c7b39c2 | 2015-01-25 18:45:59 -0600 | [diff] [blame] | 82 | Builder& withDropNullPlaceholders(bool v); |
Christopher Dunn | d78caa3 | 2015-01-25 18:15:54 -0600 | [diff] [blame] | 83 | /** \brief Do not add \n at end of document. |
| 84 | * Normally, we add an extra newline, just because. |
| 85 | */ |
Christopher Dunn | c7b39c2 | 2015-01-25 18:45:59 -0600 | [diff] [blame] | 86 | Builder& withOmitEndingLineFeed(bool v); |
Christopher Dunn | d78caa3 | 2015-01-25 18:15:54 -0600 | [diff] [blame] | 87 | /** \brief Add a space after ':'. |
| 88 | * If indentation is non-empty, we surround colon with whitespace, |
| 89 | * e.g. " : " |
| 90 | * This will add back the trailing space when there is no indentation. |
| 91 | * This seems dubious when the entire document is on a single line, |
| 92 | * but we leave this here to repduce the behavior of the old `FastWriter`. |
| 93 | */ |
Christopher Dunn | c7b39c2 | 2015-01-25 18:45:59 -0600 | [diff] [blame] | 94 | Builder& withEnableYAMLCompatibility(bool v); |
Christopher Dunn | 489707f | 2015-01-22 15:25:30 -0600 | [diff] [blame] | 95 | |
| 96 | /// Do not take ownership of sout, but maintain a reference. |
Christopher Dunn | 9243d60 | 2015-01-23 08:38:32 -0600 | [diff] [blame] | 97 | StreamWriter* newStreamWriter(std::ostream* sout) const; |
Christopher Dunn | 489707f | 2015-01-22 15:25:30 -0600 | [diff] [blame] | 98 | }; |
Christopher Dunn | 5fbfe3c | 2015-01-22 14:31:32 -0600 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | /// \brief Write into stringstream, then return string, for convenience. |
Christopher Dunn | 9243d60 | 2015-01-23 08:38:32 -0600 | [diff] [blame] | 102 | std::string writeString(Value const& root, StreamWriter::Builder const& builder); |
Christopher Dunn | 5fbfe3c | 2015-01-22 14:31:32 -0600 | [diff] [blame] | 103 | |
| 104 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 105 | /** \brief Abstract class for writers. |
Christopher Dunn | c7b39c2 | 2015-01-25 18:45:59 -0600 | [diff] [blame] | 106 | * \deprecated Use StreamWriter::Builder. |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 107 | */ |
| 108 | class JSON_API Writer { |
| 109 | public: |
| 110 | virtual ~Writer(); |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 111 | |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 112 | virtual std::string write(const Value& root) = 0; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 113 | }; |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 114 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 115 | /** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format |
| 116 | *without formatting (not human friendly). |
| 117 | * |
| 118 | * The JSON document is written in a single line. It is not intended for 'human' |
| 119 | *consumption, |
| 120 | * but may be usefull to support feature such as RPC where bandwith is limited. |
| 121 | * \sa Reader, Value |
Christopher Dunn | c7b39c2 | 2015-01-25 18:45:59 -0600 | [diff] [blame] | 122 | * \deprecated Use StreamWriter::Builder. |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 123 | */ |
| 124 | class JSON_API FastWriter : public Writer { |
| 125 | public: |
| 126 | FastWriter(); |
| 127 | virtual ~FastWriter() {} |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 128 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 129 | void enableYAMLCompatibility(); |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 130 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 131 | /** \brief Drop the "null" string from the writer's output for nullValues. |
| 132 | * Strictly speaking, this is not valid JSON. But when the output is being |
| 133 | * fed to a browser's Javascript, it makes for smaller output and the |
| 134 | * browser can handle the output just fine. |
| 135 | */ |
| 136 | void dropNullPlaceholders(); |
Aaron Jacobs | ae3c7a7 | 2012-03-12 04:53:57 +0000 | [diff] [blame] | 137 | |
Don Milham | 5bf1610 | 2014-09-02 17:09:07 -0600 | [diff] [blame] | 138 | void omitEndingLineFeed(); |
| 139 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 140 | public: // overridden from Writer |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 141 | virtual std::string write(const Value& root); |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 142 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 143 | private: |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 144 | void writeValue(const Value& value); |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 145 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 146 | std::string document_; |
| 147 | bool yamlCompatiblityEnabled_; |
| 148 | bool dropNullPlaceholders_; |
Don Milham | 5bf1610 | 2014-09-02 17:09:07 -0600 | [diff] [blame] | 149 | bool omitEndingLineFeed_; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 150 | }; |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 151 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 152 | /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a |
| 153 | *human friendly way. |
| 154 | * |
| 155 | * The rules for line break and indent are as follow: |
| 156 | * - Object value: |
| 157 | * - if empty then print {} without indent and line break |
| 158 | * - if not empty the print '{', line break & indent, print one value per |
| 159 | *line |
| 160 | * and then unindent and line break and print '}'. |
| 161 | * - Array value: |
| 162 | * - if empty then print [] without indent and line break |
| 163 | * - if the array contains no object value, empty array or some other value |
| 164 | *types, |
| 165 | * and all the values fit on one lines, then print the array on a single |
| 166 | *line. |
| 167 | * - otherwise, it the values do not fit on one line, or the array contains |
| 168 | * object or non empty array, then print one value per line. |
| 169 | * |
| 170 | * If the Value have comments then they are outputed according to their |
| 171 | *#CommentPlacement. |
| 172 | * |
| 173 | * \sa Reader, Value, Value::setComment() |
Christopher Dunn | c7b39c2 | 2015-01-25 18:45:59 -0600 | [diff] [blame] | 174 | * \deprecated Use StreamWriter::Builder. |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 175 | */ |
| 176 | class JSON_API StyledWriter : public Writer { |
| 177 | public: |
| 178 | StyledWriter(); |
| 179 | virtual ~StyledWriter() {} |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 180 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 181 | public: // overridden from Writer |
| 182 | /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format. |
| 183 | * \param root Value to serialize. |
| 184 | * \return String containing the JSON document that represents the root value. |
| 185 | */ |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 186 | virtual std::string write(const Value& root); |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 187 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 188 | private: |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 189 | void writeValue(const Value& value); |
| 190 | void writeArrayValue(const Value& value); |
| 191 | bool isMultineArray(const Value& value); |
| 192 | void pushValue(const std::string& value); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 193 | void writeIndent(); |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 194 | void writeWithIndent(const std::string& value); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 195 | void indent(); |
| 196 | void unindent(); |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 197 | void writeCommentBeforeValue(const Value& root); |
| 198 | void writeCommentAfterValueOnSameLine(const Value& root); |
| 199 | bool hasCommentForValue(const Value& value); |
| 200 | static std::string normalizeEOL(const std::string& text); |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 201 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 202 | typedef std::vector<std::string> ChildValues; |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 203 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 204 | ChildValues childValues_; |
| 205 | std::string document_; |
| 206 | std::string indentString_; |
| 207 | int rightMargin_; |
| 208 | int indentSize_; |
| 209 | bool addChildValues_; |
| 210 | }; |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 211 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 212 | /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a |
| 213 | human friendly way, |
| 214 | to a stream rather than to a string. |
| 215 | * |
| 216 | * The rules for line break and indent are as follow: |
| 217 | * - Object value: |
| 218 | * - if empty then print {} without indent and line break |
| 219 | * - if not empty the print '{', line break & indent, print one value per |
| 220 | line |
| 221 | * and then unindent and line break and print '}'. |
| 222 | * - Array value: |
| 223 | * - if empty then print [] without indent and line break |
| 224 | * - if the array contains no object value, empty array or some other value |
| 225 | types, |
| 226 | * and all the values fit on one lines, then print the array on a single |
| 227 | line. |
| 228 | * - otherwise, it the values do not fit on one line, or the array contains |
| 229 | * object or non empty array, then print one value per line. |
| 230 | * |
| 231 | * If the Value have comments then they are outputed according to their |
| 232 | #CommentPlacement. |
| 233 | * |
| 234 | * \param indentation Each level will be indented by this amount extra. |
| 235 | * \sa Reader, Value, Value::setComment() |
Christopher Dunn | c7b39c2 | 2015-01-25 18:45:59 -0600 | [diff] [blame] | 236 | * \deprecated Use StreamWriter::Builder. |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 237 | */ |
| 238 | class JSON_API StyledStreamWriter { |
| 239 | public: |
| 240 | StyledStreamWriter(std::string indentation = "\t"); |
| 241 | ~StyledStreamWriter() {} |
Christopher Dunn | 605cd7e | 2007-06-13 15:55:50 +0000 | [diff] [blame] | 242 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 243 | public: |
| 244 | /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format. |
| 245 | * \param out Stream to write to. (Can be ostringstream, e.g.) |
| 246 | * \param root Value to serialize. |
| 247 | * \note There is no point in deriving from Writer, since write() should not |
| 248 | * return a value. |
| 249 | */ |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 250 | void write(std::ostream& out, const Value& root); |
Christopher Dunn | 605cd7e | 2007-06-13 15:55:50 +0000 | [diff] [blame] | 251 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 252 | private: |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 253 | void writeValue(const Value& value); |
| 254 | void writeArrayValue(const Value& value); |
| 255 | bool isMultineArray(const Value& value); |
| 256 | void pushValue(const std::string& value); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 257 | void writeIndent(); |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 258 | void writeWithIndent(const std::string& value); |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 259 | void indent(); |
| 260 | void unindent(); |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 261 | void writeCommentBeforeValue(const Value& root); |
| 262 | void writeCommentAfterValueOnSameLine(const Value& root); |
| 263 | bool hasCommentForValue(const Value& value); |
| 264 | static std::string normalizeEOL(const std::string& text); |
Christopher Dunn | 605cd7e | 2007-06-13 15:55:50 +0000 | [diff] [blame] | 265 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 266 | typedef std::vector<std::string> ChildValues; |
Christopher Dunn | 605cd7e | 2007-06-13 15:55:50 +0000 | [diff] [blame] | 267 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 268 | ChildValues childValues_; |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 269 | std::ostream* document_; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 270 | std::string indentString_; |
| 271 | int rightMargin_; |
| 272 | std::string indentation_; |
Christopher Dunn | d383056 | 2015-01-23 13:09:43 -0600 | [diff] [blame] | 273 | bool addChildValues_ : 1; |
| 274 | bool indented_ : 1; |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 275 | }; |
Christopher Dunn | 605cd7e | 2007-06-13 15:55:50 +0000 | [diff] [blame] | 276 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 277 | #if defined(JSON_HAS_INT64) |
| 278 | std::string JSON_API valueToString(Int value); |
| 279 | std::string JSON_API valueToString(UInt value); |
| 280 | #endif // if defined(JSON_HAS_INT64) |
| 281 | std::string JSON_API valueToString(LargestInt value); |
| 282 | std::string JSON_API valueToString(LargestUInt value); |
| 283 | std::string JSON_API valueToString(double value); |
| 284 | std::string JSON_API valueToString(bool value); |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 285 | std::string JSON_API valueToQuotedString(const char* value); |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 286 | |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 287 | /// \brief Output using the StyledStreamWriter. |
| 288 | /// \see Json::operator>>() |
Aaron Jacobs | 11086dd | 2014-09-15 10:15:29 +1000 | [diff] [blame] | 289 | JSON_API std::ostream& operator<<(std::ostream&, const Value& root); |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 290 | |
| 291 | } // namespace Json |
| 292 | |
Baptiste Lepilleur | eafd702 | 2013-05-08 20:21:11 +0000 | [diff] [blame] | 293 | #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) |
Aaron Jacobs | 9fa4e84 | 2014-07-01 08:48:54 +1000 | [diff] [blame] | 294 | #pragma warning(pop) |
Baptiste Lepilleur | eafd702 | 2013-05-08 20:21:11 +0000 | [diff] [blame] | 295 | #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) |
| 296 | |
Christopher Dunn | 6d135cb | 2007-06-13 15:51:04 +0000 | [diff] [blame] | 297 | #endif // JSON_WRITER_H_INCLUDED |