summaryrefslogtreecommitdiffstats
path: root/tools/slang-cpp-extractor/options.h
blob: 14ef9ecfcf8d7842a3c230f07623cd32aaba173c (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef CPP_EXTRACT_OPTIONS_H
#define CPP_EXTRACT_OPTIONS_H

#include "../../source/slang/slang-diagnostics.h"

namespace CppExtract {
using namespace Slang;


// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Options !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

struct Options
{
    void reset()
    {
        *this = Options();
    }

    Options()
    {
        m_markPrefix = "SLANG_";
        m_markSuffix = "_CLASS";
    }

    bool m_defs = false;            ///< If set will output a '-defs.h' file for each of the input files, that corresponds to previous defs files (although doesn't have fields/RAW)
    bool m_dump = false;            ///< If true will dump to stderr the types/fields and hierarchy it extracted
    bool m_runUnitTests = false;    ///< If true will run internal unit tests

    bool m_outputFields = false;     ///< When dumping macros also dump field definitions

    List<String> m_inputPaths;      ///< The input paths to the files to be processed

    String m_outputPath;            ///< The output path. Note that the extractor can generate multiple output files, and this will actually be the 'stem' of several files

    String m_inputDirectory;        ///< The input directory that is by default used for reading m_inputPaths from. 
    String m_markPrefix;            ///< The prefix of the 'marker' used to identify a reflected type
    String m_markSuffix;            ///< The postfix of the 'marker' used to identify a reflected type
    String m_stripFilePrefix;       ///< Used for the 'origin' information, this is stripped from the source filename, and the remainder of the filename (without extension) is 'macroized'
};

struct OptionsParser
{
    /// Parse the parameters. NOTE! Must have the program path removed
    SlangResult parse(int argc, const char*const* argv, DiagnosticSink* sink, Options& outOptions);

    SlangResult _parseArgWithValue(const char* option, String& outValue);
    SlangResult _parseArgReplaceValue(const char* option, String& outValue);
    SlangResult _parseArgFlag(const char* option, bool& outFlag);

    String m_reflectType;

    Index m_index;
    Int m_argCount;
    const char*const* m_args;
    DiagnosticSink* m_sink;
};


} // CppExtract

#endif