Commit Graph

124 Commits

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