Skip to content

Commit

Permalink
refactor: utils singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
araujo88 committed Mar 28, 2024
1 parent 5b352b8 commit 0c0dc0d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion include/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@ namespace tpt
{
class Utils
{
private:
Utils() {}
Utils(const Utils &) = delete;
Utils &operator=(const Utils &) = delete;

public:
static std::string readFileToBuffer(std::string filename);
static Utils &getInstance()
{
static Utils instance;
return instance;
}

static std::string readFileToBuffer(const std::string &filename);
static std::string date();
static std::string btos(bool x);
static std::string &replaceString(std::string &s, const std::string &from, const std::string &to);
Expand Down
2 changes: 1 addition & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using namespace tpt;

std::string Utils::readFileToBuffer(std::string filename)
std::string Utils::readFileToBuffer(const std::string &filename)
{
// Use std::filesystem to handle paths correctly across different OSes
std::filesystem::path filePath{filename};
Expand Down

0 comments on commit 0c0dc0d

Please sign in to comment.