NSVD Reader  0.0.1
string_type.hpp
Go to the documentation of this file.
1 
5 /*
6  * These codes are licensed under CC0.
7  * http://creativecommons.org/publicdomain/zero/1.0/
8  */
9 #ifndef __NODAMUSHI_STRING_TYPE_HPP__
10 #define __NODAMUSHI_STRING_TYPE_HPP__
11 
12 # include <cstdint>
13 # include <string>
14 # include <ostream>
15 # include <unordered_map>
16 # include <vector>
17 # if __cplusplus >= 201703
18 # include <iterator>
19 # include <string_view>
20 # include <optional>
21 # endif
22 
23 namespace nodamushi{
24 
25 # if __cplusplus >= 201703
26 // C++17
27 
28 using const_string = std::string_view;
29 using string_ref = std::string_view;
30 using substring = std::string_view;
31 #define NODAMUSHI_CONSTEXPR_STRING constexpr std::string_view
32 constexpr auto find_npos = std::string_view::npos;
33 using str_mapkey = std::string_view;
34 
35 template<typename ITR,typename ITR_END>
36 void emplace_back_string(std::vector<std::string_view>& v,ITR itr,ITR_END end)
37 {
38  v.emplace_back(itr,std::distance(itr,end));
39 }
40 # else
41 // C++14
42 
43 using const_string = const char*;
44 using string_ref = const std::string&;
45 using substring = std::string;
46 #define NODAMUSHI_CONSTEXPR_STRING std::string
47 constexpr auto find_npos = std::string::npos;
48 
49 using str_mapkey = std::string;
50 # endif
51 template<typename V>
52 using str_map = std::unordered_map<str_mapkey, V>;
53 
54 
55 template<typename ITR,typename ITR_END>
56 void emplace_back_string(std::vector<std::string>& v,ITR itr,ITR_END end)
57 {
58  v.emplace_back(itr,end);
59 }
60 
61 
62 } // end namespace nodamushi
63 
64 #endif // __NODAMUSHI_STRING_TYPE_HPP__
65 
66 
const std::string & string_ref
Definition: string_type.hpp:44
constexpr auto find_npos
Definition: string_type.hpp:47
const char * const_string
Definition: string_type.hpp:43
std::string str_mapkey
Definition: string_type.hpp:49
std::string substring
Definition: string_type.hpp:45
std::unordered_map< str_mapkey, V > str_map
Definition: string_type.hpp:52
void emplace_back_string(std::vector< std::string > &v, ITR itr, ITR_END end)
Definition: string_type.hpp:56