findlanabyname-20040228
[openafs.git] / src / WINNT / afssvrcfg / char_conv.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef _H_CHAR_CONVERSION_H_
11 #define _H_CHAR_CONVERSION_H_
12
13
14 /*
15  *  Class to convert a TCHAR string to an ANSI string.
16  */
17 class S2A
18 {
19     char *m_pszAnsi;
20
21 public:
22     S2A(LPCTSTR pszUnicode);
23     ~S2A();
24
25     // Allow casts to char *
26     operator char *() const     { return m_pszAnsi; }
27     operator const char *() const     { return m_pszAnsi; }
28 };
29
30
31
32 /*
33  *  Class to convert an ANSI string to a TCHAR string.  If UNICODE is defined,
34  *  then the TCHAR string will be a UNICODE string, otherwise it will be an
35  *  ANSI string.
36  */
37 class A2S
38 {
39     LPTSTR m_pszUnicode;
40
41 public:
42     A2S(const char *pszAnsi);
43     ~A2S();
44
45     // Allow casts to LPTSTR
46     operator LPTSTR() const     { return m_pszUnicode; }
47     operator LPCTSTR() const     { return m_pszUnicode; }
48 };
49
50 #endif  // _H_CHAR_CONVERSION_H_
51
52