Commit Graph

254 Commits

Author SHA1 Message Date
Tomasz Sowa 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

added methods for manipulating with child spaces:
TableType * find_child_space_table()
bool child_spaces_empty()
size_t child_spaces_size()

Space * find_child_space(size_t table_index)
Space & add_child_space(const wchar_t * space_name)
Space & add_child_space(const std::wstring & space_name)

std::wstring * find_child_space_name()
std::wstring get_child_space_name()
bool is_child_space_name(const wchar_t * name)

added additional methods:
size_t str_size()
size_t wstr_size()
size_t object_size()
size_t table_size()
2021-05-21 17:13:11 +02:00
Tomasz Sowa c11aa78335 changed: names of methods in SpaceParser: PascalCase to snake_case 2021-05-21 04:42:55 +02:00
Tomasz Sowa 6e4a0f68b3 removed from SpaceParser: SetDefault(), SkipEmpty(bool skip) and UseEscapeChar(bool escape) methods 2021-05-21 04:28:31 +02:00
Tomasz Sowa 82a21f6d85 removed: SpaceParser::SetSpace(...) methods, now ParseJSON/Space(...) methods take a space as an argument 2021-05-21 01:33:01 +02:00
Tomasz Sowa 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
2021-05-21 00:26:19 +02:00
Tomasz Sowa 59d4c9a9c8 changed utf8 functions: PascalCase to snake_case 2021-05-21 00:24:56 +02:00
Tomasz Sowa b574289054 namespace PT renamed to pt 2021-05-20 16:11:12 +02:00
Tomasz Sowa 6f50626dda fixed another memory leak in CSVParser::parse() (similar like before) 2021-05-19 22:34:10 +02:00
Tomasz Sowa f8d24de386 fixed memory leak in CSVParser::parse() - a Space struct was allocated but never freed 2021-05-19 22:31:18 +02:00
Tomasz Sowa 604b47db32 added move semantics to Space class
added methods:
Space(Space && space);
Space & operator=(Space && space);
void set(const Space & space);
void set(Space && space);
Space & add(const Space & space);
Space & add(Space && space);
Space & add(const wchar_t * field, const Space & space);
Space & add(const wchar_t * field, Space && space);
Space & add(const std::wstring & field, const Space & space);
Space & add(const std::wstring & field, Space && space);
2021-05-19 22:24:53 +02:00
Tomasz Sowa 430822bad8 make depend 2021-05-19 03:26:57 +02:00
Tomasz Sowa 0ea5497094 added CSVParser - a csv parser 2021-05-19 03:26:46 +02:00
Tomasz Sowa ae1d25d5f3 removed old not used variable from Space 2021-05-19 03:23:18 +02:00
Tomasz Sowa e0565813de removed *.a from .gitignore 2021-05-18 23:58:46 +02:00
Tomasz Sowa db93586c0e make depend 2021-05-18 23:58:17 +02:00
Tomasz Sowa ad4e8078ae MainSpaceParser class has been renamed to MainOptionsParser 2021-05-18 23:57:58 +02:00
Tomasz Sowa 96e60c526f moved files: mainspaceparser/mainspaceparser.(h|cpp) -> mainoptions/mainoptionsparser.(h|cpp) 2021-05-18 23:50:42 +02:00
Tomasz Sowa a5c8833452 added tests for MainSpaceParser 2021-05-18 22:57:26 +02:00
Tomasz Sowa 91300bb245 make depend 2021-05-17 03:21:00 +02:00
Tomasz Sowa fe82f63efb changed the way of building in Makefiles 2021-05-17 03:20:51 +02:00
Tomasz Sowa da6a36a205 start creating tests for MainSpaceParser 2021-05-17 03:19:47 +02:00
Tomasz Sowa 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
2021-05-17 03:09:21 +02:00
Tomasz Sowa 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
2021-05-17 03:08:32 +02:00
Tomasz Sowa 3d6c4e27c0 added .editorconfig file with tab style and tab size information
2021-05-15 18:34:10 +02:00
Tomasz Sowa 1260b303bc added ./m to .gitignore 2021-05-10 21:24:37 +02:00
Tomasz Sowa d3dd74b3d4 added tests/tests to .gitignore 2021-05-10 20:16:54 +02:00
Tomasz Sowa 7bdc4d2fc7 added global Makefile 2021-05-10 20:10:10 +02:00
Tomasz Sowa ce81670bb6 added 'tests' directory with tests for the pikotools library
currently only tests for convert/text functions
2021-05-10 20:08:50 +02:00
Tomasz Sowa cd9e501f48 make depend 2021-05-10 20:08:19 +02:00
Tomasz Sowa b3cd4d5f7f removed definition of CXX and CXXFLAGS from Makefile 2021-05-10 20:07:08 +02:00
Tomasz Sowa adee7d134f added macro PT_HAS_MORM in Log class where operator<<(morm::Model & model) is used 2021-05-10 20:05:55 +02:00
Tomasz Sowa 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'
2021-05-10 20:04:12 +02:00
Tomasz Sowa 3984c29fbf moved all directories to src subdirectory 2021-05-09 20:11:37 +02:00
Tomasz Sowa 127f26884e make depend 2021-05-08 22:40:06 +02:00
Tomasz Sowa b055c46ae8 fixed #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'
2021-05-08 22:37:31 +02:00
Tomasz Sowa 463cec3283 fixed #2: Procedures for reading an utf8 string incorrectly read some utf-8 characters.
Those characters were treated as invalid characters.

UTF8ToInt_FirstOctet incorrectly checked if the first octed is zero (after removing first bits).
This is a case only if the utf-8 character consists of two bytes. For 3 or 4 bytes
the first part can have all bits equal zero.
2021-05-07 15:53:19 +02:00
Tomasz Sowa 96eedd9be9 added support for morm::Model to Log:
Log & operator<<(morm::Model & model);
but we need some kind of a macro to allow this
2021-04-30 01:17:47 +02:00
Tomasz Sowa f572250572 make depend 2021-04-30 01:17:29 +02:00
Tomasz Sowa 16f6bdb358 fixed: Space::has_value(...) incorrectly compared strings 2021-04-14 17:42:57 +02:00
Tomasz Sowa 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)
added to Space: some methods for searching a field with ignoring case:
Space * get_object_field_nc(const wchar_t * field)
Space * get_object_field_nc(const std::wstring & field);
const Space * get_object_field_nc(const wchar_t * field) const;
const Space * get_object_field_nc(const std::wstring & field) const;
2021-04-12 18:49:34 +02:00
Tomasz Sowa 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);
2021-04-09 17:49:44 +02:00
Tomasz Sowa a1e8f13f46 fixed: calculating buffer length in Space: sizeof(char) -> sizeof(wchar_t) 2021-04-08 17:40:30 +02:00
Tomasz Sowa 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)
2021-04-08 17:16:37 +02:00
Tomasz Sowa 0aeac12fa0 make depend 2021-04-08 17:02:27 +02:00
Tomasz Sowa 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
2021-03-18 17:55:30 +01:00
Tomasz Sowa 539faa4976 changed the indentation algorithm when pretty printing the space format (no visual changes) 2021-03-18 17:28:11 +01:00
Tomasz Sowa 679b9e6173 added some indentation when printing 'pretty Space format' 2021-03-18 17:19:36 +01:00
Tomasz Sowa 4119461f8e fixed: when reading a non-escaped space token we should check whether a delimiter was escaped or not
also a '#' was not tested
2021-03-18 16:26:56 +01:00
Tomasz Sowa db5e516564 added to Space: serialization do Space format 2021-03-18 15:33:43 +01:00
Tomasz Sowa 1baf5042fe removed: SpaceToJson 2021-03-17 18:35:48 +01:00