Cleanups for the parsers

This commit is contained in:
Paul Ferrand 2019-07-29 15:50:15 +02:00
parent 3f30c5f9de
commit d1343ef6f5
3 changed files with 5 additions and 5 deletions

View file

@ -35,7 +35,7 @@ inline std::string_view trim(std::string_view s)
inline constexpr unsigned int Fnv1aBasis = 0x811C9DC5; inline constexpr unsigned int Fnv1aBasis = 0x811C9DC5;
inline constexpr unsigned int Fnv1aPrime = 0x01000193; inline constexpr unsigned int Fnv1aPrime = 0x01000193;
inline constexpr unsigned int hash(const char *s, unsigned int h = Fnv1aBasis) inline constexpr unsigned int hash(const char *s, unsigned int h = Fnv1aBasis)
{ {
return !*s ? h : hash(s + 1, static_cast<unsigned int>((h ^ *s) * static_cast<unsigned long long>(Fnv1aPrime))); return !*s ? h : hash(s + 1, static_cast<unsigned int>((h ^ *s) * static_cast<unsigned long long>(Fnv1aPrime)));
} }

View file

@ -14,7 +14,7 @@ public:
int getNumMasters() const noexcept { return numMasters; } int getNumMasters() const noexcept { return numMasters; }
int getNumCurves() const noexcept { return numCurves; } int getNumCurves() const noexcept { return numCurves; }
protected: protected:
void callback(std::string_view header, std::vector<sfz::Opcode> members) override void callback(std::string_view header, std::vector<sfz::Opcode> members) final
{ {
switch (hash(header)) switch (hash(header))
{ {

View file

@ -12,14 +12,14 @@ namespace sfz
class Synth: public Parser class Synth: public Parser
{ {
public: public:
bool loadSfzFile(const std::filesystem::path& file) override; bool loadSfzFile(const std::filesystem::path& file) final;
int getNumRegions() const noexcept { return regions.size(); } int getNumRegions() const noexcept { return regions.size(); }
int getNumGroups() const noexcept { return numGroups; } int getNumGroups() const noexcept { return numGroups; }
int getNumMasters() const noexcept { return numMasters; } int getNumMasters() const noexcept { return numMasters; }
int getNumCurves() const noexcept { return numCurves; } int getNumCurves() const noexcept { return numCurves; }
const Region* getRegionView(int idx) { return idx < regions.size() ? &regions[idx] : nullptr; } const Region* getRegionView(int idx) const noexcept { return idx < regions.size() ? &regions[idx] : nullptr; }
protected: protected:
void callback(std::string_view header, std::vector<Opcode> members) override; void callback(std::string_view header, std::vector<Opcode> members) final;
private: private:
bool hasGlobal { false }; bool hasGlobal { false };
bool hasControl { false }; bool hasControl { false };