Silicium
c_string.hpp
Go to the documentation of this file.
1 #ifndef SILICIUM_C_STRING_HPP
2 #define SILICIUM_C_STRING_HPP
3 
4 #include <cassert>
5 #include <silicium/is_handle.hpp>
6 
7 namespace Si
8 {
9  template <class Char>
11  {
12  typedef Char char_type;
13 
14  basic_c_string() BOOST_NOEXCEPT
15  : m_begin(nullptr)
16  {
17  }
18 
19  explicit basic_c_string(char_type const *begin)
20  : m_begin(begin)
21  {
22  assert(m_begin);
23  }
24 
25  template <size_t N>
26  basic_c_string(char_type const (&literal)[N])
27  : m_begin(&literal[0])
28  {
29  }
30 
32  bool is_set() const BOOST_NOEXCEPT
33  {
34  return m_begin != nullptr;
35  }
36 
38  bool empty() const BOOST_NOEXCEPT
39  {
40  assert(is_set());
41  return (*m_begin == '\0');
42  }
43 
45  char_type const *c_str() const BOOST_NOEXCEPT
46  {
47  assert(is_set());
48  return m_begin;
49  }
50 
51  private:
52 
53  char_type const *m_begin;
54  };
55 
58 
61 
62  typedef
63 #ifdef _WIN32
64  cw_string
65 #else
66  c_string
67 #endif
69 
71 
72 #ifdef _WIN32
73 # define SILICIUM_SYSTEM_LITERAL(x) L ## x
74 #else
75 # define SILICIUM_SYSTEM_LITERAL(x) x
76 #endif
77 }
78 
79 #endif
Definition: c_string.hpp:10
Char char_type
Definition: c_string.hpp:12
BOOST_STATIC_ASSERT(Si::is_handle< absolute_path >::value)
basic_c_string< wchar_t > cw_string
Definition: c_string.hpp:57
basic_c_string(char_type const *begin)
Definition: c_string.hpp:19
c_string os_c_string
Definition: c_string.hpp:68
Definition: absolute_path.hpp:19
basic_c_string< char > c_string
Definition: c_string.hpp:56
basic_c_string() BOOST_NOEXCEPT
Definition: c_string.hpp:14
SILICIUM_USE_RESULT char_type const * c_str() const BOOST_NOEXCEPT
Definition: c_string.hpp:45
BOOST_CONSTEXPR Iterator const & begin(iterator_range< Iterator > const &range)
Definition: iterator_range.hpp:123
basic_c_string(char_type const (&literal)[N])
Definition: c_string.hpp:26
os_c_string native_path_string
Definition: c_string.hpp:70
SILICIUM_USE_RESULT bool empty() const BOOST_NOEXCEPT
Definition: c_string.hpp:38
SILICIUM_USE_RESULT bool is_set() const BOOST_NOEXCEPT
Definition: c_string.hpp:32
Definition: is_handle.hpp:21
#define SILICIUM_USE_RESULT
Definition: config.hpp:147