nlib
nn::nlib Namespace Reference

Implements stream-related classes usually commonly used, various containers, and other gadget classes. nlib_ns is an alias. More...

Namespaces

 binary_reader
 Defines functions that are used to read to user-defined classes with the BinaryReader class.
 
 binary_writer
 Defines functions that are used to write user-defined classes with the BinaryWriter class.
 
 exi
 Implements binary XML parsers (and XML parsers).
 
 handle_maker
 Namespace in which a function template to customize the HandleMaker class is defined.
 
 heap
 Namespace for the heap library. Functions such as nmalloc and nfree are defined in the global namespace.
 
 msgpack
 The library used to implement the MessagePack serializer, the JSON parser/writer, and the CSV parser.
 
 oss
 Implements a library for open-source software (OSS), code derived from OSS, and for accessing OSS.
 
 simd
 Implements the classes and functions for SIMD computations on integers and single-precision, floating-point, numbers.
 
 succinct
 Implements a library of succinct data structure classes related to bit vectors.
 
 testing
 Framework to test C++ code. View the description of List of testing Library Features.
 
 threading
 Unicode related functionality is implemented.
 
 unicode
 Unicode-related functionality is implemented.
 

Classes

class  Base64Decoder
 Decodes Base64. This class supports various variants of Base64. More...
 
class  Base64Encoder
 Encodes Base64. This class supports various variants of Base64. More...
 
class  Base64InputStream
 The class for reading Base64-encoded data. More...
 
class  Base64OutputStream
 The class for writing data after encoding it in Base64. More...
 
class  BinaryReader
 The class for reading binary from streams (from InputStream). More...
 
class  BinaryWriter
 The class for writing binary to streams (to OutputStream). More...
 
class  ConsoleOutputStream
 The class for creating a stream to output to the console as a text string using nlib_printf. More...
 
class  ConstructorForLockFree
 Class template for initializing an object. This should be specialized before use. More...
 
class  CurlInputStream
 The stream class for downloading using libcurl. More...
 
class  DateTime
 The class for representing the date and time. More...
 
struct  DateTimeParams
 The structure for setting date and time information in DateTime and for getting that information from the object. More...
 
class  DestructorForLockFree
 Class template for destructing an object. This should be specialized before use. More...
 
class  DynamicAlignedStorage
 A class for obtaining aligned memory. More...
 
class  ErrnoT
 Class that wraps errno_t. This class improves visual representations in the Visual Studio debugger. More...
 
class  FileInputStream
 The class for file input streams. More...
 
struct  FileInputStreamSettings
 The structure that stores information about the file stream settings. More...
 
class  FileOutputStream
 The class for file output streams. More...
 
struct  FileOutputStreamSettings
 The structure that stores information about the file stream settings. More...
 
class  FileStyleUri
 The class for parsing URIs that use the file scheme and for constructing URI strings. More...
 
class  GroupVarInt32
 Class for encoding and decoding four 32-bit integer values as a unit. More...
 
class  HandleAccess
 An accessor class that can access the handle instance as if it is a pointer. It becomes available after it is specified by the HandlerMaker class. More...
 
class  HandleMaker
 A class supporting the implementation of handles with a 32-bit integer value. More...
 
struct  HandleTable
 A table referencing handle instances used by the HandlerMaker class. More...
 
class  HttpStyleUri
 The class for parsing URIs that use the http and https schemes, and for constructing URI strings. More...
 
class  InputConverterStream
 The base class for classes that act internally like InputStream to convert data. More...
 
class  InputConverterStreamTempl
 The class for holding the InputTransform derived class. More...
 
class  InputStream
 The base class for input streams. This class cannot be instantiated. More...
 
class  LockFreeBroadcastQueue
 The specified number of listeners can obtain elements from the queue. After all the listeners have obtained elements, those elements are deleted from the queue. More...
 
class  LockFreePipe
 When a single sender thread sends data and a single receiver thread receives that data, you can use this class to transfer data in a lock-free manner. More...
 
class  LockFreePriorityQueue
 Wraps nlib_mq with a class implementing a lock-free queue with a priority set. More...
 
class  LockFreeQueue
 This class implements a lock-free queue. More...
 
class  LockFreeStack
 This class implements a lock-free stack. More...
 
class  LockFreeUnitHeap
 A pool allocator that can allocate or free a fixed size of memory region in a lock free manner. More...
 
class  MemoryInputStream
 The class for creating an input stream that makes use of memory. More...
 
class  MemoryOutputStream
 The class for creating an output stream that makes use of memory. More...
 
struct  move_tag
 An empty structure indicating that an argument to a function needs to be moved. More...
 
class  NativePathMapper
 The class for getting the native path string from the URI path notation that is not machine-dependent. More...
 
class  Nflags
 The class for parsing command line flags. More...
 
class  Nlist
 A container-like class similar to std::vector that can store objects that do not have copy constructors. More...
 
class  Nqueue
 A container-like class similar to std::queue that can store objects that do not have copy constructors. More...
 
class  NullInputStream
 The class for streams that always load 0. More...
 
class  NullOutputStream
 The class for OutputStream objects for which no actual writing takes place. More...
 
class  OutputConverterStream
 The base class for classes that act internally like OutputStream to convert data. More...
 
class  OutputConverterStreamTempl
 The class for holding the OutputTransform derived class. More...
 
class  OutputStream
 The base class for output streams. This class cannot be instantiated. More...
 
class  ReallocCstringVec
 The class for realloc-based implementations of C string vectors. More...
 
class  ReallocOutputStream
 The class for output streams written to memory expanded using nlib_realloc or another realloc function. More...
 
class  ReallocQueue
 The class for realloc-based implementations of queues with POD-type elements. More...
 
class  ReallocVec
 The class for realloc-based implementations of vectors with POD-type elements. More...
 
class  SimpleSingleton
 Singleton of the type for implicitly constructing an instance based on a static variable before calling the main function. More...
 
class  Singleton
 Singleton initialized by the object when first used. More...
 
class  SmartBitmap
 The data structure holding bit data operated on by Rank and Select. More...
 
class  SmartBitmapCrtp
 The data structure holding bit data operated on by Rank and Select. More...
 
class  SmartBitmapPtr
 The data structure holding bit data operated on by Rank and Select. More...
 
class  StringView
 The class for using the member functions of std::string without constructing std::string. More...
 
class  TaggedTextParser
 A simple parser for parsing XML-like tagged text. More...
 
class  TextReader
 The class for reading text from streams. More...
 
class  TextWriter
 The class for writing text to streams. More...
 
class  TimeSpan
 The class for representing the time. More...
 
class  TimeValue
 The class that wraps 64-bit signed integers. More...
 
class  UniquePtr
 UniquePtr owns the pointer, and when it goes out of scope, the pointer is released by the destructor using the method specified by DEL. More...
 
class  Uri
 The class for parsing and constructing regular URIs. More...
 
class  UriTemplate
 The class that supports URI Template (RFC 6570, Level 3). More...
 
class  Utf16InputStream
 The class for reading UTF-16 string streams as UTF-8. More...
 
class  Utf32InputStream
 The class for reading UTF-32 string streams as UTF-8. More...
 
class  Utf8Array
 Class that wraps the char array storing UTF-8. This class improves visual representations of UTF-8 in the Visual Studio debugger. More...
 
class  Utf8Ptr
 Class that wraps const char* storing UTF-8. This class improves visual representations of UTF-8 in the Visual Studio debugger. More...
 
class  WcharInputStream
 The class for reading string streams of wide characters (wchar_t and UTF-16 or UTF-32) as UTF-8. More...
 
class  ZlibInputStream
 The stream class for reading compressed data using zlib. More...
 
struct  ZlibInputStreamSettings
 The structure that stores the various ZlibInputStream settings. At construction time, the default settings are stored. More...
 
class  ZlibOutputStream
 The class that uses zlib to decompress data and write the data to a stream. More...
 
struct  ZlibOutputStreamSettings
 The structure that stores the various ZlibOutputStream settings. At construction time, the default settings are stored. More...
 

Typedefs

typedef nlib_utf16_t utf16_t
 Type for UTF-16 characters. Defined as nlib_utf16_t using typedef.
 
typedef nlib_utf32_t utf32_t
 Type for UTF-32 characters. Defined as nlib_utf32_t using typedef.
 

Functions

size_t StrLen (const char *str) noexcept
 Wraps the nlib_strlen function.
 
size_t StrLen (const nlib_utf16_t *str) noexcept
 Wraps the nlib_utf16len function.
 
size_t StrLen (const nlib_utf32_t *str) noexcept
 Wraps the nlib_utf32len function.
 
size_t StrLen (const wchar_t *str) noexcept
 Wraps the nlib_wcslen function.
 
errno_t CodePointCount (const char *str, size_t *count) noexcept
 Wraps the nlib_strcplen function.
 
errno_t CodePointCount (const nlib_utf16_t *str, size_t *count) noexcept
 Wraps the nlib_utf16cplen function.
 
errno_t CodePointCount (const nlib_utf32_t *str, size_t *count) noexcept
 Wraps the nlib_utf32cplen function.
 
errno_t CodePointCount (const wchar_t *str, size_t *count) noexcept
 Wraps the nlib_wcscplen function.
 
int StrCmp (const char *s1, const char *s2) noexcept
 Wraps the strcmp function.
 
int StrCmp (const wchar_t *s1, const wchar_t *s2) noexcept
 Wraps the wcscmp function.
 
int StrCmp (const nlib_utf16_t *s1, const nlib_utf16_t *s2) noexcept
 Compares UTF-16 strings in the same way as the strcmp function.
 
int StrCmp (const nlib_utf32_t *s1, const nlib_utf32_t *s2) noexcept
 Compares UTF-32 strings in the same way as the strcmp function.
 
int StrNcmp (const char *s1, const char *s2, size_t n) noexcept
 Wraps the strncmp function.
 
int StrNcmp (const wchar_t *s1, const wchar_t *s2, size_t n) noexcept
 Wraps the wcsncmp function.
 
int StrNcmp (const nlib_utf16_t *s1, const nlib_utf16_t *s2, size_t n) noexcept
 Compares UTF-16 strings in the same way as the strncmp function.
 
int StrNcmp (const nlib_utf32_t *s1, const nlib_utf32_t *s2, size_t n) noexcept
 Compares UTF-32 strings in the same way as the strncmp function.
 
errno_t StrCpy (char *dest, size_t dest_size, const char *src) noexcept
 Wraps the nlib_strcpy function.
 
errno_t StrCpy (nlib_utf16_t *dest, size_t dest_size, const nlib_utf16_t *src) noexcept
 Wraps the nlib_utf16cpy function.
 
errno_t StrCpy (nlib_utf32_t *dest, size_t dest_size, const nlib_utf32_t *src) noexcept
 Wraps the nlib_utf32cpy function.
 
errno_t StrCpy (wchar_t *dest, size_t dest_size, const wchar_t *src) noexcept
 Wraps the nlib_wcscpy function.
 
template<class T , size_t N>
errno_t StrCpy (T(&dest)[N], const T *src) noexcept
 Makes a call to StrCpy(&dest[0], N, src). More...
 
errno_t StrNcpy (char *dest, size_t dest_size, const char *src, size_t n) noexcept
 Wraps the nlib_strncpy function.
 
errno_t StrNcpy (nlib_utf16_t *dest, size_t dest_size, const nlib_utf16_t *src, size_t n) noexcept
 Wraps the nlib_utf16ncpy function.
 
errno_t StrNcpy (nlib_utf32_t *dest, size_t dest_size, const nlib_utf32_t *src, size_t n) noexcept
 Wraps the nlib_utf32ncpy function.
 
errno_t StrNcpy (wchar_t *dest, size_t dest_size, const wchar_t *src, size_t n) noexcept
 Wraps the nlib_wcsncpy function.
 
template<class T , size_t N>
errno_t StrNcpy (T(&dest)[N], const T *src, size_t n) noexcept
 Makes an internal call to StrNcpy(&dest[0], N, src, n). More...
 
template<class T , size_t N>
errno_t StrCat (T(&dest)[N], const T *src) noexcept
 Makes a call to StrCat(&dest[0], N, src). More...
 
template<class T , size_t N>
errno_t StrNcat (T(&dest)[N], const T *src, size_t n) noexcept
 Makes an internal call to StrNcat(&dest[0], N, src, n). More...
 
int VsnPrintfFallback (char *buf, size_t size, const char *fmt, va_list args) noexcept
 The fallback for VsnPrintf. Also implemented in a wide-character version. More...
 
int VsnPrintf (char *buf, size_t size, const char *fmt, va_list args) noexcept
 Executes vsnprintf. More...
 
template<size_t N>
int VsnPrintf (char(&buf)[N], const char *fmt, va_list args) noexcept
 Internally runs VsnPrintf(buf, N, fmt, args). More...
 
int SnPrintf (char *buf, size_t size, const char *fmt,...) noexcept
 Makes a call to the VsnPrintf function, but otherwise operates the same way as snprintf. More...
 
template<size_t N>
int SnPrintf (char(&buf)[N], const char *fmt,...) noexcept
 Internally runs the VsnPrintf function. More...
 
int VsnPrintf (wchar_t *buf, size_t size, const wchar_t *fmt, va_list args) noexcept
 Executes vsnprintf. More...
 
template<size_t N>
int VsnPrintf (wchar_t(&buf)[N], const wchar_t *fmt, va_list args) noexcept
 Internally runs VsnPrintf(buf, N, fmt, args). More...
 
int SnPrintf (wchar_t *buf, size_t size, const wchar_t *fmt,...) noexcept
 Makes a call to the VsnPrintf function, but otherwise operates the same way as snwprintf. More...
 
template<size_t N>
int SnPrintf (wchar_t(&buf)[N], const wchar_t *fmt,...) noexcept
 Internally runs the VsnPrintf function. More...
 
errno_t GetNintendoTime (int64_t *t) noexcept
 Returns the amount of time that has elapsed, in units of milliseconds, starting from 2000-01-01. More...
 
uint64_t GetTickTime () noexcept
 Returns the time in units of milliseconds that has elapsed since the system started. More...
 
bool operator== (const TimeValue &lhs, const TimeValue &rhs) noexcept
 A relational operator.
 
bool operator< (const TimeValue &lhs, const TimeValue &rhs) noexcept
 A relational operator.
 
bool operator!= (const TimeValue &lhs, const TimeValue &rhs) noexcept
 A relational operator.
 
bool operator> (const TimeValue &lhs, const TimeValue &rhs) noexcept
 A relational operator.
 
bool operator<= (const TimeValue &lhs, const TimeValue &rhs) noexcept
 A relational operator.
 
bool operator>= (const TimeValue &lhs, const TimeValue &rhs) noexcept
 A relational operator.
 
TimeValue operator+ (const TimeValue &lhs, const TimeValue &rhs) noexcept
 Adds.
 
TimeValue operator- (const TimeValue &lhs, const TimeValue &rhs) noexcept
 Subtracts.
 
TimeSpan operator+ (const TimeSpan &lhs, const TimeSpan &rhs) noexcept
 Adds.
 
TimeSpan operator- (const TimeSpan &lhs, const TimeSpan &rhs) noexcept
 Subtracts.
 
TimeSpan operator* (int i, const TimeSpan &rhs) noexcept
 Increases rhs by a factor of i.
 
TimeSpan operator* (double d, const TimeSpan &rhs) noexcept
 Increases rhs by a factor of d.
 
TimeSpan operator* (const TimeSpan &lhs, int i) noexcept
 Increases rhs by a factor of i.
 
TimeSpan operator* (const TimeSpan &lhs, double d) noexcept
 Increases rhs by a factor of d.
 
DateTime operator+ (const DateTime &lhs, const TimeSpan &rhs) noexcept
 Returns the time that is the rhs amount of time into the future from lhs.
 
DateTime operator- (const DateTime &lhs, const TimeSpan &rhs) noexcept
 Returns the time that is the rhs amount of time back in the past from lhs.
 
TimeSpan operator- (const DateTime &lhs, const DateTime &rhs) noexcept
 Returns the duration between the times of rhs and lhs.
 
template<class T >
errno_t LockFreeInit (T **ptr) noexcept
 Constructs an object in a thread safe manner. More...
 
template<class T , class AL1 , class AL2 >
bool operator== (const Nlist< T, AL1 > &lhs, const Nlist< T, AL2 > &rhs) noexcept
 Checks whether two lists have equal values.
 
template<class T , class AL1 , class AL2 >
bool operator!= (const Nlist< T, AL1 > &lhs, const Nlist< T, AL2 > &rhs) noexcept
 Checks whether two lists have equal values.
 
template<class T , class AL1 , class AL2 >
bool operator< (const Nlist< T, AL1 > &lhs, const Nlist< T, AL2 > &rhs) noexcept
 Compares two lists in dictionary order.
 
template<class T , class AL1 , class AL2 >
bool operator> (const Nlist< T, AL1 > &lhs, const Nlist< T, AL2 > &rhs) noexcept
 Compares two lists in dictionary order.
 
template<class T , class AL1 , class AL2 >
bool operator<= (const Nlist< T, AL1 > &lhs, const Nlist< T, AL2 > &rhs) noexcept
 Compares two lists in dictionary order.
 
template<class T , class AL1 , class AL2 >
bool operator>= (const Nlist< T, AL1 > &lhs, const Nlist< T, AL2 > &rhs) noexcept
 Compares two lists in dictionary order.
 
bool operator== (const StringView &lhs, const StringView &rhs) noexcept
 Compares strings to check whether they are the same.
 
bool operator!= (const StringView &lhs, const StringView &rhs) noexcept
 Compares strings to check whether they are the same.
 
bool operator< (const StringView &lhs, const StringView &rhs) noexcept
 Compares strings in dictionary order.
 
bool operator> (const StringView &lhs, const StringView &rhs) noexcept
 Compares strings in dictionary order.
 
bool operator<= (const StringView &lhs, const StringView &rhs) noexcept
 Compares strings in dictionary order.
 
bool operator>= (const StringView &lhs, const StringView &rhs) noexcept
 Compares strings in dictionary order.
 
template<class T1 , class D1 , class T2 , class D2 >
bool operator== (const UniquePtr< T1, D1 > &rhs, const UniquePtr< T2, D2 > &lhs) noexcept
 Returns true if holding the same pointer.
 
template<class T1 , class D1 >
bool operator== (const UniquePtr< T1, D1 > &lhs, nullptr_t) noexcept
 Returns true if lhs is NULL.
 
template<class T1 , class D1 >
bool operator== (nullptr_t, const UniquePtr< T1, D1 > &rhs) noexcept
 Returns true if rhs is NULL.
 
template<class T1 , class D1 , class T2 , class D2 >
bool operator!= (const UniquePtr< T1, D1 > &rhs, const UniquePtr< T2, D2 > &lhs) noexcept
 Returns true if not holding the same pointer.
 
template<class T1 , class D1 >
bool operator!= (const UniquePtr< T1, D1 > &lhs, nullptr_t) noexcept
 Returns true if lhs is not NULL.
 
template<class T1 , class D1 >
bool operator!= (nullptr_t, const UniquePtr< T1, D1 > &rhs) noexcept
 Returns true if rhs is not NULL.
 

Detailed Description

Implements stream-related classes usually commonly used, various containers, and other gadget classes. nlib_ns is an alias.

Description
The following classes and functions are implemented in the nn::nlib namespace.
See also
nlib Platform APIs (global namespace)

Function Documentation

§ GetNintendoTime()

nn::nlib::GetNintendoTime ( int64_t *  t)
inlinenoexcept

Returns the amount of time that has elapsed, in units of milliseconds, starting from 2000-01-01.

Parameters
[out]tPointer to where the elapsed time is stored.
Returns
Any value other than 0 indicates an error. If the pointer is invalid, the function returns EINVAL.

Definition at line 17 of file DateTime.h.

§ GetTickTime()

nn::nlib::GetTickTime ( )
inlinenoexcept

Returns the time in units of milliseconds that has elapsed since the system started.

Returns
The elapsed time since the system started.
Examples:
heap/cachedheap/cachedheap.cpp, heap/nmalloc_simple/nmalloc_simple.cpp, and msgpack/msgpack2/msgpack2.cpp.

Definition at line 28 of file DateTime.h.

§ LockFreeInit()

template<class T >
nn::nlib::LockFreeInit ( T **  ptr)
inlinenoexcept

Constructs an object in a thread safe manner.

Template Parameters
TThe type of the object to be initialized.
Parameters
[out]ptrThe pointer to the initialized object.
Return values
0Success.
EAGAINThe constructor function (ConstructorForLockFree<T>()()) has returned NULL.
Description
This function assigns a pointer to the object created by executing ConstructorForLockFree<T>()() to *ptr. In this case, mutex performs no exclusive processing and CAS(Compare-and-Swap) sets a pointer to the object only once in a thread safe manner. This operation may cause ConstructorForLockFree<T>()() to be simultaneously run in multiple threads, which in turn any objects that are not used are deleted by executing DestructorForLockFree<T>()(). Note that *ptr must have been statically initialized to NULL.
Sample code
class MyObj {
....
};
static MyObj* myobj = NULL;
NLIB_NAMESPACE_BEGIN
// Specializes nlib_ns::ConstructorForLockFree<T>
template<>
class ConstructorForLockFree<MyObj> {
public:
MyObj* operator()() NLIB_NOEXCEPT {
return new (std::nothrow) MyObj();
}
};
// Specializes nlib_ns::DestructorForLockFree<T>
template<>
class DestructorForLockFree<MyObj> {
public:
void operator()(MyObj* p) { delete p; }
};
NLIB_NAMESPACE_END
....
{
....
if (nlib_is_error(e)) {
// error, you can try again
}
// now you can use myobj
}

Definition at line 617 of file LockFree.h.

§ SnPrintf() [1/4]

nn::nlib::SnPrintf ( char *  buf,
size_t  size,
const char *  fmt,
  ... 
)
inlinenoexcept

Makes a call to the VsnPrintf function, but otherwise operates the same way as snprintf.

Parameters
[out]bufThe buffer storing the string.
[in]sizeThe size of the buffer (a number of characters).
[in]fmtThe format.
Returns
The return value of the VsnPrintf function.
Description
The following code is executed internally.
va_list args;
va_start(args, fmt);
int rval = VsnPrintf(buf, size, fmt, args);
va_end(args);
return rval;
Examples:
msgpack/jsonrpc/server.cpp.

Definition at line 191 of file Cstring.h.

§ SnPrintf() [2/4]

template<size_t N>
nn::nlib::SnPrintf ( char(&)  buf[N],
const char *  fmt,
  ... 
)
inlinenoexcept

Internally runs the VsnPrintf function.

Template Parameters
NThe size of the buffer (a number of characters).
Parameters
[out]bufThe buffer storing the string.
[in]fmtThe format.
Returns
The return value of the VsnPrintf function.
Description
The following code is executed internally.
va_list args;
va_start(args, fmt);
int rval = VsnPrintf(buf, N, fmt, args);
va_end(args);
return rval;

Definition at line 204 of file Cstring.h.

§ SnPrintf() [3/4]

nn::nlib::SnPrintf ( wchar_t *  buf,
size_t  size,
const wchar_t *  fmt,
  ... 
)
inlinenoexcept

Makes a call to the VsnPrintf function, but otherwise operates the same way as snwprintf.

Parameters
[out]bufThe buffer storing the string.
[in]sizeThe size of the buffer (a number of characters).
[in]fmtThe format.
Returns
The return value of the VsnPrintf function.
Description
The following code is executed internally.
va_list args;
va_start(args, fmt);
int rval = VsnPrintf(buf, size, fmt, args);
va_end(args);
return rval;

Definition at line 273 of file Cstring.h.

§ SnPrintf() [4/4]

template<size_t N>
nn::nlib::SnPrintf ( wchar_t(&)  buf[N],
const wchar_t *  fmt,
  ... 
)
inlinenoexcept

Internally runs the VsnPrintf function.

Template Parameters
NThe size of the buffer (a number of characters).
Parameters
[out]bufThe buffer storing the string.
[in]fmtThe format.
Returns
The return value of the VsnPrintf function.
Description
The following code is executed internally.
va_list args;
va_start(args, fmt);
int rval = VsnPrintf(buf, N, fmt, args);
va_end(args);
return rval;

Definition at line 286 of file Cstring.h.

§ StrCat()

template<class T , size_t N>
nn::nlib::StrCat ( T(&)  dest[N],
const T *  src 
)
inlinenoexcept

Makes a call to StrCat(&dest[0], N, src).

Template Parameters
TEither char or wchar_t.
NThe size of the string buffer where the string is appended.
Parameters
[in,out]destThe null-terminated string buffer where the string is appended.
[in]srcThe null-terminated string to append.
Returns
The return value of StrCat(&dest[0], N, src).

Definition at line 153 of file Cstring.h.

§ StrCpy()

template<class T , size_t N>
nn::nlib::StrCpy ( T(&)  dest[N],
const T *  src 
)
inlinenoexcept

Makes a call to StrCpy(&dest[0], N, src).

Template Parameters
TEither char, wchar_t, nlib_utf16_t, or nlib_utf32_t.
NThe size of the buffer to copy to.
Parameters
[out]destThe buffer where the string is copied.
[in]srcThe string to copy.
Returns
The return value of StrCpy(&dest[0], N, src).

Definition at line 115 of file Cstring.h.

§ StrNcat()

template<class T , size_t N>
nn::nlib::StrNcat ( T(&)  dest[N],
const T *  src,
size_t  n 
)
inlinenoexcept

Makes an internal call to StrNcat(&dest[0], N, src, n).

Template Parameters
TEither char or wchar_t.
NThe size of the string buffer where the string is appended.
Parameters
[in,out]destThe null-terminated string buffer where the string is appended.
[in]srcThe null-terminated string to append.
[in]nThe maximum number of characters to add (excluding the null character).
Returns
The return value of StrNcat(&dest[0], N, src, n).

Definition at line 159 of file Cstring.h.

§ StrNcpy()

template<class T , size_t N>
nn::nlib::StrNcpy ( T(&)  dest[N],
const T *  src,
size_t  n 
)
inlinenoexcept

Makes an internal call to StrNcpy(&dest[0], N, src, n).

Template Parameters
TEither char, wchar_t, nlib_utf16_t, or nlib_utf32_t.
NThe size of the buffer to copy to.
Parameters
[out]destThe buffer where the string is copied.
[in]srcThe string to copy.
[in]nThe maximum number of characters to copy (excluding the null character).
Returns
The return value of StrNcpy(&dest[0], N, src, n).

Definition at line 146 of file Cstring.h.

§ VsnPrintf() [1/4]

nn::nlib::VsnPrintf ( char *  buf,
size_t  size,
const char *  fmt,
va_list  args 
)
inlinenoexcept

Executes vsnprintf.

Parameters
[out]bufThe buffer storing the string.
[in]sizeThe size of the buffer (a number of characters).
[in]fmtThe format.
[in]argsPointer to an argument list.
Returns
If successful, returns the length of the string that was (supposed to be) written, not including the null terminator. The function returns a negative value if it fails.
Description
The null character is written to the end of buf. The user must call va_end after this function has been called.
The function makes an internal call to vsnprintf, but the error values and other behavior can differ, depending on the platform.
This is illustrated by the following coding example.
void MyFunc(char* buf, size_t size, const char* fmt, ...) {
va_start(args, fmt);
int n = VsnPrintf(buf, size, fmt, args);
va_end(args);
if (n < 0) {
// Note that if the buffer is too small, the function might return a negative value rather than a positive number and set an error such as EAGAIN, ERANGE, or EOVERFLOW in \a errno.
// The error values differ depending on the platform.
// The negative number values themselves differ, so compare them unsigned.
....
} else if (static_cast<size_t>(n) >= size) {
// The string is not written in its entirety, but rounded.
....
} else {
// Successfully written.
....
}
}

Definition at line 172 of file Cstring.h.

§ VsnPrintf() [2/4]

template<size_t N>
nn::nlib::VsnPrintf ( char(&)  buf[N],
const char *  fmt,
va_list  args 
)
inlinenoexcept

Internally runs VsnPrintf(buf, N, fmt, args).

Template Parameters
NThe size of the buffer (a number of characters).
Parameters
[out]bufThe buffer storing the string.
[in]fmtThe format.
[in]argsPointer to an argument list.
Returns
The return value of VsnPrintf(buf, N, fmt, args).

Definition at line 184 of file Cstring.h.

§ VsnPrintf() [3/4]

nn::nlib::VsnPrintf ( wchar_t *  buf,
size_t  size,
const wchar_t *  fmt,
va_list  args 
)
inlinenoexcept

Executes vsnprintf.

Parameters
[out]bufThe buffer storing the string.
[in]sizeThe size of the buffer (a number of characters).
[in]fmtThe format.
[in]argsPointer to an argument list.
Returns
If successful, returns the number of characters that were written, not including the null terminator. The function returns a negative value if it fails.
Description
The null character is written to the end of buf. The user must call va_end after this function has been called.
The function makes an internal call to vsnwprintf, but the error values and other behavior can differ, depending on the platform.

Definition at line 254 of file Cstring.h.

§ VsnPrintf() [4/4]

template<size_t N>
nn::nlib::VsnPrintf ( wchar_t(&)  buf[N],
const wchar_t *  fmt,
va_list  args 
)
inlinenoexcept

Internally runs VsnPrintf(buf, N, fmt, args).

Template Parameters
NThe size of the buffer (a number of characters).
Parameters
[out]bufThe buffer storing the string.
[in]fmtThe format.
[in]argsPointer to an argument list.
Returns
The return value of VsnPrintf(buf, N, fmt, args).

Definition at line 266 of file Cstring.h.

§ VsnPrintfFallback()

nn::nlib::VsnPrintfFallback ( char *  buf,
size_t  size,
const char *  fmt,
va_list  args 
)
noexcept

The fallback for VsnPrintf. Also implemented in a wide-character version.

Parameters
[out]bufThe buffer storing the string.
[in]sizeThe size of the buffer (a number of characters).
[in]fmtThe format.
[in]argsPointer to an argument list.
Returns
If successful, returns the number of characters that were written, not including the null terminator. The function returns a negative value if it fails.
Description
This function is called from VsnPrintf in environments where vsnprintf does not exist or can be classified as such. This function can also be called directly. As of now, the floating-point type does not use exponential notation.
If the function fails, an error value is set in errno (in environments where errno exists).
The following flag characters are supported.
  • #: For x and X conversion, the string 0x (or 0X) is added in front if the numerical value is not 0. For o conversion, the character 0 is added in front if the numerical value is not 0.
  • 0: Padded with zeros instead of white spaces to the right of the converted value. This is ignored if - is specified. This is ignored if a precision is specified.
  • -: Left-justified.
  • A space (' '): Adds one blank space in front of a positive number created from a signed conversion.
  • +: Always place the sign in front of a signed converted number.
For the field width, you can specify a decimal string or "*". "*" must be an int type value because the next argument specifies the field width.
For the precision, you can specify a decimal string or "*".
The following length modifiers are supported.
  • hh: The argument is char or unsigned char.
  • h: The argument is short or unsigned short.
  • l: The argument is long or unsigned long.
  • ll: The argument is long long or unsigned long long.
  • z: The argument is size_t.
The following conversion specifiers are supported.
  • d, c: Signed integer.
  • o, u, x, X: Unsigned integer.
  • c: A character (type char).
  • s: A string (const char* type). If ls, it is a const wchar_t*-type string, but the character corresponding to the lower 8 bits is output.
  • p: Outputs the pointer address in hexadecimal.