update dev300-m58
[ooovba.git] / reportdesign / source / inc / constasciistring.hxx
blobf4d6246ac01f8ca81f14a4785f89b42a24bce72b
1 #ifndef _RPTSHARED_CONSTASCIISTRING_HXX_
2 #define _RPTSHARED_CONSTASCIISTRING_HXX_
4 #ifndef CONSTASCII_INCLUDED_INDIRECT
5 #error "don't include this file directly! use stringconstants.hrc instead!"
6 #endif
8 // no namespaces. This file is included from several other files _within_ a namespace.
10 //============================================================
11 //= a helper for static ascii pseudo-unicode strings
12 //============================================================
13 // string constants
14 struct ConstAsciiString
16 const sal_Char* ascii;
17 sal_Int32 length;
19 inline operator const ::rtl::OUString& () const;
20 inline operator const sal_Char* () const { return ascii; }
22 inline ConstAsciiString(const sal_Char* _pAsciiZeroTerminated, const sal_Int32 _nLength);
23 inline ~ConstAsciiString();
25 private:
26 mutable ::rtl::OUString* ustring;
29 //------------------------------------------------------------
30 inline ConstAsciiString::ConstAsciiString(const sal_Char* _pAsciiZeroTerminated, const sal_Int32 _nLength)
31 :ascii(_pAsciiZeroTerminated)
32 ,length(_nLength)
33 ,ustring(NULL)
37 //------------------------------------------------------------
38 inline ConstAsciiString::~ConstAsciiString()
40 delete ustring;
41 ustring = NULL;
44 //------------------------------------------------------------
45 inline ConstAsciiString::operator const ::rtl::OUString& () const
47 if (!ustring)
48 ustring = new ::rtl::OUString(ascii, length, RTL_TEXTENCODING_ASCII_US);
49 return *ustring;
52 //============================================================
54 #define DECLARE_CONSTASCII_USTRING( name ) \
55 extern const ConstAsciiString name
57 #define IMPLEMENT_CONSTASCII_USTRING( name, string ) \
58 const ConstAsciiString name(string, sizeof(string)-1)
61 #endif // _RPTSHARED_CONSTASCIISTRING_HXX_