Commit Graph

254 Commits

Author SHA1 Message Date
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 bc9e4a3844 use PT::WideStreamToUTF8() instead of PT::WideToUTF8() for a moment 2021-03-16 18:35:08 +01:00
Tomasz Sowa 4ef8f5a884 template<size_t stack_size, size_t heap_block_size> changed to template<typename StreamType> 2021-03-15 20:09:23 +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 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)
2021-03-15 19:34:51 +01:00
Tomasz Sowa effe9be0a3 added: typedef with char_type to TextStreamBase 2021-03-15 19:27:03 +01:00
Tomasz Sowa df88d4c0fc temporarily blocked for compilation: mainspaceparser, jsontospaceparser, spaceparser, spacetojson 2021-03-15 19:25:04 +01:00
Tomasz Sowa f771f12027 renamed: std::wstring Toa(...) -> std::wstring to_str(...)
added: std::string to_str(...)
2021-03-15 19:23:49 +01:00
Tomasz Sowa 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);
2021-03-03 02:24:30 +01:00
Tomasz Sowa d9a4fa34e2 added .gitignore file 2021-02-17 17:04:05 +01:00
Tomasz Sowa 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

/usr/home/tomek/roboczy/prog/web.ttmath.org/../pikotools/textstream/textstream.h:225:11: fatal error: use of overloaded operator '!=' is ambiguous (with operand types
      'PT::TextStreamBase<char, 256, 4096>::const_iterator' (aka 'PT::MemBuffer<char, 256, 4096>::const_iterator') and 'PT::TextStreamBase<char, 256, 4096>::const_iterator')
        for( ; i != end() ; ++i)
               ~ ^  ~~~~~
/usr/home/tomek/roboczy/prog/web.ttmath.org/../morm/src/finderhelper.h:78:14: note: in instantiation of member function 'PT::TextStreamBase<char, 256, 4096>::to_string' requested here
                table_name.to_string(table_name_str);
                           ^
/usr/home/tomek/roboczy/prog/web.ttmath.org/../pikotools/membuffer/membuffer.h:93:8: note: candidate function
                bool operator!=(const const_iterator & i);
                     ^
/usr/home/tomek/roboczy/prog/web.ttmath.org/../pikotools/membuffer/membuffer.h:92:8: note: candidate function
                bool operator==(const const_iterator & i);
                     ^
/usr/home/tomek/roboczy/prog/web.ttmath.org/../pikotools/membuffer/membuffer.h:92:8: note: candidate function (with reversed parameter order)
2021-02-17 16:53:19 +01:00
Tomasz Sowa aff698d155 a comment added in Log::~Log(), we have to consider whether calling save_log_and_clear() in ~Log() should be removed 2021-02-17 16:51:06 +01:00
Tomasz Sowa a29cb45f6a added: in FileLog::save_log(): test whether synchro_lock() has returned true
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1216 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-09-25 16:12:10 +00: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 c2e63f9290 added: to Date: support for parsing timezone offsets
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1168 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-01-31 20:56:40 +00:00
Tomasz Sowa 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
                          



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1167 e52654a7-88a9-db11-a3e9-0013d4bc506e
2019-01-28 18:06:18 +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 6c4a76baad changed in utf8: functions taking WTextStream now take a template TextStreamBase
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1157 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-11-24 17:09:25 +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 8b3ae14d9a fixed: FileLog didn't save an utf8 sequence
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1155 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-11-24 10:47:13 +00:00
Tomasz Sowa 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





git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1149 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-11-23 17:07:52 +00:00
Tomasz Sowa 6984a34fcd added to convert/text.h:
bool IsSubStringp(const StringType1 * short_str, const StringType2 * long_str);
bool IsSubString(const StringType1 * short_str, const StringType2 * long_str);
bool IsSubString(const StringType1 & short_str, const StringType2 & long_str);
bool IsSubStringNoCasep(const StringType1 * short_str, const StringType2 * long_str);
bool IsSubStringNoCase(const StringType1 * short_str, const StringType2 * long_str);
bool IsSubStringNoCase(const StringType1 & short_str, const StringType2 & long_str);
(moved from winix)





git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1133 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-10-29 23:47:23 +00:00
Tomasz Sowa 5fe920d591 added: to convert/text.h:
int CompareNoCase(const StringType1 * str1_begin, const StringType1 * str1_end, const StringType2 * str2)



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1130 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-10-24 16:25:47 +00:00
Tomasz Sowa 605f24420e added to convert/text.h:
bool EqualNoCasep(const StringType1 * str1, const StringType2 * str)
int CompareNoCasep(const StringType1 * str1, const StringType2 * str2)




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1127 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-10-04 13:41:07 +00:00
Tomasz Sowa 8e9f83e377 changed: when parsing date skip 'Z' character if exists (iso format)
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1126 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-09-19 21:24:23 +00:00
Tomasz Sowa 239e1e4674 added: CompareNoCase() to convert/text.h
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1125 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-08-11 17:37:35 +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 dd325bd4f9 added: Logger
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1095 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-23 14:28:22 +00:00
Tomasz Sowa bf4fdf6da7 added: Toa() for long long, int, short and unsigned as well
fixed: when serializing Date the year has at least 4 digits
       e.g. 0001 when the year is equal to one




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1093 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-22 21:22:55 +00:00
Tomasz Sowa 38355a2830 added: method Date::SerializeISO(Stream & out)
outputs to the given stream: YYYY-MM-DDTHH:MM:SSZ, eg: 1990-02-12T13:05:39Z
added: parsing date in a format: YYYY-MM-DDTHH:MM:SS ('T' letter given)




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1089 e52654a7-88a9-db11-a3e9-0013d4bc506e
2018-04-20 09:33:53 +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 62f16ecb1b changed: using relative paths calculated with relative_path now
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1034 e52654a7-88a9-db11-a3e9-0013d4bc506e
2016-03-18 09:27:40 +00:00
Tomasz Sowa 9deb2ff2f2 some work in MainSpaceParser: added reading long (--longname) parameters
git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1025 e52654a7-88a9-db11-a3e9-0013d4bc506e
2016-02-08 18:00:17 +00:00
Tomasz Sowa 7b4b576489 added: MainSpaceParser - starting writing a parser for main(argc, argv) arguments
(a Space object is returned)




git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1019 e52654a7-88a9-db11-a3e9-0013d4bc506e
2016-01-21 18:49:42 +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