修复了一些问题
This commit is contained in:
@@ -1394,7 +1394,9 @@ struct StringIndicator
|
||||
static str ToString(const T& value)
|
||||
{
|
||||
if_exists(T::ToString)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
if constexpr (std::is_constructible_v<const T&, str>)
|
||||
return value;
|
||||
else if constexpr (std::is_same_v<str, std::wstring>)
|
||||
@@ -1800,6 +1802,11 @@ namespace Convention
|
||||
public:
|
||||
constexpr static size_t size = 0;
|
||||
constexpr static size_t _MySize = 0;
|
||||
template<size_t index>
|
||||
constexpr static size_t ElementOffset()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1871,6 +1878,7 @@ namespace Convention
|
||||
using _SharedPtr = SharedPtr<T>;
|
||||
using _UniquePtr = UniquePtr<T, DefaultDelete<T, Allocator>>;
|
||||
using _Mybase = std::conditional_t<IsUnique, _UniquePtr, _SharedPtr>;
|
||||
using _MyAlloc = Allocator<T>;
|
||||
private:
|
||||
/**
|
||||
* @brief 获取内存管理器
|
||||
@@ -1885,7 +1893,7 @@ namespace Convention
|
||||
{
|
||||
T* ptr = GetStaticMyAllocator().allocate(1);
|
||||
GetStaticMyAllocator().construct(ptr, std::forward<Args>(args)...);
|
||||
return ptr
|
||||
return ptr;
|
||||
}
|
||||
static void _DestoryMyPtr(_In_ T* ptr)
|
||||
{
|
||||
|
@@ -10,13 +10,25 @@ namespace Convention
|
||||
{
|
||||
private:
|
||||
std::filesystem::path FullPath;
|
||||
mutable std::fstream OriginControlStream;
|
||||
mutable bool StreamOpen = false;
|
||||
//mutable std::fstream OriginControlStream;
|
||||
//mutable bool StreamOpen = false;
|
||||
|
||||
public:
|
||||
explicit ToolFile(const std::filesystem::path& path) : FullPath(path) {}
|
||||
explicit ToolFile(const std::string& path) : FullPath(path) {}
|
||||
explicit ToolFile(const char* path) : FullPath(path) {}
|
||||
ToolFile(const std::filesystem::path& path) : FullPath(path) {}
|
||||
ToolFile(const std::string& path) : FullPath(path) {}
|
||||
ToolFile(const char* path) : FullPath(path) {}
|
||||
ToolFile(const ToolFile& other) : FullPath(other.FullPath) {}
|
||||
ToolFile(ToolFile&& other) : FullPath(std::move(other.FullPath)) {}
|
||||
ToolFile& operator=(const ToolFile& other)
|
||||
{
|
||||
this->FullPath = other.FullPath;
|
||||
return *this;
|
||||
}
|
||||
ToolFile& operator=(ToolFile&& other)
|
||||
{
|
||||
this->FullPath = std::move(other.FullPath);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Convert to string
|
||||
operator std::string() const { return FullPath.string(); }
|
||||
@@ -85,20 +97,21 @@ namespace Convention
|
||||
return *this;
|
||||
}
|
||||
|
||||
ToolFile& Open(std::ios::openmode mode = std::ios::in | std::ios::out)
|
||||
/*ToolFile& Open(std::ios::openmode mode = std::ios::in | std::ios::out)
|
||||
{
|
||||
Close();
|
||||
OriginControlStream.open(FullPath, mode);
|
||||
StreamOpen = OriginControlStream.is_open();
|
||||
return *this;
|
||||
}
|
||||
}*/
|
||||
|
||||
ToolFile& Close()
|
||||
{
|
||||
if (StreamOpen) {
|
||||
/*if (StreamOpen)
|
||||
{
|
||||
OriginControlStream.close();
|
||||
StreamOpen = false;
|
||||
}
|
||||
}*/
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -154,7 +167,8 @@ namespace Convention
|
||||
ToolFile& MustExistsPath()
|
||||
{
|
||||
auto parent = FullPath.parent_path();
|
||||
if (!parent.empty() && !std::filesystem::exists(parent)) {
|
||||
if (!parent.empty() && !std::filesystem::exists(parent))
|
||||
{
|
||||
std::filesystem::create_directories(parent);
|
||||
}
|
||||
return *this;
|
||||
|
@@ -16,14 +16,12 @@ namespace Convention
|
||||
static void InitExtensionEnv()
|
||||
{
|
||||
ConstConfigFile = "config.json";
|
||||
ProjectConfig::InitExtensionEnv();
|
||||
}
|
||||
|
||||
static void GenerateEmptyConfigJson(ToolFile& file)
|
||||
{
|
||||
nlohmann::json config;
|
||||
config["properties"] = nlohmann::json::object();
|
||||
file.Open(std::ios::out | std::ios::trunc);
|
||||
file.SaveAsText(config.dump(4));
|
||||
file.Close();
|
||||
}
|
||||
@@ -69,7 +67,8 @@ namespace Convention
|
||||
ToolFile GetFile(const std::string& path, bool isMustExist = false)
|
||||
{
|
||||
auto file = DataDir | path;
|
||||
if (isMustExist) {
|
||||
if (isMustExist)
|
||||
{
|
||||
file.MustExistsPath();
|
||||
}
|
||||
return file;
|
||||
@@ -78,13 +77,16 @@ namespace Convention
|
||||
bool EraseFile(const std::string& path)
|
||||
{
|
||||
auto file = DataDir | path;
|
||||
if (file.Exists()) {
|
||||
try {
|
||||
file.Open(std::ios::out | std::ios::trunc);
|
||||
file.Close();
|
||||
return true;
|
||||
} catch (...) {}
|
||||
}
|
||||
if (file.Exists())
|
||||
{
|
||||
file.MustExistsPath();
|
||||
if (file.IsFile())
|
||||
{
|
||||
file.Remove();
|
||||
file.Create();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -209,7 +211,7 @@ namespace Convention
|
||||
MyDefaultLogger = std::move(logger);
|
||||
}
|
||||
|
||||
virtual void Log(const std::string& messageType, const std::string& message, std::function<void(const std::string&)> logger = nullptr)
|
||||
virtual void Log(const std::string& messageType, const std::string& message, std::function<void(const std::string&)> logger)
|
||||
{
|
||||
configLogging_tspace = std::max(configLogging_tspace, messageType.length());
|
||||
|
||||
|
Reference in New Issue
Block a user