sync master with lastest vba changes
[ooovba.git] / rdbmaker / inc / codemaker / global.hxx
blob7a74af4e964943e28563de7cca57e8ac7e64249a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: global.hxx,v $
10 * $Revision: 1.7.8.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CODEMAKER_GLOBAL_HXX_
32 #define _CODEMAKER_GLOBAL_HXX_
34 #include <list>
35 #include <vector>
36 #include <set>
38 #include <stdio.h>
39 #include <rtl/ustring.hxx>
40 #include <rtl/strbuf.hxx>
42 struct EqualString
44 sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
46 return (str1 == str2);
50 struct HashString
52 size_t operator()(const ::rtl::OString& str) const
54 return str.hashCode();
58 struct LessString
60 sal_Bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
62 return (str1 < str2);
66 #if defined(_MSC_VER) && _MSC_VER < 1200
67 typedef ::std::new_alloc NewAlloc;
68 #endif
71 typedef ::std::list< ::rtl::OString > StringList;
72 typedef ::std::vector< ::rtl::OString > StringVector;
73 typedef ::std::set< ::rtl::OString, LessString > StringSet;
75 ::rtl::OString makeTempName();
77 const ::rtl::OString inGlobalSet(const ::rtl::OUString & r);
78 inline const ::rtl::OString inGlobalSet(sal_Char* p)
80 return inGlobalSet( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(p) ) );
83 ::rtl::OUString convertToFileUrl(const ::rtl::OString& fileName);
85 //*************************************************************************
86 // FileStream
87 //*************************************************************************
88 enum FileAccessMode
90 FAM_READ, // "r"
91 FAM_WRITE, // "w"
92 FAM_APPEND, // "a"
93 FAM_READWRITE_EXIST, // "r+"
94 FAM_READWRITE, // "w+"
95 FAM_READAPPEND // "a+"
98 class FileStream //: public ofstream
100 public:
101 FileStream();
102 virtual ~FileStream();
104 sal_Bool isValid();
106 void open(const ::rtl::OString& name, FileAccessMode nMode = FAM_READWRITE);
107 void close();
109 ::rtl::OString getName() { return m_name; }
111 // friend functions
112 friend FileStream &operator<<(FileStream& o, sal_uInt32 i)
113 { fprintf(o.m_pFile, "%lu", sal::static_int_cast< unsigned long >(i));
114 return o;
116 friend FileStream &operator<<(FileStream& o, char const * s)
117 { fprintf(o.m_pFile, "%s", s);
118 return o;
120 friend FileStream &operator<<(FileStream& o, ::rtl::OString* s)
121 { fprintf(o.m_pFile, "%s", s->getStr());
122 return o;
124 friend FileStream &operator<<(FileStream& o, const ::rtl::OString& s)
125 { fprintf(o.m_pFile, "%s", s.getStr());
126 return o;
128 friend FileStream &operator<<(FileStream& o, ::rtl::OStringBuffer* s)
129 { fprintf(o.m_pFile, "%s", s->getStr());
130 return o;
132 friend FileStream &operator<<(FileStream& o, const ::rtl::OStringBuffer& s)
133 { fprintf(o.m_pFile, "%s", s.getStr());
134 return o;
137 protected:
138 const sal_Char* checkAccessMode(FileAccessMode mode);
140 FILE* m_pFile;
141 ::rtl::OString m_name;
144 #endif // _CODEMAKER_GLOBAL_HXX_