406d14746f
math: add align_up/down
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-05-27 11:52:14 +02:00
496dc9cb34
Revise ternary operators
...
Where test expression is already or almost boolean type, using ternery
operator is excessive and possibly more difficult to read.
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-05-27 10:23:25 +02:00
bed22e7fa5
compat: add _Acquires_lock_
...
It is not exactly needed by stdex, but we have such a nice collection of
the MSVC SAL here already.
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-05-26 16:00:27 +02:00
be273d4263
exception: Add exception_msg helper
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-05-13 09:36:22 +02:00
4c499f2905
json: add escape
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-04-22 18:43:34 +02:00
1b8053f95c
Revise lambda declarations
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-04-16 10:34:11 +02:00
487f6fa922
Clear warning suppression
...
Code analysis got quite good and we'd better keep warnings on our radar.
Either:
1. Research and resolve the reason for the warning.
2. Remove silencing and let code analysis complain.
3. Comment why some warning silencing is there.
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-04-03 16:15:27 +02:00
91c9a71a5d
Resolve code analysis warnings
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-03-28 17:28:19 +01:00
5fc35751a3
UnitTest: Switch to Assert::IsTrue for primitive datatypes
...
Visual Studio 2019 has issues compiling Assert::AreEqual<stdex::langid>.
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-03-28 15:45:24 +01:00
51d472d8b2
UnitTest: ShortProjectName is not available in VS2019
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-03-28 14:26:54 +01:00
50578dabaa
unicode: Remove deprecated MB_PRECOMPOSED
...
Online documentation suggests it should be used as default (for the most
of code pages), SDK source code says it's deprecated. Let's remove it
and see how things work.
Reference: https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-03-28 14:17:29 +01:00
832daf89d6
UnitTests: Fix source code charset
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-03-28 14:17:29 +01:00
aae79719cb
AppVeyor: Initial support
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-03-28 13:31:14 +01:00
2694f59d79
Sync with Xcode
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-03-12 11:14:19 +01:00
bfd8aaff65
Stop throwing in destructors
...
When exception processing is unwinding the stack, any exception thrown
in destructors end up std::terminate()-in our process.
Since all workarounds to report errors from destructors seems an
overkill, and the only important place where we should notify the user
about a failure is the stdex::stream::cache::~cache() (data loss occurs
when failure happens here), and if we'd throw in stdex::stream::cache::
~cache(), our process would get terminated anyway so the data loss is
inevitable, let's just silence this for now and come up with a better
solution later if we get smarter anytime in the future.
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-03-06 22:15:45 +01:00
69f2c639cd
string: improve strndup documentation
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-02-20 09:11:00 +01:00
442001f66b
curl: use CURL_GLOBAL_DEFAULT by default
...
This makes the client code a bit simpler for typical use-cases.
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-02-13 12:51:49 +01:00
faa776a060
curl: fix missing #include
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-02-13 12:44:37 +01:00
d13646952d
progress: unify clock usage
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-14 12:13:48 +01:00
32d656ceed
html: default string lengths in document::assign/append
...
We run a strnlen before processing anyway.
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-14 12:13:48 +01:00
2674bb0e32
string: add variants for char16_t/char32_t strings
...
char16_t is not exactly the wchar_t on Windows. char32_t is not exactly
the wchar_t on POSIX. Rather than selecting the appropriate variant,
polymorphism picked the template implementation of strncmp, strcpy and
strncpy. The one that does not convert UTF16 surrogate pairs against
their UTF32 representation.
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-13 11:01:01 +01:00
a7543cf9ab
string: add snprintf
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-13 11:01:01 +01:00
db413bb5ce
UnitTests: fix to compile on Windows
...
sys_info.hpp requires an extra #define and linker library.
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-13 11:01:01 +01:00
8fd9fbf191
Bump Copyright year
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-08 12:36:35 +01:00
fc5a9aacf8
Trim trailing whitespace
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-07 15:01:45 +01:00
246f2baa1e
string: silence false-positive Code Analysis warning
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-11-19 10:18:03 +01:00
f45c92da23
Use == 0 for C strcmp
...
! is too easy to overlook.
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-11-15 10:39:45 +01:00
09123326c1
stream: add missing UTF-8 BOM
...
We want to ensure non-UTF8 configured Windows machines interpret our
source code correctly.
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-11-11 12:24:32 +01:00
0ae7fb6c7c
stream: use indexing operator for pointer arithmetics
2024-10-22 17:25:54 +02:00
4477706f06
stream: trun off false-positive Xcode analysis warning
2024-10-22 17:24:56 +02:00
74718b9ef8
uuid: provide uuid_str_max constant for client code
...
Using cryptic constants like 39 makes code awkward to understand.
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-10-21 12:50:52 +02:00
e442f4f502
chrono: add to_system() variants for Windows
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-10-21 12:49:08 +02:00
16e2384419
system: add safearray_accessor_with_size
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-10-18 23:47:10 +02:00
bfda0e962b
html: fix url_escape
...
When used in URLs to be passed to a browser, strings MUST NOT contain +.
We must escape + too, otherwise browsers converts it to a space or %20,
which does not represent the original value anymore.
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-10-09 17:09:50 +02:00
6379065f15
curl: add
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-10-03 17:26:25 +02:00
582438ac61
sys_info: fix to compile for _WIN32
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-10-01 16:37:35 +02:00
8844c4059d
sys_info: add username
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-09-30 17:18:12 +02:00
9fb899849d
stream: weasel around false-positive GCC warning
...
As _countof is manually implemented on non-Windows platforms, GCC
knows it returns size_t, but fails to realize it will never be more than
0x400 in our case making truncation harmless.
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-09-30 13:30:13 +02:00
4fa30d5630
memory: add get_ptr
...
This was migrated from WinStd being platform independent.
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-09-30 09:40:19 +02:00
5675f8b139
string: add recoding from UTF-16 to UTF-32
...
I know there are system functions for this (and libiconv), but this is
so trivial and quick in our implementation.
2024-09-27 14:11:11 +02:00
da11495282
string: fix high&low UTF-16 surrogate detection
...
U+D800 is a perfectly valid high surrogate. (Thou, not normal.)
While U+DC00 is a perfectly valid low surrogate.
2024-09-27 14:09:05 +02:00
f87191d113
memory: silence unknown #pragma warning
2024-09-27 14:05:46 +02:00
bdae4913c0
compat: add _In_reads_bytes_
2024-09-27 12:24:17 +02:00
8075686eee
memory: add sanitizing_allocator and sanitizing_blob
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-26 15:50:33 +02:00
d2be6a7c08
langid: address MSVC warnings
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-22 17:59:21 +02:00
c4e57f15df
langid: extend and fix conversions
...
LANGID 9 should convert to "en" and 1033 to "en-US". 36 to "sl" and
1060 to "sl-SI". Likewise backwards. Otherwise, we are loosing
disambiguation between generic and country-specific language variants.
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-22 17:02:44 +02:00
e65eb35cc2
Cleanup precompiler directives
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-21 13:32:58 +02:00
d9eb8292a9
langid: finish
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-19 16:29:22 +02:00
8bd8143c6b
langid: sync Windows build
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-19 13:01:29 +02:00
e24bd3d1fa
socket: sync Windows build
...
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-19 13:01:13 +02:00