libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
string.h File Reference
#include <string>
#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <promeki/core/namespace.h>
#include <promeki/core/util.h>
#include <promeki/core/error.h>
#include <promeki/core/sharedptr.h>
#include <promeki/core/char.h>
#include <promeki/core/stringdata.h>
Include dependency graph for string.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  String
 Encoding-aware string class with copy-on-write semantics. More...
 
class  String::CharIterator
 Random-access iterator over characters (Char values). More...
 
class  CompiledString< N >
 Compile-time string literal with encoding detection and UTF-8 decode. More...
 
class  CompiledCodepoints< Count >
 Right-sized codepoint array extracted from a CompiledString. More...
 

Namespaces

namespace  literals
 User-defined literal for convenient String construction.
 

Macros

#define PROMEKI_STRING(str)
 Compile-time optimized String from any string literal.
 

Functions

String operator+ (const char *lhs, const String &rhs)
 Concatenation with a C string on the left-hand side.
 

Detailed Description

See LICENSE file in the project root folder for license information.

Macro Definition Documentation

◆ PROMEKI_STRING

#define PROMEKI_STRING (   str)
Value:
([]() -> ::promeki::String { \
constexpr auto _cs = \
::promeki::CompiledString<sizeof(str)>(str); \
if constexpr (_cs.isAscii()) { \
static ::promeki::StringLiteralData _lit( \
str, _cs.byteCount(), _cs.hash()); \
return ::promeki::String::fromLiteralData(&_lit); \
} else { \
static constexpr auto _cp = \
::promeki::CompiledCodepoints<_cs.charCount()>(_cs); \
static ::promeki::StringUnicodeLiteralData _lit( \
_cp.data(), _cp.size(), \
str, _cs.byteCount(), _cs.hash()); \
return ::promeki::String::fromLiteralData(&_lit); \
} \
}())
Dynamic array container wrapping std::vector.
Definition list.h:40

Compile-time optimized String from any string literal.

Encoding detection and UTF-8 decoding happen entirely at compile time via consteval. At runtime both paths are zero-copy:

No heap allocation, no memcpy, no runtime decode for either path.

String a = PROMEKI_STRING("Hello"); // Latin1 zero-copy
String b = PROMEKI_STRING("café"); // compile-time UTF-8 decode
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_STRING(str)
Compile-time optimized String from any string literal.
Definition string.h:1046