Skip to content

Commit

Permalink
Refactored data members as const
Browse files Browse the repository at this point in the history
  • Loading branch information
vylion committed Mar 26, 2024
1 parent 032a996 commit 7f73bc2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
4 changes: 2 additions & 2 deletions headers/Grammar.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class Grammar {
std::vector<char> getCompiledBytes() const;

private:
GrammarType type;
std::string content;
const GrammarType type;
const std::string content;
std::vector<char> compiledBytes;
};

Expand Down
12 changes: 2 additions & 10 deletions src/Grammar.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
#include "Grammar.h"
#include <fstream>

Grammar::Grammar() {
type = NONE;
content = "";
}

Grammar::Grammar(const GrammarType type, const std::string content) {
this->type = type;
this->content = content;
Grammar::Grammar() : type{NONE}, content{} {}

Grammar::Grammar(const GrammarType type, const std::string content) : type(type), content(content) {
if (type == COMPILED) {
std::ifstream input(content, std::ios::binary);

compiledBytes = {content.data(), content.data() + content.length()};

input.close();
}
}
Expand Down

0 comments on commit 7f73bc2

Please sign in to comment.