MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / parse

Method parse

source/core/StarDirectives.cpp:126–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126void Directives::parse(String&& directives) {
127 if (directives.empty()) {
128 m_shared.reset();
129 return;
130 }
131
132 List<Entry> entries;
133 StringView view(directives);
134 view.forEachSplitView("?", [&](StringView split, size_t beg, size_t end) {
135 if (!split.empty()) {
136 ImageOperation operation = NullImageOperation();
137 if (beg == 0) {
138 try
139 { operation = imageOperationFromString(split); }
140 catch (StarException const& e)
141 { operation = ErrorImageOperation{std::exception_ptr()}; }
142 }
143 entries.emplace_back(std::move(operation), beg, end);
144 }
145 });
146
147 if (entries.empty()) {
148 m_shared.reset();
149 return;
150 }
151
152 m_shared = std::make_shared<Shared const>(std::move(entries), std::move(directives));
153 if (view.utf8().size() < 1000) { // Pre-load short enough directives
154 for (auto& entry : m_shared->entries)
155 entry.loadOperation(*m_shared);
156 }
157}
158
159StringView Directives::prefix() const {
160 if (!m_shared)

Callers 1

StarDirectives.cppFile · 0.45

Calls 7

NullImageOperationClass · 0.85
imageOperationFromStringFunction · 0.85
forEachSplitViewMethod · 0.80
emptyMethod · 0.45
resetMethod · 0.45
emplace_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected