yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Ellie Hermaszewskaformatf65d756bf

master
2.0 KiB72 linesraw
1#ifndef SLANG_CORE_COMMAND_OPTIONS_WRITER_H
2#define SLANG_CORE_COMMAND_OPTIONS_WRITER_H
3
4#include "slang-command-options.h"
5
6namespace Slang
7{
8
9class CommandOptionsWriter : public RefObject
10{
11public:
12    typedef CommandOptions::CategoryKind CategoryKind;
13    typedef CommandOptions::NameKey NameKey;
14    typedef CommandOptions::LookupKind LookupKind;
15
16    enum class Style
17    {
18        Text,           ///< Suitable for output to a terminal
19        Markdown,       ///< Markdown
20        NoLinkMarkdown, ///< Markdown without links
21    };
22
23    static ConstArrayView<NamesDescriptionValue> getStyleInfos();
24
25    struct Options
26    {
27        Style style = Style::Text; ///< The style
28        Index lineLength = 120;    ///< The maximum amount of characters on a line
29        UnownedStringSlice indent = toSlice("  ");
30        ;
31    };
32
33    /// Append descirption for a category
34    void appendDescriptionForCategory(CommandOptions* options, Index categoryIndex);
35    /// Appends a description of all of the options
36    void appendDescription(CommandOptions* options);
37
38    /// Get the builder that string is being written to
39    StringBuilder& getBuilder() { return m_builder; }
40
41    static RefPtr<CommandOptionsWriter> create(const Options& options);
42
43
44protected:
45    /// Append descirption for a category
46    virtual void appendDescriptionForCategoryImpl(Index categoryIndex) = 0;
47    /// Appends a description of all of the options
48    virtual void appendDescriptionImpl() = 0;
49
50    // Ctor, use create to create a writer
51    CommandOptionsWriter(const Options& options);
52
53    /// Get the length of the current line in ascii chars/bytes
54    Count _getCurrentLineLength();
55
56    /// Indentation/wrapping
57    void _requireIndent(Count indentCount);
58    void _appendWrappedIndented(
59        Count indentCount,
60        List<UnownedStringSlice>& slices,
61        const UnownedStringSlice& delimit);
62
63    CommandOptions* m_commandOptions = nullptr;
64
65    StringSlicePool m_pool;
66    StringBuilder m_builder;
67    Options m_options;
68};
69
70} // namespace Slang
71
72#endif