merge the formfield patch from ooo-build
[ooovba.git] / rdbmaker / inc / codemaker / global.hxx
blobdce729f37692a1e77a6674838f2989835a96dda3
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);
79 ::rtl::OUString convertToFileUrl(const ::rtl::OString& fileName);
81 //*************************************************************************
82 // FileStream
83 //*************************************************************************
84 enum FileAccessMode
86 FAM_READ, // "r"
87 FAM_WRITE, // "w"
88 FAM_APPEND, // "a"
89 FAM_READWRITE_EXIST, // "r+"
90 FAM_READWRITE, // "w+"
91 FAM_READAPPEND // "a+"
94 class FileStream //: public ofstream
96 public:
97 FileStream();
98 virtual ~FileStream();
100 sal_Bool isValid();
102 void open(const ::rtl::OString& name, FileAccessMode nMode = FAM_READWRITE);
103 void close();
105 ::rtl::OString getName() { return m_name; }
107 // friend functions
108 friend FileStream &operator<<(FileStream& o, sal_uInt32 i)
109 { fprintf(o.m_pFile, "%lu", sal::static_int_cast< unsigned long >(i));
110 return o;
112 friend FileStream &operator<<(FileStream& o, char const * s)
113 { fprintf(o.m_pFile, "%s", s);
114 return o;
116 friend FileStream &operator<<(FileStream& o, ::rtl::OString* s)
117 { fprintf(o.m_pFile, "%s", s->getStr());
118 return o;
120 friend FileStream &operator<<(FileStream& o, const ::rtl::OString& s)
121 { fprintf(o.m_pFile, "%s", s.getStr());
122 return o;
124 friend FileStream &operator<<(FileStream& o, ::rtl::OStringBuffer* s)
125 { fprintf(o.m_pFile, "%s", s->getStr());
126 return o;
128 friend FileStream &operator<<(FileStream& o, const ::rtl::OStringBuffer& s)
129 { fprintf(o.m_pFile, "%s", s.getStr());
130 return o;
133 protected:
134 const sal_Char* checkAccessMode(FileAccessMode mode);
136 FILE* m_pFile;
137 ::rtl::OString m_name;
140 #endif // _CODEMAKER_GLOBAL_HXX_