diff options
| author | Lauro Oyen <15063951+laurooyen@users.noreply.github.com> | 2024-12-02 20:46:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-02 11:46:43 -0800 |
| commit | eaa8dcfcc9deabb906cc09bf31fc17ab6f343ff4 (patch) | |
| tree | 8e0f4658de3efb5e7696e8588c55471f9d65ba18 /tools/slang-cpp-parser/file-util.h | |
| parent | 7aaf7009e2c6055a714ba4a93ab3dd73d2d2cdb7 (diff) | |
Move c++ parsing code from slang-cpp-extractor to static library (#5675)
* Move c++ parsing code from slang-cpp-extractor to static library
* Format code
* Remove relative includes
---------
Co-authored-by: slangbot <ellieh+slangbot@nvidia.com>
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tools/slang-cpp-parser/file-util.h')
| -rw-r--r-- | tools/slang-cpp-parser/file-util.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/slang-cpp-parser/file-util.h b/tools/slang-cpp-parser/file-util.h new file mode 100644 index 000000000..735758384 --- /dev/null +++ b/tools/slang-cpp-parser/file-util.h @@ -0,0 +1,31 @@ +#pragma once + +#include "diagnostics.h" + +namespace CppParse +{ +using namespace Slang; + +// A macro to define a single indent as a string +#define CPP_EXTRACT_INDENT_STRING " " + +struct FileUtil +{ + /// Read text into outRead. Any failures written to sink (can be passed as nullptr, for no + /// output) + static SlangResult readAllText( + const Slang::String& fileName, + DiagnosticSink* sink, + String& outRead); + /// Write text to filename. Any failures written to sink. (can be passed as nullptr, for no + /// output) + static SlangResult writeAllText( + const Slang::String& fileName, + DiagnosticSink* sink, + const UnownedStringSlice& text); + + /// Appends CPP_EXTRACT_INDENT_STRING indentCount number of times to out + static void indent(Index indentCount, StringBuilder& out); +}; + +} // namespace CppParse |
