98148a5575
add a Stream::new_empty() method
2024-12-05 17:49:32 +01:00
c0838de3a4
use a char32_t character in the base Stream class
...
Add an operator<<(char32_t) to the Stream class, char32_t will be used
as a main character instead of a wchar_t (this is needed on systems
where sizeof(wchar_t) is equal to 2).
while here:
- add to utf8:
size_t wide_to_int(const Stream & stream, size_t stream_index, int & res, bool & correct)
template<typename StreamType, typename OutputFunction> bool wide_to_output_function(StreamType & buffer, OutputFunction output_function, int mode = 1)
template<typename OutputFunction> bool wide_to_output_function_by_index(const Stream & stream, OutputFunction output_function, int mode)
- add to convert/misc:
bool try_esc_to_tex(char32_t c, pt::Stream & out)
bool try_esc_to_html(char32_t c, pt::Stream & out)
2024-05-31 23:11:11 +02:00
aacb1f43ae
add some utf8 converting methods
...
add new methods:
- bool int_to_stream(int c, pt::Stream & stream);
- template<typename OutputFunction>
bool utf8_to_output_function(const Stream & stream, OutputFunction output_function, int mode = 1);
- template<typename StreamIteratorType, typename OutputFunction>
bool utf8_to_output_function(StreamIteratorType & iterator_in, const StreamIteratorType & iterator_end, OutputFunction output_function, int mode = 1);
- template<typename StreamType, typename OutputFunction>
bool wide_to_output_function(StreamType & buffer, OutputFunction output_function, int mode = 1);
make some methods public:
- size_t wide_to_int(const wchar_t * wide_string, size_t string_len, int & z, bool & correct)
- size_t wide_to_int(const wchar_t * wide_string, int & z, bool & correct)
rename and make some methods public:
- template<typename OutputFunction>
utf8_to_wide_generic(const char * utf8, size_t utf8_len, OutputFunction convert_function, int mode) -> utf8_to_output_function(...)
while here:
- fix: correctly convert characters in Log::put_multiline_generic()
2024-05-30 20:19:04 +02:00
5fd17175c1
add a TextStreamBase<>::operator<<(morm::Model & model)
2024-05-29 16:37:53 +02:00
2c4bfe085b
add == and != operators to the TextStreamBase<> class
2023-07-14 09:07:57 +02:00
172c2fcee7
add to_str(...) methods to the TextStreamBase<> class
...
add such methods:
bool to_str(char * str, size_t max_buf_len) const;
bool to_str(wchar_t * str, size_t max_buf_len) const;
2023-07-14 07:42:09 +02:00
663233fe2a
let all utf8/wide functions can be available just by including utf8/utf8.h
...
while here:
- remove utf8/utf8_stream.h, now we only need utf8/utf8.h to include
- add some new methods for converting from a utf8 stream to wide stream/string
- do some improvements in TextStream:
- don't use temporary objects to convert utf8/wide
- add put_stream() which takes TextStreamBase<> as its argument
(uses an iterator instead of get_char() for reading)
- let operator<<(const Space & space) serialize to json and not to Space
2022-07-30 03:31:18 +02:00
74230d667b
change headerfile_picotools_* macros to headerfile_pikotools_*
2022-06-30 12:45:08 +02:00
cadba907b2
change licence from 3-Clause BSD to 2-Clause BSD
2022-06-30 12:09:22 +02:00
3b9b464bb7
fix: add typename keyword in TextStreamBase<> in some places
2022-02-03 19:21:22 +01:00
6b97b1b74a
fix: correctly escape json/xml/csv wide strings
...
A wide string was first changed to utf-8 and then escaped to json/xml/csv
which is incorrect. First should be escaped and then changed to utf-8.
Add TextStreamBase<>::iterator and TextStreamBase<>::const_interator as classes
with a method wchar_t get_unicode_and_advance(const iterator & end)
to return one character either from utf-8 stream or from wide stream.
Let TextStreamBase<>::operator<<(wchar_t v) correctly use utf-8.
2022-02-03 19:08:21 +01:00
8ec9350d52
added two functions to utf8:
...
template<typename StreamType> bool utf8_to_wide(const Stream & stream, StreamType & res, bool clear = true, int mode = 1);
template<typename StreamType> bool wide_stream_to_utf8(const Stream & stream, StreamType & utf8, bool clear = true, int mode = 1);
these functions are moved from TextStreamBase
2021-06-25 19:10:01 +02:00
4d9f5f6c55
Log class has the Stream class as a base class now
...
- implemented some missing operators<<(...)
- removed Manipulators: l1, l2, l3, l4, lend, lsave
- PascalCase to snake_case in Log
added to Stream:
virtual bool is_char_stream() const = 0;
virtual bool is_wchar_stream() const = 0;
virtual char get_char(size_t index) const = 0;
virtual wchar_t get_wchar(size_t index) const = 0;
virtual Stream & operator<<(const Stream & stream) = 0;
2021-06-24 20:52:48 +02:00
3c0b59e115
added to Space: long double to Space::Value and methods for converting from/to long double
...
added global methods for converting float/string double/string and long double/string (convert/double.h|cpp):
float to_float(const char * str, const char ** after = nullptr);
float to_float(const wchar_t * str, const wchar_t ** after = nullptr);
double to_double(const char * str, const char ** after = nullptr);
double to_double(const wchar_t * str, const wchar_t ** after = nullptr);
long double to_long_double(const char * str, const char ** after = nullptr);
long double to_long_double(const wchar_t * str, const wchar_t ** after = nullptr);
float to_float(const std::string & str, const char ** after = nullptr);
float to_float(const std::wstring & str, const wchar_t ** after = nullptr);
double to_double(const std::string & str, const char ** after = nullptr);
double to_double(const std::wstring & str, const wchar_t ** after = nullptr);
long double to_long_double(const std::string & str, const char ** after = nullptr);
long double to_long_double(const std::wstring & str, const wchar_t ** after = nullptr);
std::string to_str(float val);
std::wstring to_wstr(float val);
std::string to_str(double val);
std::wstring to_wstr(double val);
std::string to_str(long double val);
std::wstring to_wstr(long double val);
2021-06-23 17:01:43 +02:00
4a2a99a77d
removed a comment
2021-06-20 17:39:37 +02:00
ac407b2362
macro renamed: PT_HAS_MORM -> PT_HAS_MORM_LIBRARY
...
TextStream::to_string(...) is now TextStream::to_str(...)
added: std::string TextStream::to_str() const;
added: std::wstring TextStream::to_wstr() const;
2021-06-20 16:46:08 +02:00
819c49e638
added class Stream (textstream/stream.h) which acts as a base class for TextStream
...
TextStream is making conversions wide/utf8 now
2021-06-20 14:13:23 +02:00
06e0f13df9
added a comment in textstream.h
2021-06-16 17:44:24 +02:00
8b0ed5e750
added to TextStream:
...
TextStreamBase & operator<<(unsigned char);
TextStreamBase & operator<<(bool);
TextStreamBase & operator<<(short);
TextStreamBase & operator<<(unsigned short);
TextStreamBase & operator<<(float);
TextStreamBase & operator<<(long double);
2021-06-15 19:54:50 +02:00
b574289054
namespace PT renamed to pt
2021-05-20 16:11:12 +02:00
3984c29fbf
moved all directories to src subdirectory
2021-05-09 20:11:37 +02:00