X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=common%2FJSON_Tokenizer.hh;h=e6d5b95cacb3a967cc57cbed923c9c8ee0159899;hb=3a70874a1ed2d6b0038e93704acf65b443e488b4;hp=6775c69a12cc42934b5239f83ca33c7e3f35abb3;hpb=970ed7958b7d4e41d36fd5904d645aa3aec9f992;p=deliverable%2Ftitan.core.git diff --git a/common/JSON_Tokenizer.hh b/common/JSON_Tokenizer.hh index 6775c69..e6d5b95 100644 --- a/common/JSON_Tokenizer.hh +++ b/common/JSON_Tokenizer.hh @@ -1,3 +1,16 @@ +/****************************************************************************** + * Copyright (c) 2000-2016 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Balasko, Jeno + * Baranyi, Botond + * + ******************************************************************************/ + #ifndef JSON_TOKENIZER_HH #define JSON_TOKENIZER_HH @@ -150,11 +163,24 @@ public: * @return The number of characters added to the JSON document */ int put_next_token(json_token_t p_token, const char* p_token_str = 0); + /** Adds raw data to the end of the buffer. + * @param p_data [in] Pointer to the beginning of the data + * @param p_len [in] Length of the data in bytes */ + void put_raw_data(const char* p_data, size_t p_len); + }; // class JSON_Tokenizer // A dummy JSON tokenizer, use when there is no actual JSON document static JSON_Tokenizer DUMMY_BUFFER; +/** Converts a string into a JSON string by replacing all control characters + * with JSON escape sequences, if available, or with the \uHHHH escape sequence. + * The string is also wrapped inside a set of double quotes and all double quotes + * and backslash characters are double-escaped. + * + * Returns an expstring, that needs to be freed. */ +extern char* convert_to_json_string(const char* str); + #endif /* JSON_TOKENIZER_HH */