Commit Graph

140 Commits

Author SHA1 Message Date
Eugene Sandulenko
63f39ca792
COMMON: Rename base-str.* to str-base.* for consistency and file grouping 2023-01-05 14:21:23 +01:00
Le Philousophe
cd785e2208 COMMON: Add sprintf_s and vsprintf_s
These functions will issue warnings and truncate strings.
It's like snprintf and vsnprintf but noisier.
There are also versions automatically determining size based on the destination
array size.
This raises a compilation error when the size cannot be determined by
the compiler.
2022-10-23 22:46:19 +02:00
Le Philousophe
f8c25e2374 COMMON: Add strcpy_s and strcat_s
These functions will issue warnings and truncate strings.
It's like strlcpy and strlcat but noisier.
There are also versions automatically determining size based on the destination
array size.
This raises a compilation error when the size cannot be determined by
the compiler.
2022-10-23 22:46:19 +02:00
elasota
cdedda7fa8 COMMON: Add move semantic assign and construct to strings 2022-09-28 17:09:34 +02:00
elasota
2cad62a6ec COMMON: Add string encoding API with more detailed error behavior. 2022-07-02 12:53:50 +02:00
athrxx
b5079ca5c7 COMMON: add Korean Johab string encoding 2022-06-13 19:38:47 +02:00
Donovan Watteau
5b1ec56f96 JANITORIAL: Fix some lost or outdated URLs in comments 2022-05-19 07:57:31 +03:00
Eugene Sandulenko
498b2ca3a0
COMMON: Added firstPathComponents() method.
A better name is welcome
2022-03-14 21:16:03 +01:00
Eugene Sandulenko
abea37c9bb
ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Eugene Sandulenko
c544e5119b
COMMON: Remove USE_CXX11 checks, it is now always present 2021-10-31 11:52:29 +02:00
djsrv
2aa7e3e558 COMMON: Replace matchString pathMode with general wildcard exclusions
Different characters may need to be excluded for different path styles.
2021-08-09 17:43:12 -04:00
Eugene Sandulenko
f6e33231bb
COMMON: Add an optional parameter to tag2str() for printing non-printables
This time without variadic macros
2021-06-29 22:15:02 +02:00
Eugene Sandulenko
76c6bcef2b
Revert "COMMON: Add an optional parameter to tag2str() for printing non-printables"
This reverts commit c11fedb47e.

It is a C++11 feature...
2021-06-29 22:12:25 +02:00
Eugene Sandulenko
c11fedb47e
COMMON: Add an optional parameter to tag2str() for printing non-printables 2021-06-29 20:42:40 +02:00
SupSuper
e3d082df65 MSVC: Add compiler printf validation 2021-06-02 08:35:31 +03:00
Zvika Haramaty
dc5783c910 COMMON: Add String::forEachLine and convertBiDiStringByLines
`convertBiDiStringByLines` calls the BiDi algo for each line in isolation,
and returns a joined result.
That's needed to support BiDi in AGI, and might be needed for other engines
in the future.

In order to do that, a new utility function was added:
`String::forEachLine` which gets a function as input, and its arg(s) (if it has any),
and calls the function on each line, and returns a new string which is all
concatenation of all the lines results (with '\n' added between them).
2021-03-14 18:52:36 +01:00
D G Turner
0d6e4d647a COMMON: Minor Formatting Fix in String Header 2021-03-12 19:50:49 +00:00
Vladimir Serbinenko
68a9136e4d
COMMON: Rewrite Encoder and drop dependency on iconv (#2586)
Different platforms have different levels of support of encodings and
often have slight variations. We already have tables for most encoding
with only CJK missing. Full transcoding inclusion allows us to get reliable
encoding results independently of platform. The biggest con is the need for
external tables encoding.dat.

It removes a duplicate table for korean in graphics/korfont.cpp
2020-11-15 16:20:35 +01:00
Thierry Crozat
e5bfe63087 COMMON: Merge the String and U32String destructors
The call to decRefCount has been moved to the destructor
of the base class BaseString.

Note that BaseString only exists for the purpose of being able
to reuse code for our String and U32String implementations. As
such it is not meant to be used polymorphically and its
destructor does not need to be virtual (with the overhead that
this generates). And to ensure that it is not used in a
polymorphic way, the destructor is declared protected.
2020-11-05 23:52:19 +00:00
Thierry Crozat
0b93a68a0d COMMON: Attempt to fix compilation for some compilers 2020-10-31 16:56:50 +00:00
Thierry Crozat
23ce3edac9 COMMON: Add contains overload for char32_t in String 2020-10-31 16:56:50 +00:00
Vladimir Serbinenko
29cfa7bb0f COMMON: Merge code for str.cpp and ustr.cpp
Most of the code in str.cpp and ustr.cpp is actually the same. Do some
template magic to merge them.
2020-10-31 14:05:30 +01:00
Vladimir Serbinenko
18e6878311 COMMON: Add String::asUint64Ext
This is the same as String::asUint64 but supports 0x and 0 prefixes
2020-10-17 22:34:58 +02:00
Bartosz Gentkowski
ec24687ce4 DOXYGEN: Add doxygen groups to header files in the common folder
Adding @defgroup and @ingroup doxygen tags into all headers
in the common folder that contain doxygen blocks.

This improves the structure, readability, and findability
of information in the resulting output.

This commit targets purely structure and does not deal with
the content of the currently existing doxygen documentation.
2020-10-04 18:25:50 +02:00
aryanrawlani28
e5445fb901 GUI: U32: Small improvements/fixes
- Remove = operator in String, which compared to a U32String.
- Let implicit cast take care of results from getResultString, so in-future easy to spot new changes.
- Use uint32 for each char when encodingUrlStrings, to avoid unsafe comparision.
2020-08-30 14:43:41 +02:00
aryanrawlani28
388473656e GUI: U32: Add contains utility for string, which takes in a uint. 2020-08-30 14:43:41 +02:00
aryanrawlani28
fd763b61e5 GUI: U32: Add U32String conversion helpers to str.cpp
This commit adds a constructor and a "=" operator to allow conversion from u32strings->strings
2020-08-30 14:43:41 +02:00
Henrik "Henke37" Andersson
dc7b0a7909 COMMON: Dedicated function for in buffer check
It's UB to compare pointers that aren't from the same array. Cast to uintptr to reduce the issue to IB.
2020-07-19 23:07:35 +01:00
Eugene Sandulenko
6059566777 COMMON: Added scumm_strcasestr() 2020-06-18 14:38:12 +02:00
Eugene Sandulenko
0b00d71643 COMMON: Add methods for dictionary string comparison 2020-04-24 10:54:00 +02:00
Paul Gilbert
b2095095ed ULTIMA8: Starting the game will now auto-load the previous used savegame 2020-02-26 21:35:48 -08:00
Paul Gilbert
f972d68ae2 COMMON: Change recently added string methods to be camelcase 2020-02-01 13:13:51 -08:00
Paul Gilbert
a178952464 ULTIMA: Moving many string methods from Std::String to Common::String 2020-02-01 13:13:51 -08:00
Eugene Sandulenko
6b6dc21813 COMMON: Added helper function to produce printable strings 2019-12-10 00:32:54 +01:00
Eugene Sandulenko
50822e708b COMMON: Moved string encoding to separate file 2019-10-19 17:38:26 +02:00
Eugene Sandulenko
eb72d6b479 COMMON: Added String::find() 2019-10-18 00:28:36 +02:00
sluicebox
85333d8050 COMMON: Allow '\#' to match '#' in matchString
matchString patterns couldn't be used to find files with the # character
as it was only treated as a digit wildcard. SCI expected that to work as
it looks for files that start with the # character.
2019-03-03 22:44:29 +02:00
Thierry Crozat
1e11da712b COMMON: Add mutex to protect access to the String memory pool
This fixes a crash due to concurrent access to the global MemoryPool
used by the String class when String objects are used simultaneously
from several threads (as is for example the case when enabling the
cloud features).

See bug #10524: Thread safety issue with MemoryPool
2018-10-14 21:25:16 +01:00
Cameron Cawley
7a437e909c COMMON: Move new_strdup to common/str.cpp 2018-08-18 16:30:05 +02:00
Bastien Bouclet
7382af32be GUI: Make the tab completion case insensitive in the debug console
It made little sense for the tab-completion to be case sensitive while
command execution itself is case insensitive.
2018-04-30 20:31:44 +02:00
Adrian Frühwirth
3747d852ee JANITORIAL: Fix whitespace 2018-04-15 16:31:31 +02:00
Colin Snover
dda0f77bcf COMMON: Add basic fixed-width word wrap to Common::String 2017-11-10 09:57:41 -06:00
Colin Snover
9d3893459f COMMON: Add strnlen for safer C string length reads
This API is intended for use in cases where C strings come
from untrusted sources like game files, where malformed data
missing the null terminator would cause strlen to read out of
bounds.
2017-01-05 22:07:24 +01:00
Alexander Tkachev
438ba985a4 JANITORIAL: Remove spaces at the end of the line
I knew there were some, but I wanted to fix them once, instead of doing
it all the time.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
627bda9d82 COMMON: Add replace(String, String, String)
Searches for a substring in the string and replaces it with the other
string.
2016-08-24 16:07:55 +06:00
Alexander Tkachev
c99b24c16d COMMON: Add String::asUint64()
Instead of all these atoull() I've added everywhere.
2016-08-24 16:07:55 +06:00
Borja Lorente Escobar
a19b50ddf2 COMMON: Add replace functions to Common and String.
COMMON: Add replacement to common/algorithm.h

COMMON: Intermediate commit to show doubts.

 COMMON: Basic String::replace() methods implemented.

COMMON: Fix typo in the algorithm.h documentation.

COMMON: Fix documentation of String::replace()

COMMON: Fix formatting issues in method signatures.

COMMON: Add assert and reformat loops in str and algorithm.

COMMON: Fix typo in comment.

COMMON: Fix style in string test cases.

COMMON: Add Doxygen documentation to algorithm and String.

COMMON: Add Doxygen documentation to algorithm and String.

COMMON: Add Doxygen documentation to algorithm.

COMMON: Fix style in algorithm comments.

COMMON: Add Doxygen comments to String.

COMMON: Add Doxygen comments to algorithm test function.

COMMON: Add String support for substring replace.

COMMON: Fix string replace to comply with STL

COMMON: Fix documentation on string replace

COMMON: Fix style in string replace

COMMON: Fix unwanted reference problem in String::replace().

COMMON: Fix indentation in comments for replace

COMMON: Fix indentation in replace

COMMON: Fix comments in String::replace to match implementation.

COMMON: Remove assert to allow for not-null-terminated character arrays

COMMON: Add new test for String::replace

COMMON: Fix broken comments on String::replace

COMMON: Fix sharing bug on ensureCapacity

COMMON: Remove superfluous call to makeUnique()
2016-05-16 22:01:21 +02:00
Johannes Schickel
06641f29a7 COMMON: Allow '#' to only match digits in matchString. 2016-01-26 16:35:30 +01:00
Vincent Bénony
16605a3e10 IOS: Moves the helper function were it is used. 2016-01-06 16:20:29 +01:00
Vincent Bénony
bbf3785bba IOS: Adds two helper functions on strings 2016-01-06 15:35:30 +01:00