1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
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/.
15 #include <string_view>
20 CSharpFile(std::string_view directory
, std::string_view typeName
)
21 : m_filePath(createFilePath(directory
, typeName
))
26 std::string
getPath() const { return m_filePath
.string(); }
30 std::filesystem::create_directories(m_filePath
.parent_path());
31 m_fileStream
.open(m_filePath
, std::fstream::out
| std::fstream::trunc
);
34 void closeFile() { m_fileStream
.close(); }
36 CSharpFile
& beginBlock()
44 CSharpFile
& endBlock()
53 CSharpFile
& beginLine()
55 for (int i
= 0; i
< m_indentLevel
; i
++)
62 CSharpFile
& extraIndent()
68 CSharpFile
& append(std::string_view item
)
74 CSharpFile
& append(std::u16string_view item
)
76 m_fileStream
<< u2b(item
);
87 static std::filesystem::path
createFilePath(std::string_view dir
, std::string_view type
)
89 std::string
subdir(type
);
90 for (char& c
: subdir
)
94 std::filesystem::path
path(dir
);
95 path
/= subdir
+ ".cs";
100 std::filesystem::path m_filePath
;
101 std::ofstream m_fileStream
;
102 int m_indentLevel
= 0;
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */