Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 1 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 2 | * Copyright (C) 2013 Regents of the University of California. |
| 3 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 4 | * See COPYING for copyright and distribution information. |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
Jeff Thompson | 5490977 | 2013-07-07 22:38:57 -0700 | [diff] [blame] | 7 | #include <stdexcept> |
Jeff Thompson | b8f1b13 | 2013-08-13 11:07:43 -0700 | [diff] [blame] | 8 | #include <algorithm> |
Jeff Thompson | 5341219 | 2013-08-06 13:35:50 -0700 | [diff] [blame] | 9 | #include "name.hpp" |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 10 | |
| 11 | using namespace std; |
Jeff Thompson | d4144fe | 2013-09-18 15:59:57 -0700 | [diff] [blame] | 12 | using namespace ndn::ptr_lib; |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 13 | |
| 14 | namespace ndn { |
| 15 | |
Jeff Thompson | 26c63d6 | 2013-07-02 18:00:26 -0700 | [diff] [blame] | 16 | static const char *WHITESPACE_CHARS = " \n\r\t"; |
| 17 | |
| 18 | /** |
| 19 | * Modify str in place to erase whitespace on the left. |
| 20 | * @param str |
| 21 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 22 | static inline void |
| 23 | trimLeft(string& str) |
Jeff Thompson | 26c63d6 | 2013-07-02 18:00:26 -0700 | [diff] [blame] | 24 | { |
| 25 | size_t found = str.find_first_not_of(WHITESPACE_CHARS); |
| 26 | if (found != string::npos) { |
| 27 | if (found > 0) |
| 28 | str.erase(0, found); |
| 29 | } |
| 30 | else |
| 31 | // All whitespace |
| 32 | str.clear(); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Modify str in place to erase whitespace on the right. |
| 37 | * @param str |
| 38 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 39 | static inline void |
| 40 | trimRight(string& str) |
Jeff Thompson | 26c63d6 | 2013-07-02 18:00:26 -0700 | [diff] [blame] | 41 | { |
| 42 | size_t found = str.find_last_not_of(WHITESPACE_CHARS); |
| 43 | if (found != string::npos) { |
| 44 | if (found + 1 < str.size()) |
| 45 | str.erase(found + 1); |
| 46 | } |
| 47 | else |
| 48 | // All whitespace |
| 49 | str.clear(); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Modify str in place to erase whitespace on the left and right. |
| 54 | * @param str |
| 55 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 56 | static void |
| 57 | trim(string& str) |
Jeff Thompson | 26c63d6 | 2013-07-02 18:00:26 -0700 | [diff] [blame] | 58 | { |
| 59 | trimLeft(str); |
| 60 | trimRight(str); |
| 61 | } |
Jeff Thompson | 443398d | 2013-07-02 19:45:46 -0700 | [diff] [blame] | 62 | |
Jeff Thompson | 26c63d6 | 2013-07-02 18:00:26 -0700 | [diff] [blame] | 63 | /** |
| 64 | * Convert the hex character to an integer from 0 to 15, or -1 if not a hex character. |
| 65 | * @param c |
| 66 | * @return |
| 67 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 68 | static int |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 69 | fromHexChar(uint8_t c) |
Jeff Thompson | 26c63d6 | 2013-07-02 18:00:26 -0700 | [diff] [blame] | 70 | { |
| 71 | if (c >= '0' && c <= '9') |
| 72 | return (int)c - (int)'0'; |
| 73 | else if (c >= 'A' && c <= 'F') |
| 74 | return (int)c - (int)'A' + 10; |
| 75 | else if (c >= 'a' && c <= 'f') |
| 76 | return (int)c - (int)'a' + 10; |
| 77 | else |
| 78 | return -1; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Return a copy of str, converting each escaped "%XX" to the char value. |
| 83 | * @param str |
| 84 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 85 | static string |
| 86 | unescape(const string& str) |
Jeff Thompson | 26c63d6 | 2013-07-02 18:00:26 -0700 | [diff] [blame] | 87 | { |
| 88 | ostringstream result; |
| 89 | |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 90 | for (size_t i = 0; i < str.size(); ++i) { |
Jeff Thompson | 26c63d6 | 2013-07-02 18:00:26 -0700 | [diff] [blame] | 91 | if (str[i] == '%' && i + 2 < str.size()) { |
| 92 | int hi = fromHexChar(str[i + 1]); |
| 93 | int lo = fromHexChar(str[i + 2]); |
| 94 | |
| 95 | if (hi < 0 || lo < 0) |
| 96 | // Invalid hex characters, so just keep the escaped string. |
| 97 | result << str[i] << str[i + 1] << str[i + 2]; |
| 98 | else |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 99 | result << (uint8_t)(16 * hi + lo); |
Jeff Thompson | 26c63d6 | 2013-07-02 18:00:26 -0700 | [diff] [blame] | 100 | |
| 101 | // Skip ahead past the escaped value. |
| 102 | i += 2; |
| 103 | } |
| 104 | else |
| 105 | // Just copy through. |
| 106 | result << str[i]; |
| 107 | } |
| 108 | |
| 109 | return result.str(); |
| 110 | } |
| 111 | |
Jeff Thompson | 27cae53 | 2013-10-08 12:52:41 -0700 | [diff] [blame] | 112 | uint64_t Name::Component::toNumberWithMarker(uint8_t marker) const |
| 113 | { |
| 114 | struct ndn_NameComponent componentStruct; |
| 115 | get(componentStruct); |
| 116 | uint64_t result; |
| 117 | |
| 118 | ndn_Error error; |
| 119 | if ((error = ndn_NameComponent_toNumberWithMarker(&componentStruct, marker, &result))) |
| 120 | throw std::runtime_error(ndn_getErrorString(error)); |
| 121 | |
| 122 | return result; |
| 123 | } |
| 124 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 125 | Blob |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 126 | Name::Component::makeFromEscapedString(const char *escapedString, size_t beginOffset, size_t endOffset) |
Jeff Thompson | 443398d | 2013-07-02 19:45:46 -0700 | [diff] [blame] | 127 | { |
Jeff Thompson | c1c12e4 | 2013-09-13 19:08:45 -0700 | [diff] [blame] | 128 | string trimmedString(escapedString + beginOffset, escapedString + endOffset); |
Jeff Thompson | 443398d | 2013-07-02 19:45:46 -0700 | [diff] [blame] | 129 | trim(trimmedString); |
| 130 | string component = unescape(trimmedString); |
| 131 | |
| 132 | if (component.find_first_not_of(".") == string::npos) { |
| 133 | // Special case for component of only periods. |
| 134 | if (component.size() <= 2) |
| 135 | // Zero, one or two periods is illegal. Ignore this component. |
Jeff Thompson | 46411c9 | 2013-09-13 19:31:25 -0700 | [diff] [blame] | 136 | return Blob(); |
Jeff Thompson | 995aba5 | 2013-09-12 12:04:52 -0700 | [diff] [blame] | 137 | else |
Jeff Thompson | 443398d | 2013-07-02 19:45:46 -0700 | [diff] [blame] | 138 | // Remove 3 periods. |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 139 | return Blob((const uint8_t *)&component[3], component.size() - 3); |
Jeff Thompson | 443398d | 2013-07-02 19:45:46 -0700 | [diff] [blame] | 140 | } |
Jeff Thompson | 995aba5 | 2013-09-12 12:04:52 -0700 | [diff] [blame] | 141 | else |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 142 | return Blob((const uint8_t *)&component[0], component.size()); |
Jeff Thompson | 443398d | 2013-07-02 19:45:46 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 145 | Blob |
| 146 | Name::Component::makeSegment(unsigned long segment) |
Jeff Thompson | 8aac199 | 2013-08-12 17:26:02 -0700 | [diff] [blame] | 147 | { |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 148 | shared_ptr<vector<uint8_t> > value(new vector<uint8_t>()); |
Jeff Thompson | 8aac199 | 2013-08-12 17:26:02 -0700 | [diff] [blame] | 149 | |
Jeff Thompson | b8f1b13 | 2013-08-13 11:07:43 -0700 | [diff] [blame] | 150 | // Add the leading zero. |
Jeff Thompson | 995aba5 | 2013-09-12 12:04:52 -0700 | [diff] [blame] | 151 | value->push_back(0); |
Jeff Thompson | b8f1b13 | 2013-08-13 11:07:43 -0700 | [diff] [blame] | 152 | |
Jeff Thompson | 8aac199 | 2013-08-12 17:26:02 -0700 | [diff] [blame] | 153 | // First encode in little endian. |
| 154 | while (segment != 0) { |
Jeff Thompson | 995aba5 | 2013-09-12 12:04:52 -0700 | [diff] [blame] | 155 | value->push_back(segment & 0xff); |
Jeff Thompson | 8aac199 | 2013-08-12 17:26:02 -0700 | [diff] [blame] | 156 | segment >>= 8; |
| 157 | } |
| 158 | |
Jeff Thompson | 8aac199 | 2013-08-12 17:26:02 -0700 | [diff] [blame] | 159 | // Make it big endian. |
Jeff Thompson | 995aba5 | 2013-09-12 12:04:52 -0700 | [diff] [blame] | 160 | reverse(value->begin() + 1, value->end()); |
Jeff Thompson | 46411c9 | 2013-09-13 19:31:25 -0700 | [diff] [blame] | 161 | return Blob(value); |
Jeff Thompson | 8aac199 | 2013-08-12 17:26:02 -0700 | [diff] [blame] | 162 | } |
| 163 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 164 | void |
| 165 | Name::set(const char *uri_cstr) |
Jeff Thompson | 443398d | 2013-07-02 19:45:46 -0700 | [diff] [blame] | 166 | { |
Jeff Thompson | 67515bd | 2013-08-15 17:43:22 -0700 | [diff] [blame] | 167 | components_.clear(); |
| 168 | |
Jeff Thompson | 443398d | 2013-07-02 19:45:46 -0700 | [diff] [blame] | 169 | string uri = uri_cstr; |
| 170 | trim(uri); |
| 171 | if (uri.size() == 0) |
| 172 | return; |
| 173 | |
| 174 | size_t iColon = uri.find(':'); |
| 175 | if (iColon != string::npos) { |
| 176 | // Make sure the colon came before a '/'. |
| 177 | size_t iFirstSlash = uri.find('/'); |
| 178 | if (iFirstSlash == string::npos || iColon < iFirstSlash) { |
| 179 | // Omit the leading protocol such as ndn: |
| 180 | uri.erase(0, iColon + 1); |
| 181 | trim(uri); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | // Trim the leading slash and possibly the authority. |
| 186 | if (uri[0] == '/') { |
| 187 | if (uri.size() >= 2 && uri[1] == '/') { |
| 188 | // Strip the authority following "//". |
| 189 | size_t iAfterAuthority = uri.find('/', 2); |
| 190 | if (iAfterAuthority == string::npos) |
| 191 | // Unusual case: there was only an authority. |
| 192 | return; |
| 193 | else { |
| 194 | uri.erase(0, iAfterAuthority + 1); |
| 195 | trim(uri); |
| 196 | } |
| 197 | } |
| 198 | else { |
| 199 | uri.erase(0, 1); |
| 200 | trim(uri); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | size_t iComponentStart = 0; |
| 205 | |
| 206 | // Unescape the components. |
| 207 | while (iComponentStart < uri.size()) { |
| 208 | size_t iComponentEnd = uri.find("/", iComponentStart); |
| 209 | if (iComponentEnd == string::npos) |
| 210 | iComponentEnd = uri.size(); |
| 211 | |
Jeff Thompson | 46411c9 | 2013-09-13 19:31:25 -0700 | [diff] [blame] | 212 | Blob component = Component::makeFromEscapedString(&uri[0], iComponentStart, iComponentEnd); |
| 213 | // Ignore illegal components. This also gets rid of a trailing '/'. |
| 214 | if (component) |
| 215 | components_.push_back(Component(component)); |
Jeff Thompson | 443398d | 2013-07-02 19:45:46 -0700 | [diff] [blame] | 216 | |
| 217 | iComponentStart = iComponentEnd + 1; |
| 218 | } |
| 219 | } |
| 220 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 221 | void |
| 222 | Name::get(struct ndn_Name& nameStruct) const |
Jeff Thompson | 4881511 | 2013-06-28 18:22:48 -0700 | [diff] [blame] | 223 | { |
Jeff Thompson | 016ed64 | 2013-07-02 14:39:06 -0700 | [diff] [blame] | 224 | if (nameStruct.maxComponents < components_.size()) |
| 225 | throw runtime_error("nameStruct.maxComponents must be >= this name getNComponents()"); |
| 226 | |
| 227 | nameStruct.nComponents = components_.size(); |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 228 | for (size_t i = 0; i < nameStruct.nComponents; ++i) |
Jeff Thompson | 016ed64 | 2013-07-02 14:39:06 -0700 | [diff] [blame] | 229 | components_[i].get(nameStruct.components[i]); |
Jeff Thompson | 4881511 | 2013-06-28 18:22:48 -0700 | [diff] [blame] | 230 | } |
| 231 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 232 | void |
| 233 | Name::set(const struct ndn_Name& nameStruct) |
Jeff Thompson | b468c31 | 2013-07-01 17:50:14 -0700 | [diff] [blame] | 234 | { |
| 235 | clear(); |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 236 | for (size_t i = 0; i < nameStruct.nComponents; ++i) |
Jeff Thompson | 9303453 | 2013-10-08 11:52:43 -0700 | [diff] [blame] | 237 | addComponent(nameStruct.components[i].value.value, nameStruct.components[i].value.length); |
Jeff Thompson | b468c31 | 2013-07-01 17:50:14 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Jeff Thompson | 26b0d79 | 2013-09-23 16:19:01 -0700 | [diff] [blame] | 240 | Name& |
| 241 | Name::append(const Name& name) |
| 242 | { |
| 243 | if (&name == this) |
| 244 | // Copying from this name, so need to make a copy first. |
| 245 | return append(Name(name)); |
| 246 | |
| 247 | for (size_t i = 0; i < name.components_.size(); ++i) |
| 248 | components_.push_back(name.components_[i]); |
| 249 | |
| 250 | return *this; |
| 251 | } |
| 252 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 253 | std::string |
| 254 | Name::toUri() const |
Jeff Thompson | e606351 | 2013-07-01 15:11:28 -0700 | [diff] [blame] | 255 | { |
Jeff Thompson | 4b2479a | 2013-07-02 15:37:39 -0700 | [diff] [blame] | 256 | if (components_.size() == 0) |
| 257 | return "/"; |
| 258 | |
| 259 | ostringstream result; |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 260 | for (size_t i = 0; i < components_.size(); ++i) { |
Jeff Thompson | 4b2479a | 2013-07-02 15:37:39 -0700 | [diff] [blame] | 261 | result << "/"; |
Jeff Thompson | 9bdb3b2 | 2013-09-12 12:42:13 -0700 | [diff] [blame] | 262 | toEscapedString(*components_[i].getValue(), result); |
Jeff Thompson | e606351 | 2013-07-01 15:11:28 -0700 | [diff] [blame] | 263 | } |
| 264 | |
Jeff Thompson | 4b2479a | 2013-07-02 15:37:39 -0700 | [diff] [blame] | 265 | return result.str(); |
Jeff Thompson | e606351 | 2013-07-01 15:11:28 -0700 | [diff] [blame] | 266 | } |
| 267 | |
Jeff Thompson | d0159d7 | 2013-09-23 13:34:15 -0700 | [diff] [blame] | 268 | Name |
| 269 | Name::getSubName(size_t iStartComponent, size_t nComponents) const |
| 270 | { |
| 271 | Name result; |
| 272 | |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 273 | size_t iEnd = iStartComponent + nComponents; |
| 274 | for (size_t i = iStartComponent; i < iEnd && i < components_.size(); ++i) |
Jeff Thompson | d0159d7 | 2013-09-23 13:34:15 -0700 | [diff] [blame] | 275 | result.components_.push_back(components_[i]); |
| 276 | |
| 277 | return result; |
| 278 | } |
| 279 | |
| 280 | Name |
| 281 | Name::getSubName(size_t iStartComponent) const |
| 282 | { |
| 283 | Name result; |
| 284 | |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 285 | for (size_t i = iStartComponent; i < components_.size(); ++i) |
Jeff Thompson | d0159d7 | 2013-09-23 13:34:15 -0700 | [diff] [blame] | 286 | result.components_.push_back(components_[i]); |
| 287 | |
| 288 | return result; |
| 289 | } |
| 290 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 291 | bool |
Jeff Thompson | 3c2ab01 | 2013-10-02 14:18:16 -0700 | [diff] [blame] | 292 | Name::equals(const Name& name) const |
| 293 | { |
| 294 | if (components_.size() != name.components_.size()) |
| 295 | return false; |
| 296 | |
| 297 | for (size_t i = 0; i < components_.size(); ++i) { |
| 298 | if (*components_[i].getValue() != *name.components_[i].getValue()) |
| 299 | return false; |
| 300 | } |
| 301 | |
| 302 | return true; |
| 303 | } |
| 304 | |
| 305 | bool |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 306 | Name::match(const Name& name) const |
Jeff Thompson | cc35cd4 | 2013-08-20 12:23:14 -0700 | [diff] [blame] | 307 | { |
| 308 | // Imitate ndn_Name_match. |
| 309 | |
| 310 | // This name is longer than the name we are checking it against. |
| 311 | if (components_.size() > name.components_.size()) |
Jeff Thompson | 3c2ab01 | 2013-10-02 14:18:16 -0700 | [diff] [blame] | 312 | return false; |
Jeff Thompson | cc35cd4 | 2013-08-20 12:23:14 -0700 | [diff] [blame] | 313 | |
| 314 | // Check if at least one of given components doesn't match. |
Jeff Thompson | 3c2ab01 | 2013-10-02 14:18:16 -0700 | [diff] [blame] | 315 | for (size_t i = 0; i < components_.size(); ++i) { |
| 316 | if (*components_[i].getValue() != *name.components_[i].getValue()) |
Jeff Thompson | cc35cd4 | 2013-08-20 12:23:14 -0700 | [diff] [blame] | 317 | return false; |
| 318 | } |
| 319 | |
| 320 | return true; |
| 321 | } |
| 322 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 323 | void |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 324 | Name::toEscapedString(const vector<uint8_t>& value, ostringstream& result) |
Jeff Thompson | ec7789a | 2013-08-21 11:08:36 -0700 | [diff] [blame] | 325 | { |
| 326 | bool gotNonDot = false; |
| 327 | for (unsigned i = 0; i < value.size(); ++i) { |
| 328 | if (value[i] != 0x2e) { |
| 329 | gotNonDot = true; |
| 330 | break; |
| 331 | } |
| 332 | } |
| 333 | if (!gotNonDot) { |
| 334 | // Special case for component of zero or more periods. Add 3 periods. |
| 335 | result << "..."; |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 336 | for (size_t i = 0; i < value.size(); ++i) |
Jeff Thompson | ec7789a | 2013-08-21 11:08:36 -0700 | [diff] [blame] | 337 | result << '.'; |
| 338 | } |
| 339 | else { |
| 340 | // In case we need to escape, set to upper case hex and save the previous flags. |
| 341 | ios::fmtflags saveFlags = result.flags(ios::hex | ios::uppercase); |
| 342 | |
Jeff Thompson | 97223af | 2013-09-24 17:01:27 -0700 | [diff] [blame] | 343 | for (size_t i = 0; i < value.size(); ++i) { |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 344 | uint8_t x = value[i]; |
Jeff Thompson | ec7789a | 2013-08-21 11:08:36 -0700 | [diff] [blame] | 345 | // Check for 0-9, A-Z, a-z, (+), (-), (.), (_) |
| 346 | if (x >= 0x30 && x <= 0x39 || x >= 0x41 && x <= 0x5a || |
| 347 | x >= 0x61 && x <= 0x7a || x == 0x2b || x == 0x2d || |
| 348 | x == 0x2e || x == 0x5f) |
| 349 | result << x; |
| 350 | else { |
| 351 | result << '%'; |
| 352 | if (x < 16) |
| 353 | result << '0'; |
| 354 | result << (unsigned int)x; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | // Restore. |
| 359 | result.flags(saveFlags); |
| 360 | } |
| 361 | } |
| 362 | |
Jeff Thompson | 6653b0b | 2013-09-23 12:32:39 -0700 | [diff] [blame] | 363 | string |
Jeff Thompson | 10ad12a | 2013-09-24 16:19:11 -0700 | [diff] [blame] | 364 | Name::toEscapedString(const vector<uint8_t>& value) |
Jeff Thompson | 6653b0b | 2013-09-23 12:32:39 -0700 | [diff] [blame] | 365 | { |
| 366 | ostringstream result; |
| 367 | toEscapedString(value, result); |
| 368 | return result.str(); |
| 369 | } |
| 370 | |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 371 | } |