Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_CODEMAKER_GLOBAL_HXX
21 : #define INCLUDED_CODEMAKER_GLOBAL_HXX
22 :
23 : #include <list>
24 : #include <vector>
25 : #include <set>
26 :
27 : #include <stdio.h>
28 :
29 : #include <osl/file.hxx>
30 : #include <rtl/ustring.hxx>
31 : #include <rtl/strbuf.hxx>
32 :
33 : struct LessString
34 : {
35 : bool operator()(const ::rtl::OString& str1, const ::rtl::OString& str2) const
36 : {
37 : return (str1 < str2);
38 : }
39 : };
40 :
41 : typedef ::std::list< ::rtl::OString > StringList;
42 : typedef ::std::vector< ::rtl::OString > StringVector;
43 : typedef ::std::set< ::rtl::OString, LessString > StringSet;
44 :
45 :
46 : // FileStream
47 :
48 : enum FileAccessMode
49 : {
50 : FAM_READ, // "r"
51 : FAM_WRITE, // "w"
52 : FAM_READWRITE_EXIST, // "r+"
53 : FAM_READWRITE // "w+"
54 : };
55 :
56 : class FileStream
57 : {
58 : public:
59 : FileStream();
60 : virtual ~FileStream();
61 :
62 : bool isValid();
63 :
64 : void createTempFile(const ::rtl::OString& sPath);
65 : void close();
66 :
67 18926 : ::rtl::OString getName() { return m_name; }
68 :
69 : bool write(void const * buffer, sal_uInt64 size);
70 :
71 : // friend functions
72 : friend FileStream &operator<<(FileStream& o, sal_uInt32 i);
73 : friend FileStream &operator<<(FileStream& o, char const * s);
74 : friend FileStream &operator<<(FileStream& o, ::rtl::OString* s);
75 : friend FileStream &operator<<(FileStream& o, const ::rtl::OString& s);
76 : friend FileStream &operator<<(FileStream& o, ::rtl::OStringBuffer* s);
77 : friend FileStream &operator<<(FileStream& o, const ::rtl::OStringBuffer& s);
78 : friend FileStream & operator <<(FileStream & out, rtl::OUString const & s);
79 :
80 : private:
81 : oslFileHandle m_file;
82 : ::rtl::OString m_name;
83 : };
84 :
85 :
86 :
87 : // Helper functions
88 :
89 : ::rtl::OString getTempDir(const ::rtl::OString& sFileName);
90 :
91 : ::rtl::OString createFileNameFromType(const ::rtl::OString& destination,
92 : const ::rtl::OString& type,
93 : const ::rtl::OString& postfix,
94 : bool bLowerCase=false,
95 : const ::rtl::OString& prefix="");
96 :
97 : bool fileExists(const ::rtl::OString& fileName);
98 : bool makeValidTypeFile(const ::rtl::OString& targetFileName,
99 : const ::rtl::OString& tmpFileName,
100 : bool bFileCheck);
101 : bool removeTypeFile(const ::rtl::OString& fileName);
102 :
103 : ::rtl::OUString convertToFileUrl(const ::rtl::OString& fileName);
104 :
105 : class CannotDumpException {
106 : public:
107 0 : CannotDumpException(OUString const & message): message_(message) {}
108 :
109 : virtual ~CannotDumpException() throw ();
110 :
111 0 : OUString getMessage() const { return message_; }
112 :
113 : private:
114 : OUString message_;
115 : };
116 :
117 : #endif // INCLUDED_CODEMAKER_GLOBAL_HXX
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|