13#include <unordered_map>
53 void parse(std::string_view rawCommandSegment);
81 std::string_view resourceName,
86 std::string_view resourceName,
93 std::string_view resourceName,
111 std::string_view executorName,
122 std::string_view packetName,
128 struct CommandHeader final
131 std::string targetCategory;
132 std::string targetType;
133 std::string executorName;
134 std::string dataPacketName;
135 std::string reference;
136 std::string dataString;
138 bool isRecognized()
const;
143 std::unordered_map<std::string, const SdlClass*> m_mangledNameToClass;
144 std::unique_ptr<SdlDataPacketInterface> m_packetInterface;
146 Path m_sceneWorkingDirectory;
147 bool m_isInSingleLineComment;
148 std::string m_processedCommandCache;
149 std::size_t m_generatedNameCounter;
150 std::size_t m_numParsedCommands;
151 std::size_t m_numParseErrors;
158 void enterProcessed(std::string_view processedCommandSegment);
160 void parseCommand(
const std::string& command);
161 void parseSingleCommand(
const CommandHeader& command);
163 void parseLoadCommand(
const CommandHeader& command);
164 void parseExecutionCommand(
const CommandHeader& command);
165 void parseDirectiveCommand(
const CommandHeader& command);
166 void parseNamedDataPacketCommand(
const CommandHeader& command);
171 std::string_view packetCommand,
173 std::string_view targetName,
177 const SdlClass* getSdlClass(
const std::string& mangledClassName)
const;
178 const SdlClass* getSdlClass(std::string_view categoryName, std::string_view typeName)
const;
181 static std::string getMangledName(std::string_view categoryName, std::string_view typeName);
182 static void getMangledName(std::string_view categoryName, std::string_view typeName, std::string* out_mangledName);
183 static CommandHeader parseCommandHeader(std::string_view command);
190 return m_sceneWorkingDirectory;
195 return m_commandVersion;
200 return m_numParsedCommands;
205 return m_numParseErrors;
208inline bool SdlCommandParser::CommandHeader::isRecognized()
const
Interface for all SDL resource.
Definition ISdlResource.h:22
General path representation. Does not check whether the target actually exists (e....
Definition Path.h:21
Definition SdlCommandParser.h:32
SdlCommandParser(TSpanView< const SdlClass * > targetClasses)
Definition SdlCommandParser.cpp:33
virtual ISdlResource * createResource(std::string_view resourceName, const SdlInputContext &ctx, ESdlCommandType commandType)=0
virtual ~SdlCommandParser()
virtual bool beginCommand(ESdlCommandType commandType, const SdlClass *targetClass, SdlInputContext *out_ctx)=0
Called when the parser starts processing a command.
virtual void storeNamedDataPacket(std::string_view packetName, const SdlInputClauses &packet, const SdlInputContext &ctx)=0
virtual ISdlResource * getResource(std::string_view resourceName, const SdlInputContext &ctx)=0
virtual void runExecutor(std::string_view executorName, const SdlInputContext &ctx, ISdlResource *targetResource, SdlInputClauses &clauses, ESdlCommandType commandType)=0
Called when an executor command has been processed and is ready to run.
virtual void initResource(std::string_view resourceName, ISdlResource *resource, const SdlInputContext &ctx, SdlInputClauses &clauses, ESdlCommandType commandType)=0
SdlDataPacketInterface & getPacketInterface()
Definition SdlCommandParser.cpp:78
void setSceneWorkingDirectory(const Path &directory)
Definition SdlCommandParser.cpp:541
virtual void commandVersionSet(const SemanticVersion &version, const SdlInputContext &ctx)=0
void flush()
Force the parse of commands that were cached in the parser.
Definition SdlCommandParser.cpp:203
std::size_t numParsedCommands() const
Definition SdlCommandParser.h:198
std::size_t numParseErrors() const
Definition SdlCommandParser.h:203
virtual void endCommand()=0
Called when the parser finishes processing a command.
void setPacketInterface(std::unique_ptr< SdlDataPacketInterface > interface)
Definition SdlCommandParser.cpp:536
const Path & getSceneWorkingDirectory() const
Definition SdlCommandParser.h:188
const SemanticVersion & getCommandVersion() const
Definition SdlCommandParser.h:193
void parse(std::string_view rawCommandSegment)
Enters a string and parse it as one or more commands.
Definition SdlCommandParser.cpp:84
Parsing & generating a group of SDL clauses.
Definition SdlDataPacketInterface.h:14
Data that SDL input process can rely on.
Definition SdlInputContext.h:19
Convenient software version handling routines. See https://semver.org/ for a detailed explaination of...
Definition SemanticVersion.h:16
The root for all renderer implementations.
Definition EEngineProject.h:6
std::span< const T, EXTENT > TSpanView
Same as TSpan, except that the objects are const-qualified. Note that for pointer types,...
Definition TSpan.h:19
ESdlCommandType
Definition SdlCommandParser.h:20