lean cpp library
A lean C++ library providing efficient utility classes for high-performance C++ applications.
Classes | Functions
lean::io Namespace Reference

Provides I/O utilities such as intrinsic endian conversion, serialization and file classes, etc. More...

Classes

struct  filesystem_chars
 Special file system characters. More...
class  generic_serialization
 Generic value serialization. More...
struct  int_serialization
 Integer value serialization. More...
struct  float_serialization
 Float value serialization. More...
class  generic_serializer
 Generic value serializer. More...
class  mapped_file_base
 Base class for mapped files. More...
class  rmapped_file
 File class that allows for memory-mapped read access to a given file. More...
class  mapped_file
 File class that allows for memory-mapped read/write access to a given file. More...
struct  max_int_string_length
 Estimates the maximum string length for integers of the given type. More...
struct  max_float_string_length
 Estimates the maximum string length for floating-point values of the given type. More...
class  raw_file
 File class that allows for raw read/write operations on a given file. More...
class  raw_file_inserter
 File inserter class that follows the STL output iterator concept to allow for convenient buffered file output. More...
class  serializer
 Value serializer. More...
class  wcharcvt
 Encodes wchar_t strings as true 16-byte strings. More...

Functions

template<class Value >
LEAN_INLINE Value byteswap (Value value)
 Swaps the byte order of the given value.
template<class Value >
LEAN_INLINE void byteswap (const Value *value, const Value *valueEnd, Value *dest)
 Swaps the byte order of the given values.
template<class Value >
LEAN_INLINE void bytecopy (const Value *value, const Value *valueEnd, Value *dest)
 Swaps the byte order of the given values.
template<class Value >
LEAN_INLINE Value byteswap_little (Value value)
 Sets the byte order of the given value to little endian.
template<class Value >
LEAN_INLINE Value byteswap_big (Value value)
 Sets the byte order of the given value to big endian.
template<class Value >
LEAN_INLINE void byteswap_little (const Value *value, const Value *valueEnd, Value *dest)
 Sets the byte order of the given values to little endian.
template<class Value >
LEAN_INLINE void byteswap_big (const Value *value, const Value *valueEnd, Value *dest)
 Sets the byte order of the given values to big endian.
LEAN_MAYBE_EXPORT bool file_exists (const utf16_nti &file)
 Checks whether the given file exists.
LEAN_INLINE bool file_exists (const utf8_ntri &file)
 Checks whether the given file exists.
LEAN_MAYBE_EXPORT uint8 file_size (const utf16_nti &file)
 Gets the size of the given file, in bytes.
LEAN_INLINE uint8 file_size (const utf8_ntri &file)
 Gets the size of the given file, in bytes.
LEAN_MAYBE_EXPORT uint8 file_revision (const utf16_nti &file)
 Gets the last modification time in microseconds since 1/1/1970. Returns 0 on error.
LEAN_INLINE uint8 file_revision (const utf8_ntri &file)
 Gets the last modification time in microseconds since 1/1/1970. Returns 0 on error.
LEAN_MAYBE_EXPORT size_t current_directory (utf16_t *buffer, size_t bufferSize)
 Gets the current directory. Will return the buffer size required to store the current directory, if the given buffer is too small, the number of actual characters written, otherwise (excluding the terminating null appended).
template<class String >
String current_directory ()
 Gets the current directory.
LEAN_INLINE const utf8_string & initial_directory ()
 Gets the initial directory.
template<class Char >
LEAN_INLINE bool is_root_separator (Char chr)
 Checks if the given character is a root separator.
template<class Char >
LEAN_INLINE bool is_alt_path_separator (Char chr)
 Checks if the given character is an alternative path separator.
template<class Char >
LEAN_INLINE bool is_path_separator (Char chr)
 Checks if the given character is a path separator.
template<class Char >
LEAN_INLINE bool is_extension_separator (Char chr)
 Checks if the given character is an extension separator.
template<class Char >
LEAN_INLINE bool is_redirection (Char chr)
 Checks if the given character is a redirection character.
template<class Char >
LEAN_INLINE Char & assign_path_separator (Char &chr)
 Assigns a path separator to the given character.
template<class Char >
LEAN_INLINE Char & assign_extension_separator (Char &chr)
 Assigns an extension separator to the given character.
template<class Char >
LEAN_INLINE Char & assign_redirection (Char &chr)
 Assigns a redirection character to the given character.
template<class Char >
LEAN_INLINE Char & canonize_path_separator (Char &chr)
 Replaces an alternative path separator by a canonical path separator in the given character.
template<class String , class Range1 , class Range2 >
enable_if_range2< Range1,
Range2, String >::type 
relative_path (const Range1 &base, const Range2 &path)
 Gets the relative path euqivalent to the given absolute path when starting at the given base. Does not resolve redirections, use CanonicalPath prior to calling this function to resolve these.
template<class String , class Chars1 , class Chars2 >
LEAN_INLINE
enable_if_not_range2< Chars1,
Chars2, String >::type 
relative_path (const Chars1 &base, const Chars2 &path)
 Gets the relative path euqivalent to the given absolute path when starting at the given base. Does not resolve redirections, use CanonicalPath prior to calling this function to resolve these.
template<class Chars1 , class Chars2 >
LEAN_INLINE std::basic_string
< typename range_char_type2
< Chars1, Chars2 >::type > 
relative_path (const Chars1 &base, const Chars2 &path)
 Gets the relative path euqivalent to the given absolute path when starting at the given base. Does not resolve redirections, use CanonicalPath prior to calling this function to resolve these.
template<class String , class Range >
enable_if_range< Range, String >
::type 
canonical_path (const Range &path)
 Gets a canonical relative path euqivalent to the given relative path.
template<class String , class Chars >
LEAN_INLINE
enable_if_not_range< Chars,
String >::type 
canonical_path (const Chars &path)
 Gets a canonical relative path euqivalent to the given relative path.
template<class Chars >
LEAN_INLINE std::basic_string
< typename range_char_type
< Chars >::type > 
canonical_path (const Chars &path)
 Gets a canonical relative path euqivalent to the given relative path.
template<class String , class Range1 , class Range2 >
enable_if_range2< Range1,
Range2, String >::type 
append_path (const Range1 &path, const Range2 &file)
 Appends the given file or directory to the given path.
template<class String , class Chars1 , class Chars2 >
LEAN_INLINE
enable_if_not_range2< Chars1,
Chars2, String >::type 
append_path (const Chars1 &path, const Chars2 &file)
 Appends the given file or directory to the given path.
template<class Chars1 , class Chars2 >
LEAN_INLINE std::basic_string
< typename range_char_type2
< Chars1, Chars2 >::type > 
append_path (const Chars1 &path, const Chars2 &file)
 Appends the given file or directory to the given path.
template<class String , class Range1 , class Range2 >
LEAN_INLINE String absolute_path (const Range1 &base, const Range2 &path)
 Gets the absolute path euqivalent to the given relative path.
template<class Chars1 , class Chars2 >
LEAN_INLINE std::basic_string
< typename range_char_type2
< Chars1, Chars2 >::type > 
absolute_path (const Chars1 &base, const Chars2 &path)
 Gets the absolute path euqivalent to the given relative path.
template<class Range >
enable_if_range< Range, bool >
::type 
is_rooted (const Range &path)
 Checks if the given path is rooted.
template<class Chars >
LEAN_INLINE
enable_if_not_range< Chars,
bool >::type 
is_rooted (const Chars &path)
 Checks if the given path is rooted.
template<class String , class Range >
enable_if_range< Range, String >
::type 
absolute_path (const Range &path)
 Gets the absolute path euqivalent to the given relative path.
template<class String , class Chars >
LEAN_INLINE
enable_if_not_range< Chars,
String >::type 
absolute_path (const Chars &path)
 Gets the absolute path euqivalent to the given relative path.
template<class Chars >
LEAN_INLINE std::basic_string
< typename range_char_type
< Chars >::type > 
absolute_path (const Chars &path)
 Gets the absolute path euqivalent to the given relative path.
template<class Iterator >
Iterator get_directory (Iterator fileBegin, Iterator fileEnd)
 Gets the end of the parent directory, e.g. '..' from '../test.txt'.
template<class String , class Range >
LEAN_INLINE String get_directory (const Range &file)
 Gets the parent directory, e.g. '..' from '../test.txt'.
template<class String , class Char >
LEAN_INLINE String get_directory (const Char *file)
 Gets the parent directory, e.g. '..' from '../test.txt'.
template<class Char >
LEAN_INLINE std::basic_string
< Char > 
get_directory (const Char *file)
 Gets the parent directory, e.g. '..' from '../test.txt'.
template<class Iterator >
Iterator get_filename (Iterator fileBegin, Iterator fileEnd)
 Gets the beginning of the file name, e.g. 'test.txt' from '../test.txt'.
template<class String , class Range >
LEAN_INLINE String get_filename (const Range &file)
 Gets the file name, e.g. 'test.txt' from '../test.txt'.
template<class Char >
LEAN_INLINE const Char * get_filename (const Char *file)
 Gets the file name, e.g. 'test.txt' from '../test.txt'.
template<class Iterator >
range< Iterator > get_stem (Iterator fileBegin, Iterator fileEnd)
 Gets the file stem, e.g. 'test' from '../test.txt'.
template<class String , class Range >
LEAN_INLINE String get_stem (const Range &file)
 Gets the file stem, e.g. 'test' from '../test.txt'.
template<class String , class Char >
LEAN_INLINE String get_stem (const Char *file)
 Gets the file stem, e.g. 'test' from '../test.txt'.
template<class Char >
LEAN_INLINE std::basic_string
< Char > 
get_stem (const Char *file)
 Gets the file stem, e.g. 'test' from '../test.txt'.
template<class Iterator >
Iterator get_extension (Iterator fileBegin, Iterator fileEnd)
 Gets the beginning of the file extension, e.g. '.txt' from 'test.txt'.
template<class String , class Range >
LEAN_INLINE String get_extension (const Range &file)
 Gets the file extension, e.g. '.txt' from 'test.txt'.
template<class Char >
LEAN_INLINE const Char * get_extension (const Char *file)
 Gets the file extension, e.g. '.txt' from 'test.txt'.
template<class Type >
LEAN_NOINLINE const serializerget_generic_serializer ()
 Gets the generic serializer for the given type.
template<class Type >
LEAN_NOINLINE const serializerget_int_serializer ()
 Gets the integer serializer for the given type.
template<class Type >
LEAN_NOINLINE const serializerget_float_serializer ()
 Gets the float serializer for the given type.
template<class CharIter , class Integer >
CharIter int_to_char (CharIter buffer, Integer num)
 Converts the given integer of the given type into an ascii character string, returning a pointer to the first character not written to. Does not append a terminating null character.
template<class Integer >
utf8_string int_to_string (Integer num)
 Converts the given integer of the given type into an ascii character string.
template<class CharIter , class Integer >
CharIter char_to_int (CharIter begin, CharIter end, Integer &num)
 Converts the given range of characters into an integer of the given type. Does not require *end to be a terminating null character.
template<class Integer >
bool string_to_int (const utf8_ntri &string, Integer &num)
 Converts the given range of characters into an integer of the given type.
template<class CharIter , class Float >
CharIter float_to_char (CharIter buffer, Float num)
 Converts the given floating-point value of the given type into an ascii character string, returning a pointer to the first character not actively used. Assumes the given iterator points to the beginning of a continuous range in memory. Overwrites *end with a terminating null character.
template<class Float >
utf8_string float_to_string (Float num)
 Converts the given floating-point value of the given type into an ascii character string.
template<class CharIter , class Float >
CharIter char_to_float (CharIter begin, CharIter end, Float &num)
 Converts the given range of characters into a floating-point value of the given type. Assumes the given iterator points to the beginning of a continuous range in memory. Expects *end to be either a terminating null or some other non-numeric character.
template<class Float >
bool string_to_float (const utf8_ntri &string, Float &num)
 Converts the given range of characters into a floating-point value of the given type.
 DECLARE_OPAQUE_TYPE (windows_file_handle, void *)

Detailed Description

Provides I/O utilities such as intrinsic endian conversion, serialization and file classes, etc.