Skip to content

Commit 0c0dc0d

Browse files
committed
refactor: utils singleton
1 parent 5b352b8 commit 0c0dc0d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

include/utils.hpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,19 @@ namespace tpt
1616
{
1717
class Utils
1818
{
19+
private:
20+
Utils() {}
21+
Utils(const Utils &) = delete;
22+
Utils &operator=(const Utils &) = delete;
23+
1924
public:
20-
static std::string readFileToBuffer(std::string filename);
25+
static Utils &getInstance()
26+
{
27+
static Utils instance;
28+
return instance;
29+
}
30+
31+
static std::string readFileToBuffer(const std::string &filename);
2132
static std::string date();
2233
static std::string btos(bool x);
2334
static std::string &replaceString(std::string &s, const std::string &from, const std::string &to);

src/utils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
using namespace tpt;
44

5-
std::string Utils::readFileToBuffer(std::string filename)
5+
std::string Utils::readFileToBuffer(const std::string &filename)
66
{
77
// Use std::filesystem to handle paths correctly across different OSes
88
std::filesystem::path filePath{filename};

0 commit comments

Comments
 (0)