34 lines
998 B
C++
34 lines
998 B
C++
#include "methods.h"
|
|
#include <ctime>
|
|
#include <iostream>
|
|
|
|
methods::methods() {}
|
|
|
|
using inicpp::ini;
|
|
using inicpp::IniManager;
|
|
using std::string;
|
|
|
|
int getUnixTimestamp() { // 获取当前Unix时间戳
|
|
return static_cast<int>(time(nullptr));
|
|
}
|
|
|
|
string getTextMiddle(string source, string left, string right) {
|
|
size_t leftPos = source.find(left);
|
|
if (leftPos == string::npos) return "";
|
|
leftPos += left.length();
|
|
size_t rightPos = source.find(right, leftPos);
|
|
if (rightPos == string::npos) return "";
|
|
return source.substr(leftPos, rightPos - leftPos);
|
|
}
|
|
|
|
string getKeyText(string iniFilePath, string mainLevel, string subLevel) {
|
|
IniManager _ini(iniFilePath); // Load and parse the INI file
|
|
string returnValue = _ini[mainLevel][subLevel];
|
|
return (returnValue);
|
|
}
|
|
|
|
void setKeyText(string iniFilePath, string mainLevel, string subLevel, string value) {
|
|
IniManager _ini(iniFilePath); // Load and parse the INI file
|
|
_ini.set(mainLevel, subLevel, value);
|
|
}
|