Skip to content

Commit

Permalink
major update
Browse files Browse the repository at this point in the history
bump 307lib to 1.20.0
added more features from the original version, like the config file (which works this time; and is now on a preprocessor switch)
expanded the unit roster to include SI prefixes (yocto, zepto, atto, femto, peta, exa, zetta, yotta)
added the ability to check for updates (this is on a preprocessor switch)
  • Loading branch information
radj307 committed Aug 24, 2022
1 parent 39e42ea commit a7d1a35
Show file tree
Hide file tree
Showing 8 changed files with 736 additions and 278 deletions.
68 changes: 55 additions & 13 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"version": 3,
"version": 3,
"configurePresets": [
{
"name": "networking",
"hidden": true,
"cacheVariables": {
"307lib_build_netlib": true
}
},


{
"name": "windows-base",
"hidden": true,
Expand All @@ -18,8 +27,8 @@
}
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"name": "windows-debug",
"displayName": "Debug",
"inherits": "windows-base",
"architecture": {
"value": "x64",
Expand All @@ -30,17 +39,19 @@
}
},
{
"name": "x64-release",
"displayName": "x64 Release",
"inherits": "x64-debug",
"name": "windows-release",
"displayName": "Release",
"inherits": "windows-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},


{
"name": "x86-debug",
"displayName": "x86 Debug",
"inherits": "windows-base",
"name": "windows-debug-networking",
"displayName": "(w/netlib) Debug",
"inherits": [ "windows-base", "networking" ],
"architecture": {
"value": "x86",
"strategy": "external"
Expand All @@ -50,16 +61,18 @@
}
},
{
"name": "x86-release",
"displayName": "x86 Release",
"inherits": "x86-debug",
"name": "windows-release-networking",
"displayName": "(w/netlib) Release",
"inherits": "windows-debug-networking",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},


{
"name": "linux-debug",
"displayName": "Linux Debug",
"displayName": "Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
Expand All @@ -77,6 +90,28 @@
}
}
},

{
"name": "linux-release",
"displayName": "Release",
"inherits": "linux-debug",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Release" }
},

{
"name": "linux-debug-networking",
"displayName": "(w/netlib) Debug",
"inherits": [ "linux-debug", "networking" ]
},

{
"name": "linux-release-networking",
"displayName": "(w/netlib) Release",
"inherits": "linux-debug-networking",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Release" }
},


{
"name": "macos-debug",
"displayName": "macOS Debug",
Expand All @@ -96,6 +131,13 @@
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
}
}
},
{
"name": "macos-release",
"displayName": "Release",
"inherits": "macos-debug",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Release" }
}

]
}
25 changes: 23 additions & 2 deletions ckconv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ endif()

add_executable (ckconv "${SRCS}" "${ckconv_rc}" "rc/version.h")

set_property(TARGET ckconv PROPERTY CXX_STANDARD 20)
set_property(TARGET ckconv PROPERTY CXX_STANDARD 23)
set_property(TARGET ckconv PROPERTY CXX_STANDARD_REQUIRED ON)

if (MSVC)
Expand All @@ -44,7 +44,28 @@ endif()

target_sources(ckconv PRIVATE "${HEADERS}")

target_link_libraries(ckconv PRIVATE TermAPI optlib filelib)
target_link_libraries(ckconv PRIVATE TermAPI filelib)

option(ckconv_DISABLE_CONFIG_FILE "Don't enable the code for the INI configuration file." FALSE)
if (NOT ${ckconv_DISABLE_CONFIG_FILE})
target_compile_definitions(ckconv PRIVATE ENABLE_CONFIG_FILE)
endif()

if (${307lib_build_netlib})
include(FetchContent)
FetchContent_Declare(nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.2
)
FetchContent_Declare(cpr
GIT_REPOSITORY https://github.com/libcpr/cpr.git
GIT_TAG 1.9.1
)
FetchContent_MakeAvailable(nlohmann_json cpr)

target_link_libraries(ckconv PRIVATE nlohmann_json::nlohmann_json cpr::cpr)
target_compile_definitions(ckconv PRIVATE ENABLE_UPDATE_CHECK)
endif()

include(PackageInstaller)
INSTALL_EXECUTABLE(ckconv "${CMAKE_INSTALL_PREFIX}")
16 changes: 8 additions & 8 deletions ckconv/PrintableMeasurementUnits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace ckconv {
inline std::ostream& operator<<(std::ostream& os, const conv::Unit& unit)
{
return os << (global.useFullNames ? unit.getName() : unit.getSymbol());
return os << (global.useFullNames ? unit.GetFullName() : unit.GetSymbol());
}

template<conv::SystemID System>
Expand All @@ -39,11 +39,11 @@ namespace ckconv {
;
int power{ -12 };
for (const auto& unit : conv::CreationKit.units) {
const auto& symbol{ (unit.hasName() ? unit.getSymbol() : ""s) }, name{ unit.getName() };
const auto& symbol{ (unit.HasFullName() ? unit.GetSymbol() : ""s) }, name{ unit.GetFullName() };
ss
<< " " << symbol << indent(symbol_indent_postfix, symbol.size())
<< name << indent(name_indent_postfix, name.size())
<< unit.unitcf << ' ' << *conv::CreationKit.base
<< unit.GetConversionFactor() << ' ' << *conv::CreationKit.base
<< '\n';
}
if (!fallthrough) break;
Expand All @@ -59,11 +59,11 @@ namespace ckconv {
;
int power{ -12 };
for (const auto& unit : conv::Metric.units) {
const auto& symbol{ (unit.hasName() ? unit.getSymbol() : ""s) }, name{ unit.getName() };
const auto& symbol{ (unit.HasFullName() ? unit.GetSymbol() : ""s) }, name{ unit.GetFullName() };
ss
<< " " << symbol << indent(symbol_indent_postfix, symbol.size())
<< name << indent(name_indent_postfix, name.size())
<< unit.unitcf << ' ' << *conv::Metric.base
<< unit.GetConversionFactor() << ' ' << *conv::Metric.base
<< '\n';
power += (power < 3 || power > 3 ? 3 : 1);
}
Expand All @@ -79,11 +79,11 @@ namespace ckconv {
<< " --------------------------------------\n"
;
for (const auto& unit : conv::Imperial.units) {
const auto& symbol{ (unit.hasName() ? unit.getSymbol() : ""s) }, name{ unit.getName() };
const auto& symbol{ (unit.HasFullName() ? unit.GetSymbol() : ""s) }, name{ unit.GetFullName() };
ss
<< " " << symbol << indent(symbol_indent_postfix, symbol.size())
<< name << indent(name_indent_postfix, name.size())
<< unit.unitcf << ' ' << *conv::Imperial.base
<< unit.GetConversionFactor() << ' ' << *conv::Imperial.base
<< '\n';
}
if (!fallthrough) break;
Expand Down Expand Up @@ -111,7 +111,7 @@ namespace ckconv {
if (str::equalsAny<true>(systemName, "creationkit", "ck", "creation-kit", "creation_kit", "gamebryo", "engine", "bethesda"))
return conv::SystemID::CREATIONKIT;

return conv::getUnit(systemName, DEFAULT_UNIT).getSystem();
return conv::getUnit(systemName, DEFAULT_UNIT).GetSystemID();
}

conv::SystemID system;
Expand Down
Loading

0 comments on commit a7d1a35

Please sign in to comment.