added types

master
cobrapitz 3 years ago
parent c1f2595478
commit 20dd00fad3

@ -22,12 +22,14 @@ set(CBLIB_HEADERS
${CBLIB_INCLUDE_DIR}/types/types.h
${CBLIB_INCLUDE_DIR}/time/time.h
${CBLIB_INCLUDE_DIR}/test/test.h
${CBLIB_INCLUDE_DIR}/string_utils/string_utils.h
)
set(CBLIB_SOURCES
${CBLIB_SOURCE_DIR}/base.cpp
${CBLIB_SOURCE_DIR}/types/types.cpp
${CBLIB_SOURCE_DIR}/time/time.cpp
${CBLIB_SOURCE_DIR}/test/test.cpp
${CBLIB_SOURCE_DIR}/string_utils/string_utils.cpp
)
@ -44,8 +46,8 @@ target_include_directories(${PROJECT_NAME}
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
# PRIVATE
# ${CMAKE_CURRENT_SOURCE_DIR}/src
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)

@ -8,11 +8,18 @@
#define assertm(exp, msg) = assert(((void)msg, exp))
#define or ||
#define and &&
#define xor ^
#define compl ~
#define not !
#endif
#include "cb/test/test.h"
#include "cb/time/time.h"
#include "cb/types/types.h"
#include "cb/string_utils/string_utils.h"
#endif //GODOT_HUB_MAP_CB_H

@ -0,0 +1,14 @@
#ifndef GODOTHUB_STRING_UTILS_H
#define GODOTHUB_STRING_UTILS_H
#include <string_view>
namespace cb::string {
bool starts_with(std::string_view content, std::string_view begins_with);
bool ends_with(std::string_view content, std::string_view ends_with);
}
#endif //GODOTHUB_STRING_UTILS_H

@ -5,6 +5,8 @@
using i64 = int64_t;
using u64 = uint64_t;
using i32 = int32_t;
using u32 = uint32_t;
using f64 = double;
using f32 = float;

@ -0,0 +1,12 @@
#include "cb/string_utils/string_utils.h"
namespace cb {
bool string::starts_with(std::string_view content, std::string_view begins_with) {
return content.find(begins_with) != std::string::npos;
}
bool string::ends_with(std::string_view content, std::string_view ends_with) {
return content.find(ends_with) != std::string::npos;
}
}

@ -11,7 +11,7 @@ namespace cb {
}
void time::start_measure(const std::string_view &id) {
_name_to_measurement.insert({id, chrono_now()});
_name_to_measurement.insert_or_assign(id, chrono_now());
}
long long time::get_duration(const std::string_view &id) {
@ -26,7 +26,7 @@ namespace cb {
}
void time::measure(const std::string_view &id) {
std::cout << "measurement: " << id << " took: " << get_duration(id) << "\n";
std::cout << "measurement: " << id << " took: " << (double)get_duration(id) / 1'000'000'000.0 << "\n";
}
const time::time_point_map &time::get_measurements() {

Loading…
Cancel
Save