change:基本定义更改用于同时支持wstring和string。
This commit is contained in:
parent
13132f5212
commit
b8ec3c55cb
58
.vscode/settings.json
vendored
58
.vscode/settings.json
vendored
@ -19,9 +19,9 @@
|
||||
"args": [
|
||||
]
|
||||
},
|
||||
// "cmake.configureSettings": {
|
||||
// "CMAKE_TOOLCHAIN_FILE": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
// },
|
||||
"cmake.configureSettings": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
},
|
||||
"cmake.options.statusBarVisibility": "visible",
|
||||
"cmake.generator": "Ninja",
|
||||
"C_Cpp.default.compileCommands": "${workspaceRoot}/build/compile_commands.json",
|
||||
@ -31,5 +31,57 @@
|
||||
"ja": true,
|
||||
"zh-hant": true,
|
||||
"zh-hans": true
|
||||
},
|
||||
"files.associations": {
|
||||
"xstring": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"chrono": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"exception": "cpp",
|
||||
"filesystem": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"ios": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"list": "cpp",
|
||||
"locale": "cpp",
|
||||
"memory": "cpp",
|
||||
"new": "cpp",
|
||||
"ostream": "cpp",
|
||||
"ratio": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"utility": "cpp",
|
||||
"vector": "cpp",
|
||||
"xfacet": "cpp",
|
||||
"xiosbase": "cpp",
|
||||
"xlocale": "cpp",
|
||||
"xlocbuf": "cpp",
|
||||
"xlocinfo": "cpp",
|
||||
"xlocmes": "cpp",
|
||||
"xlocmon": "cpp",
|
||||
"xlocnum": "cpp",
|
||||
"xloctime": "cpp",
|
||||
"xmemory": "cpp",
|
||||
"xmemory0": "cpp",
|
||||
"xstddef": "cpp",
|
||||
"xtr1common": "cpp",
|
||||
"xutility": "cpp"
|
||||
}
|
||||
}
|
@ -11,11 +11,14 @@ endif()
|
||||
message(STATUS "System: ${CMAKE_SYSTEM_NAME}")
|
||||
message(STATUS "Compiler CXX ID: ${CMAKE_CXX_COMPILER_ID}")
|
||||
|
||||
set(SRC_FILES
|
||||
include/of_path.h src/of_path.cpp
|
||||
include/of_str.h src/of_str.cpp
|
||||
)
|
||||
# find_package(GTest CONFIG REQUIRED)
|
||||
|
||||
set(SRC_FILES
|
||||
src/of_path.cpp src/of_str.cpp
|
||||
)
|
||||
include_directories(include)
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
add_library(Ofen STATIC ${SRC_FILES})
|
||||
target_include_directories(Ofen PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
14
include/of_def.hpp
Normal file
14
include/of_def.hpp
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef OFEN_DEFINE
|
||||
#define OFEN_DEFINE
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef UNICODE_OFSTR
|
||||
using ofString = std::wstring;
|
||||
#define ofT(text) L##text
|
||||
#else
|
||||
using ofString = std::string;
|
||||
#define ofT(text) text
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
#ifndef OFEN_PATH_HEADER
|
||||
#define OFEN_PATH_HEADER
|
||||
|
||||
#include <string>
|
||||
#include "of_def.hpp"
|
||||
|
||||
namespace ofen {
|
||||
class COfPath
|
||||
@ -11,7 +11,7 @@ public:
|
||||
~COfPath();
|
||||
|
||||
public:
|
||||
static bool is_same_path(const std::string& pa, const std::string& pb);
|
||||
static bool is_same_path(const ofString& pa, const ofString& pb);
|
||||
};
|
||||
}; // namespace ofen
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
#ifndef OFEN_STRING_HEADER
|
||||
#define OFEN_STRING_HEADER
|
||||
|
||||
#include <string>
|
||||
#include "of_def.hpp"
|
||||
|
||||
namespace ofen {
|
||||
class COfStr
|
||||
|
@ -11,7 +11,7 @@ COfPath::~COfPath()
|
||||
{
|
||||
}
|
||||
|
||||
bool COfPath::is_same_path(const std::string& pa, const std::string& pb)
|
||||
bool COfPath::is_same_path(const ofString& pa, const ofString& pb)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
13
test/CMakeLists.txt
Normal file
13
test/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(ofen LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options(/source-charset:utf-8)
|
||||
endif()
|
||||
|
||||
|
||||
add_executable(ofTest main.cpp)
|
||||
target_link_libraries(ofTest PRIVATE Ofen)
|
Loading…
x
Reference in New Issue
Block a user