LibreOffice Module codemaker (master) 1
global.hxx
Go to the documentation of this file.
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 <utility>
24#include <vector>
25#include <string_view>
26
27#include <osl/file.hxx>
28#include <rtl/ustring.hxx>
29#include <rtl/strbuf.hxx>
30
31typedef ::std::vector< ::rtl::OString > StringVector;
32
33
34// FileStream
35
36class FileStream final
37{
38public:
39 FileStream();
41
42 bool isValid() const;
43
44 void createTempFile(const ::rtl::OString& sPath);
45 void close();
46
47 const ::rtl::OString& getName() const { return m_name; }
48
49 bool write(void const * buffer, sal_uInt64 size);
50
51 // friend functions
52 friend FileStream &operator<<(FileStream& o, sal_uInt32 i);
53 friend FileStream &operator<<(FileStream& o, char const * s);
54 friend FileStream &operator<<(FileStream& o, ::rtl::OString const * s);
55 friend FileStream &operator<<(FileStream& o, const ::rtl::OString& s);
56 friend FileStream &operator<<(FileStream& o, ::rtl::OStringBuffer const * s);
57 friend FileStream &operator<<(FileStream& o, const ::rtl::OStringBuffer& s);
58 friend FileStream & operator <<(FileStream & out, std::u16string_view s);
59
60private:
61 oslFileHandle m_file;
62 ::rtl::OString m_name;
63};
64
65
66// Helper functions
67
68::rtl::OString getTempDir(const ::rtl::OString& sFileName);
69
70::rtl::OString createFileNameFromType(const ::rtl::OString& destination,
71 const ::rtl::OString& type,
72 const ::rtl::OString& postfix);
73
74bool fileExists(const ::rtl::OString& fileName);
75bool makeValidTypeFile(const ::rtl::OString& targetFileName,
76 const ::rtl::OString& tmpFileName,
77 bool bFileCheck);
78bool removeTypeFile(const ::rtl::OString& fileName);
79
80::rtl::OUString convertToFileUrl(const ::rtl::OString& fileName);
81
83public:
84 CannotDumpException(OUString message): message_(std::move(message)) {}
85
86 ~CannotDumpException() noexcept;
87
88 const OUString& getMessage() const { return message_; }
89
90private:
91 OUString message_;
92};
93
94#endif // INCLUDED_CODEMAKER_GLOBAL_HXX
95
96/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const OUString & getMessage() const
Definition: global.hxx:88
~CannotDumpException() noexcept
Definition: global.cxx:364
CannotDumpException(OUString message)
Definition: global.hxx:84
OUString message_
Definition: global.hxx:91
~FileStream() override
Definition: global.cxx:262
SW_DLLPUBLIC std::ostream & operator<<(std::ostream &s, const SwContentIndex &index)
::std::vector< ::rtl::OString > StringVector
Definition: global.hxx:31
::rtl::OUString convertToFileUrl(const ::rtl::OString &fileName)
bool removeTypeFile(const ::rtl::OString &fileName)
bool makeValidTypeFile(const ::rtl::OString &targetFileName, const ::rtl::OString &tmpFileName, bool bFileCheck)
::rtl::OString createFileNameFromType(const ::rtl::OString &destination, const ::rtl::OString &type, const ::rtl::OString &postfix)
::rtl::OString getTempDir(const ::rtl::OString &sFileName)
bool fileExists(const ::rtl::OString &fileName)
size
int i