Commit Graph

53 Commits

Author SHA1 Message Date
Martchus f549285fde Fix splitString()/splitStringSimple() for case of empty trailing part 2021-05-11 16:42:28 +02:00
Martchus b43de126b9 Retain source compatibility of numberToString()/stringToNumber()
IntegralType and BaseType need to be kept different types, otherwise one
runs into deduction errors if both arguments have different types (which is
quite likely in practise). Since the base is always a small positive
integer the cast should always be safe.
2021-03-22 13:45:16 +01:00
Martchus a30ba0c147 Ensure still the right stringToNumber() overload is called for char arrays 2021-03-22 12:13:20 +01:00
Martchus 42132719e5 Remove comments about std::expected (which didn't even make it into C++20) 2021-03-22 12:12:11 +01:00
Martchus 8c033ca243 Fix warnings 2021-03-20 21:56:45 +01:00
Martchus 3c8eb5a333 Apply clang-format 2021-03-05 23:14:54 +01:00
Martchus cc63c8c250 Improve parameter-passing in some string conversion functions
* Allow using a range as input of joinStrings()
* Use `std::string_view` instead of `const std::string &` to pass read-only
  parameters to joinStrings() and splitString*() to avoid constructing an
  `std::string` from `const char *` parameters
* Use auto for return types of toMultiline() and toArrayOfLines()
* Does not affect BC because those are template functions
* Should not affect source compatibility; at least uses in my main projects
  seem to be unaffected
2021-03-05 23:01:30 +01:00
Martchus 6968716d5c Avoid using substr in splitString()/splitStringSimple() 2021-02-23 20:54:04 +01:00
Martchus 27e9761f63 Adjust conditions for C++20 for g++ 2021-02-09 00:22:20 +01:00
Martchus c61a1784ec Allow using splitStringSimple() with `std::unordered_set` in C++20
* So one could use e.g. `std::unordered_set<std::string_view>` as target
  container when splitting an `std::string_view`.
* Still an experimental feature
2021-02-09 00:21:53 +01:00
Martchus a26f3d7e1a Avoid instantiating an std::string for find and replace parameters
This overloads should allow passing an std::string_view or C-string to
findAndReplace() without instantiating an std::string.
2020-09-19 15:40:32 +02:00
Martchus b363498f53 Allow specifying return type in joinStrings()
for joining an std::string from an std::vector<std::string_view>.
2020-07-25 22:53:46 +02:00
Martchus 1154ed4d1c Improve exception messages of NativeFileStream
So one gets e.g. "open failed: Permission denied" instead of
just "open failed: iostream error".
2020-02-14 17:13:05 +01:00
Martchus 4e3393ee72 Apply clang-format 2019-10-30 23:02:30 +01:00
Martchus 1177381521 Add CppUtilities::endsWith() 2019-10-30 20:34:16 +01:00
Martchus 2cdde81077 Fix startsWith() if strings are equal 2019-10-27 17:59:26 +01:00
Martchus b48b2f5c06 Have everything in one top-level namespace 2019-06-10 21:56:46 +02:00
Martchus 9a50d2b8df Remove types 2019-04-13 20:33:39 +02:00
Martchus 5356d793fc Make all tests pass under Windows
* Workaround some issues
* Disable some tests (better than not running tests
  at all)
2018-10-03 22:37:55 +02:00
Martchus 8e3c40abb5 Make conversion from multi byte to wide string generic 2018-10-03 21:26:41 +02:00
Martchus 3a14d39a14 Add conversion from const char* to float/double
Previously only conversion from std::string to float/double
was possible.
2018-09-22 16:47:44 +02:00
Martchus a6eefc3ab6 Fix documentation of string conversion functions 2018-09-22 16:46:48 +02:00
Martchus 651720552e Replace typedef's with using
* Except in code which will be discarded in v5 anyways
* Should not affect source and binary compatibility
2018-09-22 16:41:33 +02:00
Marius Kittler 7e4d9a6c59 Add missing header to fix compilation with GCC 4.9 2018-07-13 13:54:53 +02:00
Martchus 97aac2424a Reduce block-nesting in joinStrings() 2018-07-01 23:21:06 +02:00
Martchus 7125e52e87 Make error messages in stringconversion.h more verbose 2018-05-31 22:28:38 +02:00
Martchus 1aa8b387e1 Apply clang-format 2018-05-08 00:35:51 +02:00
Martchus a4435bbcf3 Fix usage of enable_if with GCC 8
Seems like the trick with the three dots isn't working
with GCC 8 anymore. So let's make it a default template
parameter then.

Not sure whether GCC 8 is here correct and whether this
workaround causes further trouble.
2018-05-07 23:22:43 +02:00
Martchus da5a027ea3 Add simplified, string_view-compatible version of splitString() 2018-02-28 18:03:07 +01:00
Martchus a0c6868e88 Add conversion methods: multiline str <=> array of lines 2017-10-23 01:09:59 +02:00
Martchus e52fd5a4af Apply tidy after updating to clang-format 5.0.0
The behavior of clang-format slightly changed in Clang 5.0.0:
http://releases.llvm.org/5.0.0/tools/clang/docs/ReleaseNotes.html#clang-format
2017-09-17 21:45:23 +02:00
Martchus 22c8e636dc Write digitToChar() in a more compact way 2017-06-29 18:24:11 +02:00
Martchus 28f37bbbcd string to int: Allow specifying string size 2017-06-08 00:41:29 +02:00
Martchus 045c713cf5 string to int: Ignore whitespaces at beginning 2017-06-08 00:39:54 +02:00
Martchus db46948f2f Apply clang-format 2017-05-04 22:44:15 +02:00
Martchus 59e20b1043 Apply clang-format 2017-05-01 03:13:11 +02:00
Martchus 787d541974 Fix conversion of 0 to string
Return "0" instead of an empty string
2017-03-07 00:28:46 +01:00
Martchus 2be349856f Make numberToString/stringToNumber work with u16string
Don't rely on std::basic_stringstream at least for
integral types.
2016-11-13 23:06:03 +01:00
Martchus d6b08b8ed9 Fix decoration for static builds
- Also add improvemnts a few other things in the build system
2016-08-29 15:35:48 +02:00
Martchus b36572a4dd Add macro to assert execution of application 2016-08-06 22:02:14 +02:00
Martchus 994181cbf9 Improve utilities for testing tageditor CLI 2016-08-03 17:31:28 +02:00
Martchus 0c40a510e5 Add functions for character set conversions 2016-07-27 18:24:37 +02:00
Martchus 526cbc5282 Rewrite argument parsing 2016-06-13 00:00:36 +02:00
Martchus db7b02b1db Make header guards more unique and consistent 2016-06-11 19:09:14 +02:00
Martchus c7c64e0784 Improve documentation 2016-06-10 14:08:56 +02:00
Martchus d437126760 throw ConversionException if not all chars could be extracted 2015-11-28 00:19:44 +01:00
Martchus 4d6bf67188 fixed includes 2015-09-06 20:19:09 +02:00
Martchus 5689cb8058 added missing includes 2015-09-01 16:06:37 +02:00
Martchus 8e27b97d47 improved encode-/decodeBase64 2015-08-16 23:44:38 +02:00
Martchus 8c6f7a9785 dataSizeToString can print the exact size additionally 2015-08-09 23:58:13 +02:00