summaryrefslogtreecommitdiffstats
path: root/tools/slang-cpp-parser/file-util.h
blob: 735758384c7e59cb3d1a52df368dca6aea4f728f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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