stream: add stdex::sstring method variants
This commit is contained in:
parent
475e6734a7
commit
dcfc4752b5
@ -69,12 +69,18 @@
|
|||||||
#ifndef _Inout_opt_
|
#ifndef _Inout_opt_
|
||||||
#define _Inout_opt_
|
#define _Inout_opt_
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef _Inout_z_
|
||||||
|
#define _Inout_z_
|
||||||
|
#endif
|
||||||
#ifndef _Inout_cap_
|
#ifndef _Inout_cap_
|
||||||
#define _Inout_cap_(p)
|
#define _Inout_cap_(p)
|
||||||
#endif
|
#endif
|
||||||
#ifndef _Inout_count_
|
#ifndef _Inout_count_
|
||||||
#define _Inout_count_(p)
|
#define _Inout_count_(p)
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef _Inout_updates_z_
|
||||||
|
#define _Inout_updates_z_(p)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef _Use_decl_annotations_
|
#ifndef _Use_decl_annotations_
|
||||||
#define _Use_decl_annotations_
|
#define _Use_decl_annotations_
|
||||||
|
@ -2454,6 +2454,14 @@ namespace stdex
|
|||||||
open(filename, mode);
|
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
|
/// Opens file
|
||||||
///
|
///
|
||||||
@ -2527,6 +2535,17 @@ namespace stdex
|
|||||||
m_state = state_t::fail;
|
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)
|
virtual fpos_t seek(_In_ foff_t offset, _In_ seek_t how = seek_t::beg)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -2788,6 +2807,15 @@ namespace stdex
|
|||||||
init(m_source);
|
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()
|
virtual ~cached_file()
|
||||||
{
|
{
|
||||||
done();
|
done();
|
||||||
@ -2819,6 +2847,17 @@ namespace stdex
|
|||||||
m_state = state_t::fail;
|
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:
|
protected:
|
||||||
file m_source;
|
file m_source;
|
||||||
};
|
};
|
||||||
@ -2910,6 +2949,14 @@ namespace stdex
|
|||||||
load(filename, mode);
|
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()
|
virtual ~memory_file()
|
||||||
{
|
{
|
||||||
if (m_manage && m_data)
|
if (m_manage && m_data)
|
||||||
@ -2978,6 +3025,17 @@ namespace stdex
|
|||||||
#endif
|
#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
|
/// Saves content to a file-system file
|
||||||
///
|
///
|
||||||
@ -3002,7 +3060,18 @@ namespace stdex
|
|||||||
f.set_atime(m_atime);
|
f.set_atime(m_atime);
|
||||||
f.set_mtime(m_mtime);
|
f.set_mtime(m_mtime);
|
||||||
#endif
|
#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
|
/// Returns pointer to data
|
||||||
|
@ -1286,4 +1286,71 @@ namespace stdex
|
|||||||
va_end(arg);
|
va_end(arg);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Convert string to lower-case character-by-character
|
||||||
|
///
|
||||||
|
/// \note For legacy code support only.
|
||||||
|
///
|
||||||
|
/// \param[in,out] str String
|
||||||
|
///
|
||||||
|
template<class T>
|
||||||
|
inline void strlwr(_Inout_z_ T* str, _In_ const std::locale& locale)
|
||||||
|
{
|
||||||
|
assert(str);
|
||||||
|
const auto& ctype = std::use_facet<std::ctype<T>>(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<class T>
|
||||||
|
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<std::ctype<T>>(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<class T>
|
||||||
|
inline void strupr(_Inout_z_ T* str, _In_ const std::locale& locale)
|
||||||
|
{
|
||||||
|
assert(str);
|
||||||
|
const auto& ctype = std::use_facet<std::ctype<T>>(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<class T>
|
||||||
|
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<std::ctype<T>>(locale);
|
||||||
|
for (size_t i = 0; i < count && str[i]; ++i)
|
||||||
|
str[i] = ctype.toupper(str[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user