C++ 17
parent
02c62a2d63
commit
da0609e0fd
|
@ -1,7 +1,7 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
project(BLT VERSION 0.8.1)
|
project(BLT VERSION 0.8.1)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
||||||
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace blt
|
||||||
void arg_vector_t::validateFlags()
|
void arg_vector_t::validateFlags()
|
||||||
{
|
{
|
||||||
for (const auto& flag : flags)
|
for (const auto& flag : flags)
|
||||||
if (!flag.starts_with('-'))
|
if (!blt::string::starts_with(flag, '-'))
|
||||||
throw invalid_argument_exception("Flag '" + flag + "' must start with - or --");
|
throw invalid_argument_exception("Flag '" + flag + "' must start with - or --");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ namespace blt
|
||||||
std::string flag = flags[0];
|
std::string flag = flags[0];
|
||||||
// search for first '--' flag
|
// search for first '--' flag
|
||||||
for (const auto& f : flags)
|
for (const auto& f : flags)
|
||||||
if (f.starts_with("--"))
|
if (blt::string::starts_with(f, "--"))
|
||||||
{
|
{
|
||||||
flag = f;
|
flag = f;
|
||||||
break;
|
break;
|
||||||
|
@ -91,7 +91,7 @@ namespace blt
|
||||||
|
|
||||||
std::string to_string(const arg_data_t& v)
|
std::string to_string(const arg_data_t& v)
|
||||||
{
|
{
|
||||||
if (holds_alternative<arg_data_internal_t>(v))
|
if (std::holds_alternative<arg_data_internal_t>(v))
|
||||||
return to_string(std::get<arg_data_internal_t>(v));
|
return to_string(std::get<arg_data_internal_t>(v));
|
||||||
else if (std::holds_alternative<arg_data_vec_t>(v))
|
else if (std::holds_alternative<arg_data_vec_t>(v))
|
||||||
{
|
{
|
||||||
|
@ -145,9 +145,9 @@ namespace blt
|
||||||
properties->a_dest = properties->a_flags.name;
|
properties->a_dest = properties->a_flags.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties->a_dest.starts_with("--"))
|
if (blt::string::starts_with(properties->a_dest, "--"))
|
||||||
properties->a_dest = properties->a_dest.substr(2);
|
properties->a_dest = properties->a_dest.substr(2);
|
||||||
else if (properties->a_dest.starts_with('-'))
|
else if (blt::string::starts_with(properties->a_dest, '-'))
|
||||||
properties->a_dest = properties->a_dest.substr(1);
|
properties->a_dest = properties->a_dest.substr(1);
|
||||||
|
|
||||||
// associate flags with their properties
|
// associate flags with their properties
|
||||||
|
@ -266,12 +266,12 @@ namespace blt
|
||||||
tokenizer.advance();
|
tokenizer.advance();
|
||||||
|
|
||||||
// token is a flag, figure out how to handle it
|
// token is a flag, figure out how to handle it
|
||||||
if (flag.starts_with("--"))
|
if (blt::string::starts_with(flag, "--"))
|
||||||
processFlag(tokenizer, flag);
|
processFlag(tokenizer, flag);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// handle special args like -vvv
|
// handle special args like -vvv
|
||||||
if (!flag.starts_with('-'))
|
if (!blt::string::starts_with(flag, '-'))
|
||||||
std::cerr << "Flag processed but does not start with '-' (this is a serious error!)\n";
|
std::cerr << "Flag processed but does not start with '-' (this is a serious error!)\n";
|
||||||
// make sure the flag only contains the same character
|
// make sure the flag only contains the same character
|
||||||
auto type = flag[1];
|
auto type = flag[1];
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <blt/std/format.h>
|
#include <blt/std/format.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <blt/std/hashmap.h>
|
#include <blt/std/hashmap.h>
|
||||||
|
#include <blt/compatibility.h>
|
||||||
|
|
||||||
namespace blt
|
namespace blt
|
||||||
{
|
{
|
||||||
|
@ -215,7 +216,7 @@ namespace blt
|
||||||
void _internal::startInterval(const std::string& profile_name, const std::string& interval_name)
|
void _internal::startInterval(const std::string& profile_name, const std::string& interval_name)
|
||||||
{
|
{
|
||||||
auto& profile = profiles[profile_name];
|
auto& profile = profiles[profile_name];
|
||||||
if (!profile.contains(interval_name))
|
if (profile.find(interval_name) == profile.end())
|
||||||
{
|
{
|
||||||
auto interval = new interval_t();
|
auto interval = new interval_t();
|
||||||
interval->interval_name = interval_name;
|
interval->interval_name = interval_name;
|
||||||
|
|
|
@ -5,9 +5,7 @@ option(ENABLE_ADDRSAN "Enable the address sanitizer" ON)
|
||||||
option(ENABLE_UBSAN "Enable the ub sanitizer" ON)
|
option(ENABLE_UBSAN "Enable the ub sanitizer" ON)
|
||||||
option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF)
|
option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
add_subdirectory(../)
|
|
||||||
|
|
||||||
include_directories(include/)
|
include_directories(include/)
|
||||||
file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
|
||||||
|
|
Loading…
Reference in New Issue