I need to make a glorified text parser that has two methods of parsing, depending on a config file This is what I came up with.
class Compiler
{
public:
static void compile(const std::string& filepath);
private:
Compiler() {}
static void SimpleCompilation(std::ifstream& fin, std::ofstream& fout);
static void AdvancedCompilation(std::ifstream& fin, std::ofstream& fout);
static unsigned int numOfChars(const std::string& target, const std::string& charset);
};
In a sense, I want this class to be a function with some subfucntions. I want the user to have access to compile, and compile chooses which of the two parser types it uses, without an object of the class being created.
Is this bad practice? Should I make a compile namespace and put all of these subfunctions into one huge compile function or is there a way to stop the user from calling select functions from a namespace?