1 // -*- C++ -*-
2 // Module:  Log4CPLUS
3 // File:    tstring.h
4 // Created: 4/2003
5 // Author:  Tad E. Smith
6 //
7 //
8 // Copyright 2003-2010 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 DCMTK_LOG4CPLUS_TSTRING_HEADER_
25 #define DCMTK_LOG4CPLUS_TSTRING_HEADER_
26 
27 #include "dcmtk/oflog/config.h"
28 
29 #if defined (DCMTK_LOG4CPLUS_HAVE_PRAGMA_ONCE)
30 #pragma once
31 #endif
32 
33 #include "dcmtk/ofstd/ofstring.h"
34 #include "dcmtk/oflog/tchar.h"
35 
36 namespace dcmtk
37 {
38 namespace log4cplus
39 {
40 
41 typedef OFString tstring;
42 
43 
44 namespace helpers
45 {
46 
47 inline
48 OFString
tostring(char const * str)49 tostring (char const * str)
50 {
51     return OFString (str);
52 }
53 
54 
55 inline
56 OFString
tostring(OFString const & str)57 tostring (OFString const & str)
58 {
59     return str;
60 }
61 
62 
63 
64 inline
65 STD_NAMESPACE wstring
towstring(wchar_t const * str)66 towstring (wchar_t const * str)
67 {
68     return STD_NAMESPACE wstring (str);
69 }
70 
71 inline
72 STD_NAMESPACE wstring
towstring(STD_NAMESPACE wstring const & str)73 towstring (STD_NAMESPACE wstring const & str)
74 {
75     return str;
76 }
77 
78 DCMTK_LOG4CPLUS_EXPORT OFString tostring(const STD_NAMESPACE wstring&);
79 DCMTK_LOG4CPLUS_EXPORT OFString tostring(wchar_t const *);
80 
81 DCMTK_LOG4CPLUS_EXPORT STD_NAMESPACE wstring towstring(const OFString&);
82 DCMTK_LOG4CPLUS_EXPORT STD_NAMESPACE wstring towstring(char const *);
83 
84 } // namespace helpers
85 
86 #ifdef DCMTK_OFLOG_UNICODE
87 
88 #define DCMTK_LOG4CPLUS_C_STR_TO_TSTRING(STRING) log4cplus::helpers::towstring(STRING)
89 #define DCMTK_LOG4CPLUS_STRING_TO_TSTRING(STRING) log4cplus::helpers::towstring(STRING)
90 #define DCMTK_LOG4CPLUS_TSTRING_TO_STRING(STRING) log4cplus::helpers::tostring(STRING)
91 
92 #else // DCMTK_OFLOG_UNICODE
93 
94 #define DCMTK_LOG4CPLUS_C_STR_TO_TSTRING(STRING) OFString(STRING)
95 #define DCMTK_LOG4CPLUS_STRING_TO_TSTRING(STRING) STRING
96 #define DCMTK_LOG4CPLUS_TSTRING_TO_STRING(STRING) STRING
97 
98 #endif // DCMTK_OFLOG_UNICODE
99 
100 } // namespace log4cplus
101 } // end namespace dcmtk
102 
103 
104 #endif // DCMTK_LOG4CPLUS_TSTRING_HEADER_
105