From eaa8dcfcc9deabb906cc09bf31fc17ab6f343ff4 Mon Sep 17 00:00:00 2001 From: Lauro Oyen <15063951+laurooyen@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:46:43 +0100 Subject: 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 Co-authored-by: Yong He --- tools/slang-cpp-parser/file-util.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tools/slang-cpp-parser/file-util.h (limited to 'tools/slang-cpp-parser/file-util.h') 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 -- cgit v1.2.3