Commit Graph

51 Commits

Author SHA1 Message Date
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 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
Tomasz Sowa ba82ac7cbe renamed: JSONToSpaceParser -> SpaceParser 2021-03-17 18:33:41 +01:00
Tomasz Sowa 961a02ab39 removed: old SpaceParser 2021-03-17 18:26:13 +01:00
Tomasz Sowa 6e169f7650 added to JSONToSpaceParser: possibility to parse the Space format
renamed: ParseFile() -> ParseJSONFile()
added: ParseSpaceFile(), ParseJSON(), ParseSpace()
2021-03-17 18:24:50 +01:00
Tomasz Sowa 31f7bdb857 added to Space: child_spaces and a name of a Space 2021-03-17 18:09:47 +01:00
Tomasz Sowa 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
2021-03-17 13:16:01 +01:00
Tomasz Sowa 61291cf7ad make depend 2021-03-16 18:43:34 +01:00
Tomasz Sowa 0c0f15ab8a changed: JSONToSpaceParser can parse json string/file to the new Space format now
(some minor chars escaping not ready yet)
2021-03-16 18:40:14 +01:00
Tomasz Sowa 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();
2021-03-16 18:36:59 +01:00
Tomasz Sowa 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)
2021-03-15 19:36:49 +01:00
Tomasz Sowa 7ccd435e2c make depend 2021-03-15 19:36:04 +01:00
Tomasz Sowa df88d4c0fc temporarily blocked for compilation: mainspaceparser, jsontospaceparser, spaceparser, spacetojson 2021-03-15 19:25:04 +01:00
Tomasz Sowa 7309c7817d in spacetojson: if there is only one item then do not put it in the table
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1170 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-02-19 13:08:07 +00:00
Tomasz Sowa e9df044f9e added to convert: PatternReplacer
for replacing parameters in patterns e.g. Replace("param %0", "first param")




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1163 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-01-07 03:29:34 +00:00
Tomasz Sowa da4ed9c1f8 added to utf8:
bool UTF8ToWide(const char * utf8, size_t utf8_len, WTextStream & res, bool clear = true, int mode = 1);
bool UTF8ToWide(const char * utf8,                  WTextStream & res, bool clear = true, int mode = 1);
bool UTF8ToWide(const std::string & utf8,           WTextStream & res, bool clear = true, int mode = 1);
bool UTF8ToWide(std::istream & utf8,                WTextStream & res, bool clear = true, int mode = 1);

void WideToUTF8(PT::WTextStream & buffer,                       std::string & utf8,  bool clear = true, int mode = 1);
void WideToUTF8(PT::WTextStream & buffer,                       std::ostream & utf8, int mode = 1);

these functions need some testing yet




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1156 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-11-24 13:30:45 +00:00
Tomasz Sowa 040eb12c8b added: to convert/text
wchar_t ToLower(wchar_t c)
       wchar_t ToUpper(wchar_t c)
       void ToLower(std::wstring & s)
       void ToUpper(std::wstring & s)
       
       template<class StringType1, class StringType2>
       bool EqualNoCase(const StringType1 * str1, const StringType2 * str2)

       template<class StringType1, class StringType2>
       bool EqualNoCase(const StringType1 & str1, const StringType2 & str2)

       template<class StringType1, class StringType2>
       bool EqualNoCase(const StringType1 * str1_begin, const StringType1 * str1_end, const StringType2 * str2)

added: to space:
       Value * GetValueNoCase(const wchar_t * name);
       Value * GetValueNoCase(const std::wstring & name);
       const Value * GetValueNoCase(const wchar_t * name) const;
       const Value * GetValueNoCase(const std::wstring & name) const;

       
       



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1111 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-05-25 17:12:28 +00:00
Tomasz Sowa 72a510ce71 fixed: JSONToSpaceParser incorrectly read the last character from an UTF8 string (a last character before terminating zero char)
it caused a syntax error when parsing



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1101 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-26 16:36:15 +00:00
Tomasz Sowa dc0cd13178 some work in Space
- default value returned from TextRef()



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1083 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-16 22:55:58 +00:00
Tomasz Sowa c910e22c00 temporarily commented 'current_nested_level' in JSONtoSpaceParser
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1082 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-16 22:51:14 +00:00
Tomasz Sowa cb23304885 added: to methods Toull(), Toll(), Toul(), Toui(), Tol(), Toi()
a new parameter: bool allow_skip_whitechars default true
added:   new methods: Toull_b(), Toll_b(), Toul_b(), Toui_b(), Tol_b(), Toi_b()
         automatically detects the base (radix):
           4323 - base 10
           0122 - base 8  (string starts with 0)
           #fff - base 16 (string starts with #)
           &101 - base 2  (string starts with &)
added:   CharType * SkipWhiteFromBack(CharType * str, bool check_additional_chars = true, bool treat_new_line_as_white = true)
         skipping white characters from the end of a string
changed: Toll_b(), Toull_b(), Tol_b() and Toul_b() are used in Space now
         for methods ToInt() etc so we are able to use a different base now
changed: some work in Space (const correctness)
       




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1070 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-01-05 20:03:11 +00:00
Tomasz Sowa e24112b79b some work in Space API:
added: new GetValue() implementation
       Value * GetValue(const wchar_t * name)
       Value * GetValue(const std::wstring & name)
       const Value * GetValue(const wchar_t * name) const
       const Value * GetValue(const std::wstring & name) const
added: const correctness for Text() and TextA() methods
       std::wstring Text(...) const;
       std::string TextA(...) const;
added: TextA() with a wide second argument
       std::string TextA(const wchar_t * name, const wchar_t * def) const;
       std::string TextA(const std::wstring & name, const wchar_t * def) const;
       std::string TextA(const std::wstring & name, const std::wstring & def) const;
       




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1067 e52654a7-88a9-db11-a3e9-0013d4bc506e
2017-12-07 11:35:12 +00:00
Tomasz Sowa 7d51372844 added: functions for dealing with white characters:
bool IsWhite(wchar_t c, bool check_additional_chars, bool treat_new_line_as_white) (checking unicode white characters too)
       CharType * SkipWhite(CharType * str, bool check_additional_chars = true, bool treat_new_line_as_white = true)
       IsDigit(wchar_t c, int base, int * digit)

added: functions to converting from a string to an integer:
       unsigned long long Toull(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
       long long Toll(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
       unsigned long Toul(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
       unsigned int  Toui(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
       long          Tol(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)
       int           Toi(const CharType * str, int base = 10, const CharType ** after_str = 0, bool * was_overflow = 0)

changed: some work in Space (new Api)       
       now Text() methods returns std::wstring by value (before they were returned by reference)
       added std::wstring & TextRef() methods
       added unsigned int UInt(), unsigned long ULong() and LongLong() and ULongLong()
       GetValue() renamed to GetFirstValue()
       AText() renamed to TextA() and they return std::string by value now
       



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1066 e52654a7-88a9-db11-a3e9-0013d4bc506e
2017-12-05 16:32:21 +00:00
Tomasz Sowa cde990ba82 start changing the Space API
removed table_single from Space



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1065 e52654a7-88a9-db11-a3e9-0013d4bc506e
2017-06-27 16:51:55 +00:00
Tomasz Sowa d9b583df76 instead of directly using 'ar' program we are using the AR macro now
(which defaults to 'ar' if you do not define it)



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@991 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-11-12 04:11:28 +00:00
Tomasz Sowa d655c7c872 removed: svn:executable attribute from files
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@985 e52654a7-88a9-db11-a3e9-0013d4bc506e
2014-11-01 17:11:00 +00:00
Tomasz Sowa 28ea8f3c3e added: to membuffer:
template<typename in_item_type>
         void append(const in_item_type * item_array, size_t len);
         when adding values from item_array are casted to the type of the internal buffer
changed: some minor optimizations in Space (in Add() methods with WTextStream as an argument)
changed: removed following write() methods from TextStreamBase:
         TextStreamBase & write(const char * buf,    size_t len);
         TextStreamBase & write(const wchar_t * buf, size_t len);
         and added a template instead:
         template<typename in_buffer_type>
         TextStreamBase & write(const in_buffer_type * buf, size_t len);
         this allows to write char* buffer to TextStreamBase<wchar_t...> (and vice versa)
added:   two write() methods to TextStreamBase:
         write(const char * format, double val);
         write(const wchar_t * format, double val);
         converting double value to the text (format is the same as in snprintf)




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@448 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-11-28 22:21:10 +00:00
Tomasz Sowa 3cc5fd5e12 added: -I.. flag for Makefiles when compiling
changed: in SpaceToJSON::PrintToken():
         slash doesn't have to be escaped when serializing to JSON




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@444 e52654a7-88a9-db11-a3e9-0013d4bc506e
2013-10-15 23:53:57 +00:00
Tomasz Sowa 1e48455942 added: to Space:
bool HasValue(const wchar_t * name, const wchar_t * value);
       bool HasValue(const wchar_t * name, const std::wstring & value);
       bool HasValue(const std::wstring & name, const wchar_t * value);
       bool HasValue(const std::wstring & name, const std::wstring & value);
       useful when testing whether a value is in a list (or in simple table too)



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@433 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-10-17 19:55:16 +00:00
Tomasz Sowa 02abfe62fa changed: in SpaceParser: now we do not parse special characters when reading commentaries
so we can parse:
         # such a \n string
         beforehand this \n was treated as a new line character
         and the parser was returning syntax error when reading above 'string'



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@432 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-09-25 16:50:01 +00:00
Tomasz Sowa 5ad48470b6 added: to Space:
std::wstring & FindAdd(const WTextStream & name);
       std::wstring & Add(const wchar_t * name,        const WTextStream & value);
       std::wstring & Add(const std::wstring & name,   const WTextStream & value);
       std::wstring & Add(const WTextStream & name,    const WTextStream & value);




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@430 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-07-25 10:27:20 +00:00
Tomasz Sowa f8d5a962ed changed: rewritten the Serialize method in SpaceToJSON class
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@429 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-07-15 22:53:24 +00:00
Tomasz Sowa 2b88d011f6 updated: SpaceToJSON (not finished yet)
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@428 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-07-13 12:26:09 +00:00
Tomasz Sowa 2af6c28a54 added: JSONToSpaceParser -- a parser for JSON format to Space structure
added: SpaceToJSON -- a serializer from Space structure to JSON (not finished yet)



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@427 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-07-12 15:01:15 +00:00
Tomasz Sowa bff2ecb147 added: to Space:
const std::wstring * GetValue(const std::wstring & name) const;
       std::wstring & Add(const wchar_t * name,        size_t value);
       std::wstring & Add(const std::wstring & name,   size_t value);




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@418 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-06-26 23:20:59 +00:00
Tomasz Sowa e25bc826e7 changed: Date::SerializeDay outputs the date in a form of YYYY-MM-DD (before was: YYYY.MM.DD)
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@411 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-05-13 21:49:06 +00:00
Tomasz Sowa 5d9ce6e093 changed: in SpaceParser:
white characters can be escaped by '\ ' and in such a case this is not a delimiter
         (when reading single token)


git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@410 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-05-12 18:20:39 +00:00
Tomasz Sowa 11ddf0f6d9 fixed: in Space serializer: we have to escape more characters
fixed: in SpaceParser::ReadTokenSingle
       the delimiter can be only if the character was not escaped


git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@409 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-05-12 15:54:20 +00:00
Tomasz Sowa e195145394 changed: now in SpaceParser 'split_single' and utf8 are default
removed: some errors checking at the end of a line
         now we can have in the same line: value="option" value2="option2"



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@408 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-05-12 14:54:19 +00:00
Tomasz Sowa e620c8f95d changed: SpaceParser -- parser's engine has been rewritten
now we can map all strings to all strings
         documentation in space.h need to be updated yet


git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@407 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-05-10 21:16:19 +00:00
Tomasz Sowa 3280568594 added: Date structure -- represents year, month, day, hour, min, sec
with O(1) algorithm for converting from time_t (seconds from Unix epoch)


git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@405 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-05-05 15:08:04 +00:00
Tomasz Sowa 19da401bb0 changed Makefile dep
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@404 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-04-30 22:54:37 +00:00
Tomasz Sowa e15bae9fac changed: in space/spaceparser.cpp the correct include file (spaceparser.h now)
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@403 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-04-30 13:17:50 +00:00
Tomasz Sowa cd3a1b853f changed: class name: ConfParser -> SpaceParser
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@402 e52654a7-88a9-db11-a3e9-0013d4bc506e
2012-04-30 13:10:55 +00:00