819c49e638
added class Stream (textstream/stream.h) which acts as a base class for TextStream TextStream is making conversions wide/utf8 now
tomasz.sowa2021-06-20 14:13:23 +02:00
865837d911
fixed in Space::find_child_space_const(...) - clang address sanitizer reports stack-use-after-scope we have got a reference to a Space instead of a pointer and a local object was created and returned
tomasz.sowa2021-06-18 18:52:24 +02:00
55f6bda3ab
Merge branch 'api2021' added support for surrogate pairs when reading \uHHHH format added support to parse \u{H...} format (only if parsing Space format) and some fixes
tomasz.sowa2021-06-14 13:51:53 +02:00
4d70ae9e87
fixed: using size() when serializing strings - this allows to serialize a string which contain a null character fixed: printing null character in space format: \u0000 (before was \0 which is not correct in json) fixed: in serialize_string_buffer(const char * input_str, ...) a temporary fixed was used when copying input string added support for surrogate pairs when reading \uHHHH format added support to parse \u{H...} format (only if parsing Space format)
tomasz.sowa2021-06-14 13:48:32 +02:00
848cdf9c03
Merge pull request 'api2021 part I' (#4) from api2021 into master
tomasz.sowa2021-05-27 10:37:35 +02:00
49c2b478c0
fixed return value from Space::add_child_space()
tomasz.sowa2021-05-21 17:32:10 +02:00
5ce36ea844
changed the way how child_spaces are created in Space class - removed child_spaces and name pointers - now a table with child spaces is created under "child_spaces" object field - a name of the child space is stored in "name" field of the child object
tomasz.sowa2021-05-21 17:13:11 +02:00
c11aa78335
changed: names of methods in SpaceParser: PascalCase to snake_case
tomasz.sowa2021-05-21 04:42:55 +02:00
6e4a0f68b3
removed from SpaceParser: SetDefault(), SkipEmpty(bool skip) and UseEscapeChar(bool escape) methods
tomasz.sowa2021-05-21 04:28:31 +02:00
82a21f6d85
removed: SpaceParser::SetSpace(...) methods, now ParseJSON/Space(...) methods take a space as an argument
tomasz.sowa2021-05-21 01:33:01 +02:00
abeca010cc
fixed: SpaceParser was using space->set_empty_object() when parsing a space and it cleared all values if not an empty object was provided to the set_space() method
tomasz.sowa2021-05-21 00:26:19 +02:00
59d4c9a9c8
changed utf8 functions: PascalCase to snake_case
tomasz.sowa2021-05-21 00:24:56 +02:00
fe82f63efb
changed the way of building in Makefiles
tomasz.sowa2021-05-17 03:20:51 +02:00
da6a36a205
start creating tests for MainSpaceParser
tomasz.sowa2021-05-17 03:19:47 +02:00
ac691bccb7
updated MainSpaceParser to the new Space format, changed api to snake case now we can: - parse short options, those beginning with a hypnen '-' - parse long options, those beginning with two hyphens '--' - long options can have arguments in two forms: - either with an equal sign, e.g.: --opion-name=argument - or with a space, e.g: --option argument in the latter case we can have more than one argument, e.g: --option argument1 argument2 - parse non-option arguments, those after two hyphens to the end of a string, e.g: -- arg1 arg2
tomasz.sowa2021-05-17 03:09:21 +02:00
77d7bb5e64
fixed in Space: set_empty_string(), set_empty_wstring(), set_empty_table() and set_empty_object() didn't clear its object if the same kind of object already existed
tomasz.sowa2021-05-17 03:08:32 +02:00
ce81670bb6
added 'tests' directory with tests for the pikotools library currently only tests for convert/text functions
tomasz.sowa2021-05-10 20:08:50 +02:00
b3cd4d5f7f
removed definition of CXX and CXXFLAGS from Makefile
tomasz.sowa2021-05-10 20:07:08 +02:00
adee7d134f
added macro PT_HAS_MORM in Log class where operator<<(morm::Model & model) is used
tomasz.sowa2021-05-10 20:05:55 +02:00
7abe4b340a
changes in convert/text functions - changed function names: PascalCase to snake_case - templates functions moved to a seperate file (text_private.h) - as a public api only available functions with char/wchar_t/std::string/std::wstring - ToLower(...) changed to to_lower_emplace(...), similar ToUpper(...) to to_upper_emplace(...) - added functions: std::string to_lower(const std::string & str); std::string to_upper(const std::string & str); and with std::wstring too - functions with postfix 'NoCase' changed to 'nc'
tomasz.sowa2021-05-10 20:04:12 +02:00
3984c29fbf
moved all directories to src subdirectory
tomasz.sowa2021-05-09 20:11:37 +02:00
b055c46ae8fixed#3: CompareNoCase incorrectly returned that string1 is greater than string2 for some characters when converting from 'char' to 'int' we should first convert to 'unsigned char' and then to 'int'
tomasz.sowa2021-05-08 22:37:31 +02:00
463cec3283fixed#2: Procedures for reading an utf8 string incorrectly read some utf-8 characters. Those characters were treated as invalid characters.
tomasz.sowa2021-05-07 15:53:19 +02:00
96eedd9be9
added support for morm::Model to Log: Log & operator<<(morm::Model & model); but we need some kind of a macro to allow this
tomasz.sowa2021-04-30 01:17:47 +02:00
297940ff7c
fix in SpaceParser when parsing json format: floating point values such as 1.123e+01 where not correctly parsed ('+' character was not correctly parsed)
tomasz.sowa2021-04-12 18:49:34 +02:00
5d34db5fcf
added to Space: - methods for testing a string value if a Space is a string or a table: bool has_value(const char * val) const; bool has_value(const std::string & val) const; bool has_value(const wchar_t * val) const; bool has_value(const std::wstring & val) const; - methods for testing a string value in an object (testing a string or a table): bool has_value(const wchar_t * field, const char * val) const; bool has_value(const wchar_t * field, const std::string & val) const; bool has_value(const wchar_t * field, const wchar_t * val) const; bool has_value(const wchar_t * field, const std::wstring & val) const; - methods for removing a child space: void remove_child_space(const wchar_t * name); void remove_child_space(const std::wstring & name); void remove_child_space(size_t index);
tomasz.sowa2021-04-09 17:49:44 +02:00
a2339eed34
fixed: in Space: pointers 'name' and 'child_spaces' were not correctly initialized in cctors added in Space: - some methods for adding values to an object, such as: Space & Space::add(const std::wstring & field, bool val) (bool, short, int, long, long long etc.) - methods for creating lists: void Space::to_list(std::list<std::string> & output_list, bool clear_list) const bool Space::to_list(const wchar_t * field, std::list<std::string> & output_list, bool clear_list) const - methods for converting a value from an object field: bool Space::to_bool(const wchar_t * field, bool default_value) const - methods for testing strings: bool Space::is_equal(const char * val) const bool Space::is_equal(const std::string & val) const bool Space::is_equal(const wchar_t * val) const bool Space::is_equal(const std::wstring & val) const - methods to get the raw pointer to a value from an object, such as: bool * Space::get_bool(const wchar_t * field) float * Space::get_float(const wchar_t * field) - methods for finding a child space (used in Space format only) Space * Space::find_child_space(const wchar_t * name) Space & Space::find_add_child_space(const wchar_t * name)
tomasz.sowa2021-04-08 17:16:37 +02:00
1c643a08b0
added a test whether we have reach the end of the input string without this such an input json (incorrect json string as there is no {} characters): "key": "value" would be parsed correctly: "key" would be parsed and the rest would be skipped
tomasz.sowa2021-03-18 17:55:30 +01:00
539faa4976
changed the indentation algorithm when pretty printing the space format (no visual changes)
tomasz.sowa2021-03-18 17:28:11 +01:00
679b9e6173
added some indentation when printing 'pretty Space format'
tomasz.sowa2021-03-18 17:19:36 +01:00
4119461f8e
fixed: when reading a non-escaped space token we should check whether a delimiter was escaped or not also a '#' was not tested
tomasz.sowa2021-03-18 16:26:56 +01:00
db5e516564
added to Space: serialization do Space format
tomasz.sowa2021-03-18 15:33:43 +01:00
6e169f7650
added to JSONToSpaceParser: possibility to parse the Space format renamed: ParseFile() -> ParseJSONFile() added: ParseSpaceFile(), ParseJSON(), ParseSpace()
tomasz.sowa2021-03-17 18:24:50 +01:00
31f7bdb857
added to Space: child_spaces and a name of a Space
tomasz.sowa2021-03-17 18:09:47 +01:00
5b5a1dfbb6
changed the way how the library is built - now there is only one Makefile in the root directory and we have only one pikotools.a lib file - removed: mainparser
tomasz.sowa2021-03-17 13:16:01 +01:00
0c0f15ab8a
changed: JSONToSpaceParser can parse json string/file to the new Space format now (some minor chars escaping not ready yet)
tomasz.sowa2021-03-16 18:40:14 +01:00
ba7fa1c195
fixed: in serialize_json_double(): the buffer length was calculated incorrectly: sizeof(char) changed to sizeof(wchar_t) added to Space struct: void set_null(); void set_empty_string(); void set_empty_wstring(); void set_empty_table(); void set_empty_object(); void clear();
tomasz.sowa2021-03-16 18:36:59 +01:00
bc9e4a3844
use PT::WideStreamToUTF8() instead of PT::WideToUTF8() for a moment
tomasz.sowa2021-03-16 18:35:08 +01:00
f65d934e8c
start working on a new version of Space struct - better support for JSON format now we have a correct model, some methods for setting/getting values and serialization to json (no serialization to Space yet)
tomasz.sowa2021-03-15 19:36:49 +01:00
fac3a7eb71
reorganization in utf8 - utf8 auxiliary functions moved to utf8_private.h file - in utf8.h are shown only functions available for consumers - template functions has been moved to utf8_template.h (in utf8.h are only declarations) utf8_template.h is included at the end of utf8.h - functions which take std::ostream changed to template (the stream is a template argument now)
tomasz.sowa2021-03-15 19:34:51 +01:00
effe9be0a3
added: typedef with char_type to TextStreamBase
tomasz.sowa2021-03-15 19:27:03 +01:00
448ad42961
added: Toa() methods for converting to a string (new file convert/inttostr.cpp): template<class StringType> void Toa(unsigned long long value, StringType & res, bool clear_string = true, int base = 10); template<class StringType> void Toa(long long value, StringType & res, bool clear_string = true, int base = 10); template<class StringType> void Toa(unsigned long value, StringType & res, bool clear_string = true, int base = 10); template<class StringType> void Toa(long value, StringType & res, bool clear_string = true, int base = 10); template<class StringType> void Toa(unsigned int value, StringType & res, bool clear_string = true, int base = 10); template<class StringType> void Toa(int value, StringType & res, bool clear_string = true, int base = 10); template<class StringType> void Toa(unsigned short value, StringType & res, bool clear_string = true, int base = 10); template<class StringType> void Toa(short value, StringType & res, bool clear_string = true, int base = 10); std::wstring Toa(unsigned long long value, int base); std::wstring Toa(long long value, int base); std::wstring Toa(unsigned long value, int base); std::wstring Toa(long value, int base); std::wstring Toa(unsigned int value, int base); std::wstring Toa(int value, int base); std::wstring Toa(unsigned short value, int base); std::wstring Toa(short value, int base);
tomasz.sowa2021-03-03 02:24:30 +01:00
49e49d1246
fixed: operator==() and operator!=() in iterators in MemBuffer<> template did not have 'const' modifier and there was an error when compiling with clang with -std=c++20 flag
tomasz.sowa2021-02-17 16:53:19 +01:00
aff698d155
a comment added in Log::~Log(), we have to consider whether calling save_log_and_clear() in ~Log() should be removed
tomasz.sowa2021-02-17 16:51:06 +01:00
a29cb45f6a
added: in FileLog::save_log(): test whether synchro_lock() has returned true
tomasz.sowa2019-09-25 16:12:10 +00:00
7309c7817d
in spacetojson: if there is only one item then do not put it in the table
tomasz.sowa2019-02-19 13:08:07 +00:00
c2e63f9290
added: to Date: support for parsing timezone offsets
tomasz.sowa2019-01-31 20:56:40 +00:00
5a63a8c0ec
added: to Log: IntMinWidth(size_t min_width) minimal width for integers added: to Log: operator<<(long long s) added: to TextStreamBase: operator<<(long long); operator<<(unsigned long long); int_min_width(size_t min_width); // minimal width for integers
tomasz.sowa2019-01-28 18:06:18 +00:00
e9df044f9e
added to convert: PatternReplacer for replacing parameters in patterns e.g. Replace("param %0", "first param")
tomasz.sowa2019-01-07 03:29:34 +00:00
6c4a76baad
changed in utf8: functions taking WTextStream now take a template TextStreamBase
tomasz.sowa2018-11-24 17:09:25 +00:00
8b3ae14d9a
fixed: FileLog didn't save an utf8 sequence
tomasz.sowa2018-11-24 10:47:13 +00:00
e971e1ef9b
changed in logger: renamed Logger -> Log this class has an api (<< operators) for taking what should be put to the log file as the buffer is used WTextStream which should be allocated elsewhere added: FileLog - this class saves to a file log
tomasz.sowa2018-11-23 17:07:52 +00:00