/src/log4cplus/include/log4cplus/tstring.h
Line | Count | Source |
1 | | // -*- C++ -*- |
2 | | // Module: Log4CPLUS |
3 | | // File: tstring.h |
4 | | // Created: 4/2003 |
5 | | // Author: Tad E. Smith |
6 | | // |
7 | | // |
8 | | // Copyright 2003-2017 Tad E. Smith |
9 | | // |
10 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
11 | | // you may not use this file except in compliance with the License. |
12 | | // You may obtain a copy of the License at |
13 | | // |
14 | | // http://www.apache.org/licenses/LICENSE-2.0 |
15 | | // |
16 | | // Unless required by applicable law or agreed to in writing, software |
17 | | // distributed under the License is distributed on an "AS IS" BASIS, |
18 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
19 | | // See the License for the specific language governing permissions and |
20 | | // limitations under the License. |
21 | | |
22 | | /** @file */ |
23 | | |
24 | | #ifndef LOG4CPLUS_TSTRING_HEADER_ |
25 | | #define LOG4CPLUS_TSTRING_HEADER_ |
26 | | |
27 | | #include <log4cplus/config.hxx> |
28 | | |
29 | | #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) |
30 | | #pragma once |
31 | | #endif |
32 | | |
33 | | #include <string> |
34 | | #include <log4cplus/tchar.h> |
35 | | |
36 | | namespace log4cplus |
37 | | { |
38 | | |
39 | | typedef std::basic_string<tchar> tstring; |
40 | | |
41 | | |
42 | | namespace helpers |
43 | | { |
44 | | |
45 | | inline |
46 | | std::string |
47 | | tostring (char const * str) |
48 | 0 | { |
49 | 0 | return std::string (str); |
50 | 0 | } |
51 | | |
52 | | inline |
53 | | std::string |
54 | | tostring (std::string const & str) |
55 | 0 | { |
56 | 0 | return str; |
57 | 0 | } |
58 | | |
59 | | inline |
60 | | std::string const & |
61 | | tostring (std::string & str) |
62 | 0 | { |
63 | 0 | return str; |
64 | 0 | } |
65 | | |
66 | | inline |
67 | | std::string |
68 | | tostring (std::string && str) |
69 | 0 | { |
70 | 0 | return std::move (str); |
71 | 0 | } |
72 | | |
73 | | |
74 | | inline |
75 | | std::wstring |
76 | | towstring (wchar_t const * str) |
77 | 0 | { |
78 | 0 | return std::wstring (str); |
79 | 0 | } |
80 | | |
81 | | inline |
82 | | std::wstring |
83 | | towstring (std::wstring const & str) |
84 | 0 | { |
85 | 0 | return str; |
86 | 0 | } |
87 | | |
88 | | inline |
89 | | std::wstring const & |
90 | | towstring (std::wstring & str) |
91 | 0 | { |
92 | 0 | return str; |
93 | 0 | } |
94 | | |
95 | | inline |
96 | | std::wstring |
97 | | towstring (std::wstring && str) |
98 | 0 | { |
99 | 0 | return std::move (str); |
100 | 0 | } |
101 | | |
102 | | |
103 | | LOG4CPLUS_EXPORT std::string tostring(const std::wstring&); |
104 | | LOG4CPLUS_EXPORT std::string tostring(wchar_t const *); |
105 | | |
106 | | LOG4CPLUS_EXPORT std::wstring towstring(const std::string&); |
107 | | LOG4CPLUS_EXPORT std::wstring towstring(char const *); |
108 | | |
109 | | } // namespace helpers |
110 | | |
111 | | #ifdef UNICODE |
112 | | |
113 | | #define LOG4CPLUS_C_STR_TO_TSTRING(STRING) log4cplus::helpers::towstring(STRING) |
114 | | #define LOG4CPLUS_STRING_TO_TSTRING(STRING) log4cplus::helpers::towstring(STRING) |
115 | | #define LOG4CPLUS_TSTRING_TO_STRING(STRING) log4cplus::helpers::tostring(STRING) |
116 | | |
117 | | #else // UNICODE |
118 | | |
119 | 1.21M | #define LOG4CPLUS_C_STR_TO_TSTRING(STRING) (std::string(STRING)) |
120 | 0 | #define LOG4CPLUS_STRING_TO_TSTRING(STRING) STRING |
121 | 61.9k | #define LOG4CPLUS_TSTRING_TO_STRING(STRING) STRING |
122 | | |
123 | | #endif // UNICODE |
124 | | |
125 | | } // namespace log4cplus |
126 | | |
127 | | |
128 | | #endif // LOG4CPLUS_TSTRING_HEADER_ |