diff --git a/include/stdex/compat.hpp b/include/stdex/compat.hpp index 961555d69..314877a71 100644 --- a/include/stdex/compat.hpp +++ b/include/stdex/compat.hpp @@ -69,12 +69,18 @@ #ifndef _Inout_opt_ #define _Inout_opt_ #endif +#ifndef _Inout_z_ +#define _Inout_z_ +#endif #ifndef _Inout_cap_ #define _Inout_cap_(p) #endif #ifndef _Inout_count_ #define _Inout_count_(p) #endif +#ifndef _Inout_updates_z_ +#define _Inout_updates_z_(p) +#endif #ifndef _Use_decl_annotations_ #define _Use_decl_annotations_ diff --git a/include/stdex/stream.hpp b/include/stdex/stream.hpp index 360a4c7ae..4b0e246d0 100644 --- a/include/stdex/stream.hpp +++ b/include/stdex/stream.hpp @@ -2454,6 +2454,14 @@ namespace stdex open(filename, mode); } + /// + /// Opens file + /// + /// \param[in] filename Filename + /// \param[in] mode Bitwise combination of mode_t flags + /// + inline file(_In_ const stdex::sstring& filename, _In_ int mode) : file(filename.c_str(), mode) {} + /// /// Opens file /// @@ -2527,6 +2535,17 @@ namespace stdex m_state = state_t::fail; } + /// + /// Opens file + /// + /// \param[in] filename Filename + /// \param[in] mode Bitwise combination of mode_t flags + /// + inline void open(_In_ const stdex::sstring& filename, _In_ int mode) + { + open(filename.c_str(), mode); + } + virtual fpos_t seek(_In_ foff_t offset, _In_ seek_t how = seek_t::beg) { #ifdef _WIN32 @@ -2788,6 +2807,15 @@ namespace stdex init(m_source); } + /// + /// Opens file + /// + /// \param[in] filename Filename + /// \param[in] mode Bitwise combination of mode_t flags + /// \param[in] cache_size Size of the cache block + /// + inline cached_file(_In_ const stdex::sstring& filename, _In_ int mode, _In_ size_t cache_size = default_cache_size) : cached_file(filename.c_str(), mode, cache_size) {} + virtual ~cached_file() { done(); @@ -2819,6 +2847,17 @@ namespace stdex m_state = state_t::fail; } + /// + /// Opens file + /// + /// \param[in] filename Filename + /// \param[in] mode Bitwise combination of mode_t flags + /// + inline void open(_In_ const stdex::sstring& filename, _In_ int mode) + { + open(filename.c_str(), mode); + } + protected: file m_source; }; @@ -2910,6 +2949,14 @@ namespace stdex load(filename, mode); } + /// + /// Loads content from file-system file + /// + /// \param[in] filename Filename + /// \param[in] mode Bitwise combination of mode_t flags + /// + inline memory_file(_In_ const stdex::sstring& filename, _In_ int mode) : memory_file(filename.c_str(), mode) {} + virtual ~memory_file() { if (m_manage && m_data) @@ -2978,6 +3025,17 @@ namespace stdex #endif } + /// + /// Loads content from a file-system file + /// + /// \param[in] filename Filename + /// \param[in] mode Bitwise combination of mode_t flags + /// + inline void load(_In_ const stdex::sstring& filename, _In_ int mode) + { + load(filename.c_str(), mode); + } + /// /// Saves content to a file-system file /// @@ -3002,7 +3060,18 @@ namespace stdex f.set_atime(m_atime); f.set_mtime(m_mtime); #endif - } + } + + /// + /// Saves content to a file-system file + /// + /// \param[in] filename Filename + /// \param[in] mode Bitwise combination of mode_t flags + /// + inline void save(_In_ const stdex::sstring& filename, _In_ int mode) + { + save(filename.c_str(), mode); + } /// /// Returns pointer to data diff --git a/include/stdex/string.hpp b/include/stdex/string.hpp index 1ab6e4f5f..c647aa5ea 100644 --- a/include/stdex/string.hpp +++ b/include/stdex/string.hpp @@ -1286,4 +1286,71 @@ namespace stdex va_end(arg); return str; } + + /// + /// Convert string to lower-case character-by-character + /// + /// \note For legacy code support only. + /// + /// \param[in,out] str String + /// + template + inline void strlwr(_Inout_z_ T* str, _In_ const std::locale& locale) + { + assert(str); + const auto& ctype = std::use_facet>(locale); + for (size_t i = 0; str[i]; ++i) + str[i] = ctype.tolower(str[i]); + } + + /// + /// Convert string to lower-case character-by-character + /// + /// \note For legacy code support only. + /// + /// \param[in,out] str String + /// \param[in] count Code unit limit + /// + template + inline void strlwr(_Inout_updates_z_(count) T* str, _In_ size_t count, _In_ const std::locale& locale) + { + assert(str || !count); + const auto& ctype = std::use_facet>(locale); + for (size_t i = 0; i < count && str[i]; ++i) + str[i] = ctype.tolower(str[i]); + } + + /// + /// Convert string to upper-case character-by-character + /// + /// \note For legacy code support only. + /// + /// \param[in,out] str String + /// + template + inline void strupr(_Inout_z_ T* str, _In_ const std::locale& locale) + { + assert(str); + const auto& ctype = std::use_facet>(locale); + for (size_t i = 0; str[i]; ++i) + str[i] = ctype.toupper(str[i]); + } + + /// + /// Convert string to upper-case character-by-character + /// + /// \note For legacy code support only. + /// + /// \param[in,out] str String + /// \param[in] count Code unit limit + /// + template + inline void strupr + (_Inout_updates_z_(count) T* str, _In_ size_t count, _In_ const std::locale& locale) + { + assert(str || !count); + const auto& ctype = std::use_facet>(locale); + for (size_t i = 0; i < count && str[i]; ++i) + str[i] = ctype.toupper(str[i]); + } }