Commit Graph

343 Commits

Author SHA1 Message Date
Simon Rozman
703e43d055 string: add some more helpers for locale manipulation
Microsoft has nonstandard implementation.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-24 14:04:23 +02:00
Simon Rozman
b0b0a91729 unicode: add variants for zero-terminated input
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-24 13:58:55 +02:00
Simon Rozman
be83f36082 stream: add write_array variants for zero-terminated strings
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-24 13:57:57 +02:00
Simon Rozman
73d03d81af stream: fix buffered_sys and cached_file destruction
We had to introduce out-of-order construction for those classes, but we
forgot to implement out-of-order destruction. File gets closed first
by cached_file::m_source destructor, then inherited destructor
cache::~cache() which flushes the cache is called.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-24 13:56:41 +02:00
Simon Rozman
2b1bfc235d sgml, unicode: fix 2023-08-23 15:30:55 +02:00
Simon Rozman
52d6f8daf1 sgml, unicode: split strcat and strcpy variants
Previous implementation had only strcat-class conversion using vague
function names. This commit makes function names more explicit by adding
"cat" and deprecating previous function variants.

Since many situation required strcpy variant, the move above made space
to add strcpy variants too.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-23 14:45:39 +02:00
Simon Rozman
fe47a47e4e string: add reusable C locale
This is frequently needed locale.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-22 17:16:23 +02:00
Simon Rozman
4ca3ed0718 system: add missing include
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-22 17:06:17 +02:00
Simon Rozman
1c622c3091 stream: fix ISequentialStream
MSVC 2019 didn't handle stdex::stream::ISequentialStream and
ISequentialStream disambiguation very well.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-22 17:05:49 +02:00
Simon Rozman
f9809adf0c sgml: add variants to convert into fixed-sized buffers
This is a performance requirement of PRSkupno.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-22 17:04:36 +02:00
Simon Rozman
6bb4027553 parser::date_format_t: make classic enum
With scoped enum, bitwise operations in C++ require insane amount of
type-casting.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-22 17:03:24 +02:00
Simon Rozman
f08aa73690 chrono: additional conversions
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-22 17:00:58 +02:00
Simon Rozman
e28c61e431 chrono: finish AOsn date and time-stamp implementations
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-21 16:33:03 +02:00
Simon Rozman
55d39b1566 stream: fix cache handling in open and close
Reusing same class instance for different files reused cache content
as well.

Reported-by: Peter Holozan <peter.holozan@amebis.si>
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-21 10:27:43 +02:00
Simon Rozman
e7b6ab5345 stream: using namespace in UnitTests
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-21 10:22:32 +02:00
Simon Rozman
34449d124d system: add sys_string
"std::basic_string<sys_char>" is too cumbersome and error-prone for
daily use.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-21 10:20:44 +02:00
Simon Rozman
42a38802d3 stream: fix Win32
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-19 08:31:08 +02:00
Simon Rozman
8457226168 ios, stream: replace <iostream> with leaner and faster own streaming
Our test program runs 15 minutes using our streams vs. 25 minutes using
std::iostream derived streams.

Streams were ported from Amebis AOsn project.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-18 15:05:24 +02:00
Simon Rozman
4965d1eac5 unicode: add unit tests
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-18 15:05:19 +02:00
Simon Rozman
d7950abe42 unicode: add more constants for Windows codepages
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-18 15:05:19 +02:00
Simon Rozman
057174bef9 string: fix strtoint() template
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-18 15:05:19 +02:00
Simon Rozman
43d0c4ba05 ring: add
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-18 15:05:19 +02:00
Simon Rozman
501183ca3e math: add
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-18 15:05:19 +02:00
Simon Rozman
3516c546ca interval: add contains() method
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-18 15:05:19 +02:00
Simon Rozman
72ce0a03e5 system: add
Windows is very peculiar with #include <windows.h>. Besides we need some
OS primitive wrappers that are OS-specific.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-18 15:05:18 +02:00
Simon Rozman
d3a12f45b1 string: Add strcpy, strcat, strncat
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-26 12:17:47 +02:00
Simon Rozman
c61ce2cbf9 unicode: Add Windows-specific UTF-8 charset ID
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-26 11:04:43 +02:00
Simon Rozman
6aa63f3bd6 ios: Combine and simplify i/odiagstream
We need this for a rare use-case, so maintaining three flavors of
diagstream is too expensive. Furthermore, the buffering was removed
for simplicity.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-25 16:38:55 +02:00
Simon Rozman
516b428d4b ios: Add diagstreambuf
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-25 16:32:46 +02:00
Simon Rozman
07f42442e0 string: Fix and extend vsprintf
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-25 16:32:45 +02:00
Simon Rozman
34f05feae4 ios: extend and update
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-24 11:46:26 +02:00
Simon Rozman
3e69770585 parser: Fix basic_scientific_numeral detection
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-24 09:46:18 +02:00
Simon Rozman
95141510b1 chrono: add
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-23 14:02:58 +02:00
Simon Rozman
58caa542ac Add missing UTF-8 BOM
Many many many Windows out there are still using Windows-1252 and
similar ancient encodings.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-23 14:02:58 +02:00
Simon Rozman
991f81254d ios: add
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-23 14:02:58 +02:00
Simon Rozman
519a8c70ca endian: add
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-21 11:53:48 +02:00
Simon Rozman
df4ab7aa79 string: upgrade sprintf to use specific locale
One can always revert to default locale by specifying NULL. Mind that
stdlib locale_t is used, as we are using its sprintf() implementation
and it is not simple to convert from std::locale to locale_t.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-21 11:53:48 +02:00
Simon Rozman
82b25cc24a parser: add missing #include
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-21 11:53:48 +02:00
Simon Rozman
c5f972971e parser: revise
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 17:05:31 +02:00
Simon Rozman
f55d5636aa string: add sprintf and appendf
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 15:11:04 +02:00
Simon Rozman
863d37546e sgml: add missing #include
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 14:56:01 +02:00
Simon Rozman
33859f3a2a string: silence the code analysis warning for (nullptr, 0) combinations
Functions are allowed to be called with nullptr string input as long as
the length of those strings is set to 0.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 13:01:56 +02:00
Simon Rozman
aedb0921f2 parser: adopt changes from string
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 12:57:23 +02:00
Simon Rozman
434cf6d3e2 unicode: add conversion between char* and wchar_t*
It's implemented for Windows-only for the time being.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 12:53:03 +02:00
Simon Rozman
6cdcb08365 sgml: rename str -> wstr
The sgml.hpp is about converting between SGML and UTF-16/Unicode
actually. The "wstr" naming aligns better with std::wstring, wchar_t
etc.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 12:51:41 +02:00
Simon Rozman
08de93ce2b sgml: add helpers for std::string input parameters
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 11:33:03 +02:00
Simon Rozman
cd61f8afe0 progress: cleanup
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 10:39:46 +02:00
Simon Rozman
a8c3ade263 progress: add progress_switcher
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-15 10:10:05 +02:00
Simon Rozman
ff097d4432 string: have strncpy return number of non-zero code points in dst
This information is a side product of these templates and saves an extra
strnlen when caller plans on appending dst string some more data.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-13 14:35:48 +02:00
Simon Rozman
27d10344d9 string: Add strncoll
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-12 13:57:13 +02:00