121 Commits

Author SHA1 Message Date
501183ca3e math: add
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-18 15:05:19 +02:00
3516c546ca interval: add contains() method
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-18 15:05:19 +02:00
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
d3a12f45b1 string: Add strcpy, strcat, strncat
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-26 12:17:47 +02:00
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
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
516b428d4b ios: Add diagstreambuf
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-25 16:32:46 +02:00
07f42442e0 string: Fix and extend vsprintf
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-25 16:32:45 +02:00
34f05feae4 ios: extend and update
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-24 11:46:26 +02:00
3e69770585 parser: Fix basic_scientific_numeral detection
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-24 09:46:18 +02:00
95141510b1 chrono: add
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-23 14:02:58 +02:00
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
991f81254d ios: add
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-23 14:02:58 +02:00
519a8c70ca endian: add
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-21 11:53:48 +02:00
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
82b25cc24a parser: add missing #include
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-21 11:53:48 +02:00
c5f972971e parser: revise
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 17:05:31 +02:00
f55d5636aa string: add sprintf and appendf
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 15:11:04 +02:00
863d37546e sgml: add missing #include
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 14:56:01 +02:00
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
aedb0921f2 parser: adopt changes from string
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 12:57:23 +02:00
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
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
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
cd61f8afe0 progress: cleanup
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 10:39:46 +02:00
a8c3ade263 progress: add progress_switcher
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-15 10:10:05 +02:00
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
27d10344d9 string: Add strncoll
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-12 13:57:13 +02:00
1dda8cde86 string: Revise searching
POSIX C strchr and strstr implementations return pointers and pointer
arithmetic is error prone. Switch to std C++ index search offsets.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-12 13:56:52 +02:00
a6c1c6c7ae interval: Add equality operators
MSVC is not comparing instances properly otherwise.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-04 11:08:54 +02:00
44975a016f mapping: Use member equality operators and document
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-04 11:08:54 +02:00
1c54745b3b string: Add strncpy
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-03 13:56:48 +02:00
556d5a9798 string: Revise SAL for strnlen
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-03 13:56:24 +02:00
7731a20f56 interval: Add interval_vector
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-03 13:55:34 +02:00
067cbddf64 Reformat á la VS2022
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-06-07 12:06:43 +02:00
5d46888dc2 Revise SAL for "start&length" string parameters
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-06-06 19:28:39 +02:00
2c8fad779c sgml: support appending SGML to supplied string
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-06-06 19:28:39 +02:00
1fb78a78f2 parser: Stabilize HTTP suite
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-16 12:35:52 +01:00
b028c8772e parser: Cleanup
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-16 12:35:08 +01:00
a59163733a parser: Add missing constructors to allow locale propagation
Classes using m_locale must allow locale configuration in their
constructor. Otherwise m_locale was always set to default by
basic_parser<> constructor.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-16 11:21:53 +01:00
38fac2837f parser: Duplicate locale
The Release testing revealed that compiler might free temporary
std::locale instances sooner than we thought, exposing UaF.

On 64-bit arch, a reference takes 8 bytes, a std::locale copy takes 16
bytes. So duplicating a locale in each parser instance is not such a big
deal to risk an UaF.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-16 11:02:23 +01:00
127704d2d8 parser: Rename "tester" to "parser"
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-16 10:58:15 +01:00
33012e1513 parser: Use ranged for loops where appropriate
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-16 09:38:53 +01:00
aa233bd5f9 Convert space to tab indentation
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-15 21:51:39 +01:00
308f63490c Rename .h to .hpp
These files are C++ only. They should either have no extension like
standard C++ headers (which is cumbersome on Windows environments), or
.hpp.

.h is used for C and hybrid C/C++ headers.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-15 21:49:41 +01:00
261ad98812 Add string parsers
Ported from Amebis AOsn library to standard C++

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-15 21:38:57 +01:00
d13421e4b6 Add noop deleter
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-15 09:09:23 +01:00
601cfec62d interval: Add empty() method
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-15 09:03:01 +01:00
b43b853235 Add SGML↔Unicode conversion
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-15 09:02:25 +01:00
9ce8e6bff9 Add support for character testing, strncmp, strnstr and number parsing
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-03-15 09:02:21 +01:00