diff --git a/CMakeLists.txt b/CMakeLists.txt index aadf55665..3302ae3ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ option(BUILD_COVERAGE "Build with coverage information" OFF) set(HAVE_COVERAGE OFF) if(NOT WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -std=c++11") ## Optimize + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -std=c++17") ## Optimize set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wunreachable-code") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedef") # boost + clang @@ -104,8 +104,8 @@ include_directories("${PROJECT_BINARY_DIR}/include") ### scan files include_directories(BEFORE include) -file(GLOB_RECURSE nix_SOURCES src/*.cpp) -file(GLOB_RECURSE nix_INCLUDES include/*.hpp) +file(GLOB_RECURSE nix_SOURCES "src/[!.#]*.cpp") +file(GLOB_RECURSE nix_INCLUDES "include/[!.#]*.hpp") list(APPEND nix_INCLUDES "${PROJECT_BINARY_DIR}/include/nix/nixversion.hpp") ### BACKENDS @@ -115,8 +115,8 @@ set(backends "hdf5") include_directories(${CMAKE_SOURCE_DIR}/backend) foreach(backend ${backends}) - file(GLOB_RECURSE backend_SOURCES "backend/${backend}/*.cpp") - file(GLOB_RECURSE backend_INCLUDES "backend/${backend}/*.hpp") + file(GLOB_RECURSE backend_SOURCES "backend/${backend}/[!.#]*.cpp") + file(GLOB_RECURSE backend_INCLUDES "backend/${backend}/[!.#]*.hpp") list(APPEND nix_SOURCES ${backend_SOURCES}) list(APPEND nix_INCLUDES ${backend_INCLUDES}) diff --git a/backend/hdf5/BaseTagHDF5.cpp b/backend/hdf5/BaseTagHDF5.cpp index 8d86ac0aa..b08a8bbc8 100644 --- a/backend/hdf5/BaseTagHDF5.cpp +++ b/backend/hdf5/BaseTagHDF5.cpp @@ -53,14 +53,14 @@ bool BaseTagHDF5::hasReference(const std::string &name_or_id) const { ndsize_t BaseTagHDF5::referenceCount() const { - boost::optional g = refs_group(false); + std::optional g = refs_group(false); return g ? g->objectCount() : size_t(0); } std::shared_ptr BaseTagHDF5::getReference(const std::string &name_or_id) const { std::shared_ptr da; - boost::optional g = refs_group(false); + std::optional g = refs_group(false); std::string id = block()->resolveEntityId({name_or_id, ObjectType::DataArray}); if (g && hasReference(id)) { @@ -72,13 +72,13 @@ std::shared_ptr BaseTagHDF5::getReference(const std::string &name_o } std::shared_ptr BaseTagHDF5::getReference(ndsize_t index) const { - boost::optional g = refs_group(false); + std::optional g = refs_group(false); std::string id = g ? g->objectName(index) : ""; return getReference(id); } void BaseTagHDF5::addReference(const std::string &name_or_id) { - boost::optional g = refs_group(true); + std::optional g = refs_group(true); if (!block()->hasEntity({name_or_id, ObjectType::DataArray})) throw std::runtime_error("BaseTagHDF5::addReference: DataArray not found in block!"); @@ -90,7 +90,7 @@ void BaseTagHDF5::addReference(const std::string &name_or_id) { bool BaseTagHDF5::removeReference(const std::string &name_or_id) { - boost::optional g = refs_group(false); + std::optional g = refs_group(false); bool removed = false; if (g && hasReference(name_or_id)) { @@ -124,19 +124,19 @@ bool BaseTagHDF5::hasFeature(const std::string &name_or_id) const { ndsize_t BaseTagHDF5::featureCount() const { - boost::optional g = feature_group(false); + std::optional g = feature_group(false); return g ? g->objectCount() : size_t(0); } std::shared_ptr BaseTagHDF5::getFeature(const std::string &name_or_id) const { std::shared_ptr feature; - boost::optional g = feature_group(false); + std::optional g = feature_group(false); if (g) { - boost::optional group = g->findGroupByNameOrAttribute("name", name_or_id); + std::optional group = g->findGroupByNameOrAttribute("name", name_or_id); if (group) - feature = std::make_shared(file(), block(), group.get()); + feature = std::make_shared(file(), block(), group.value()); else { for (ndsize_t i = 0; i < g->objectCount(); i++) { H5Group gr = g->openGroup(g->objectName(i), false); @@ -154,7 +154,7 @@ std::shared_ptr BaseTagHDF5::getFeature(const std::string &name_or_id) std::shared_ptr BaseTagHDF5::getFeature(ndsize_t index) const { - boost::optional g = feature_group(false); + std::optional g = feature_group(false); std::string id = g->objectName(index); return getFeature(id); } @@ -165,7 +165,7 @@ std::shared_ptr BaseTagHDF5::createFeature(const std::string &name_or throw std::runtime_error("DataArray not found in Block!"); } std::string rep_id = util::createId(); - boost::optional g = feature_group(true); + std::optional g = feature_group(true); H5Group group = g->openGroup(rep_id, true); DataArray data = std::dynamic_pointer_cast(block()->getEntity({name_or_id, ObjectType::DataArray})); @@ -174,7 +174,7 @@ std::shared_ptr BaseTagHDF5::createFeature(const std::string &name_or bool BaseTagHDF5::deleteFeature(const std::string &name_or_id) { - boost::optional g = feature_group(false); + std::optional g = feature_group(false); bool deleted = false; if (g && hasFeature(name_or_id)) { diff --git a/backend/hdf5/BlockHDF5.cpp b/backend/hdf5/BlockHDF5.cpp index d9944f937..c850a4b8b 100644 --- a/backend/hdf5/BlockHDF5.cpp +++ b/backend/hdf5/BlockHDF5.cpp @@ -58,8 +58,8 @@ BlockHDF5::BlockHDF5(const shared_ptr &file, const H5Group &group, const // Generic access methods //-------------------------------------------------- -boost::optional BlockHDF5::groupForObjectType(ObjectType type, bool create) const { - boost::optional p; +std::optional BlockHDF5::groupForObjectType(ObjectType type, bool create) const { + std::optional p; switch (type) { case ObjectType::DataArray: @@ -87,20 +87,20 @@ boost::optional BlockHDF5::groupForObjectType(ObjectType type, bool cre break; default: - p = boost::optional(create); + p = std::optional(create); } return p; } -boost::optional BlockHDF5::findEntityGroup(const nix::Identity &ident) const { - boost::optional p = groupForObjectType(ident.type()); +std::optional BlockHDF5::findEntityGroup(const nix::Identity &ident) const { + std::optional p = groupForObjectType(ident.type()); if (!p) { return p; } - boost::optional g; + std::optional g; const std::string &iname = ident.name(); const std::string &iid = ident.id(); @@ -115,7 +115,7 @@ boost::optional BlockHDF5::findEntityGroup(const nix::Identity &ident) bool foundNeedle = p->hasObject(needle); if (foundNeedle) { - g = boost::make_optional(p->openGroup(needle, false)); + g = std::make_optional(p->openGroup(needle, false)); } else if (haveId) { g = p->findGroupByAttribute("entity_id", iid); } @@ -125,7 +125,7 @@ boost::optional BlockHDF5::findEntityGroup(const nix::Identity &ident) g->getAttr("entity_id", eid); if (eid != iid) { - return boost::optional(); + return std::optional(); } } @@ -137,7 +137,7 @@ std::string BlockHDF5::resolveEntityId(const nix::Identity &ident) const { return ident.id(); } - boost::optional g = findEntityGroup(ident); + std::optional g = findEntityGroup(ident); if (!g) { return ""; } @@ -149,12 +149,12 @@ std::string BlockHDF5::resolveEntityId(const nix::Identity &ident) const { } bool BlockHDF5::hasEntity(const nix::Identity &ident) const { - boost::optional p = findEntityGroup(ident); + std::optional p = findEntityGroup(ident); return !!p; } std::shared_ptr BlockHDF5::getEntity(const nix::Identity &ident) const { - boost::optional eg = findEntityGroup(ident); + std::optional eg = findEntityGroup(ident); switch (ident.type()) { case ObjectType::DataArray: { @@ -213,19 +213,19 @@ std::shared_ptr BlockHDF5::getEntity(const nix::Identity &ident) } std::shared_ptrBlockHDF5::getEntity(ObjectType type, ndsize_t index) const { - boost::optional eg = groupForObjectType(type); + std::optional eg = groupForObjectType(type); string name = eg ? eg->objectName(index) : ""; return getEntity({name, "", type}); } ndsize_t BlockHDF5::entityCount(ObjectType type) const { - boost::optional g = groupForObjectType(type); + std::optional g = groupForObjectType(type); return g ? g->objectCount() : ndsize_t(0); } bool BlockHDF5::removeEntity(const nix::Identity &ident) { - boost::optional p = groupForObjectType(ident.type()); - boost::optional eg = findEntityGroup(ident); + std::optional p = groupForObjectType(ident.type()); + std::optional eg = findEntityGroup(ident); if (!p || !eg) { return false; @@ -255,7 +255,7 @@ bool BlockHDF5::removeEntity(const nix::Identity &ident) { shared_ptr BlockHDF5::createSource(const string &name, const string &type) { string id = util::createId(); - boost::optional g = source_group(true); + std::optional g = source_group(true); H5Group group = g->openGroup(name, true); return make_shared(file(), block(), group, id, type, name); @@ -263,7 +263,7 @@ shared_ptr BlockHDF5::createSource(const string &name, const string &ty bool BlockHDF5::deleteSource(const string &name_or_id) { - boost::optional g = source_group(); + std::optional g = source_group(); bool deleted = false; if (g) { @@ -293,7 +293,7 @@ bool BlockHDF5::deleteSource(const string &name_or_id) { shared_ptr BlockHDF5::createTag(const std::string &name, const std::string &type, const std::vector &position) { string id = util::createId(); - boost::optional g = tag_group(true); + std::optional g = tag_group(true); H5Group group = g->openGroup(name); return make_shared(file(), block(), group, id, type, name, position); @@ -310,7 +310,7 @@ shared_ptr BlockHDF5::createDataArray(const std::string &name, const NDSize &shape, const Compression &compression) { string id = util::createId(); - boost::optional g = data_array_group(true); + std::optional g = data_array_group(true); H5Group group = g->openGroup(name, true); auto da = make_shared(file(), block(), group, id, type, name); @@ -330,7 +330,7 @@ std::shared_ptr BlockHDF5::createDataFrame(const std::string &name, const Compression &compression) { string id = util::createId(); - boost::optional g = data_frame_group(true); + std::optional g = data_frame_group(true); H5Group group = g->openGroup(name, true); auto df = make_shared(file(), block(), group, id, type, name); @@ -346,7 +346,7 @@ std::shared_ptr BlockHDF5::createDataFrame(const std::string &name, shared_ptr BlockHDF5::createMultiTag(const std::string &name, const std::string &type, const DataArray &positions) { string id = util::createId(); - boost::optional g = multi_tag_group(true); + std::optional g = multi_tag_group(true); H5Group group = g->openGroup(name); return make_shared(file(), block(), group, id, type, name, positions); @@ -358,7 +358,7 @@ shared_ptr BlockHDF5::createMultiTag(const std::string &name, const s shared_ptr BlockHDF5::createGroup(const std::string &name, const std::string &type) { string id = util::createId(); - boost::optional g = groups_group(true); + std::optional g = groups_group(true); H5Group group = g->openGroup(name); return make_shared(file(), block(), group, id, type, name); diff --git a/backend/hdf5/BlockHDF5.hpp b/backend/hdf5/BlockHDF5.hpp index 7f523ca1b..0df3eed85 100644 --- a/backend/hdf5/BlockHDF5.hpp +++ b/backend/hdf5/BlockHDF5.hpp @@ -14,7 +14,7 @@ #include #include -#include +#include namespace nix { namespace hdf5 { @@ -67,9 +67,9 @@ class BlockHDF5 : virtual public base::IBlock, public EntityWithMetadataHDF5, private: // Helper methods for generic entity related methods below - boost::optional groupForObjectType(ObjectType ot, bool create = false) const; + std::optional groupForObjectType(ObjectType ot, bool create = false) const; - boost::optional findEntityGroup(const nix::Identity &ident) const; + std::optional findEntityGroup(const nix::Identity &ident) const; public: //-------------------------------------------------- diff --git a/backend/hdf5/DataArrayHDF5.cpp b/backend/hdf5/DataArrayHDF5.cpp index d36177cdd..7ec585e2f 100644 --- a/backend/hdf5/DataArrayHDF5.cpp +++ b/backend/hdf5/DataArrayHDF5.cpp @@ -41,8 +41,8 @@ DataArrayHDF5::DataArrayHDF5(const shared_ptr &file, const shared_ptr DataArrayHDF5::label() const { - boost::optional ret; +std::optional DataArrayHDF5::label() const { + std::optional ret; string value; bool have_attr = group().getAttr("label", value); @@ -68,8 +68,8 @@ void DataArrayHDF5::label(const none_t t) { } -boost::optional DataArrayHDF5::unit() const { - boost::optional ret; +std::optional DataArrayHDF5::unit() const { + std::optional ret; string value; bool have_attr = group().getAttr("unit", value); if (have_attr) { @@ -94,8 +94,8 @@ void DataArrayHDF5::unit(const none_t t) { // TODO use defaults -boost::optional DataArrayHDF5::expansionOrigin() const { - boost::optional ret; +std::optional DataArrayHDF5::expansionOrigin() const { + std::optional ret; double expansion_origin; bool have_attr = group().getAttr("expansion_origin", expansion_origin); if (have_attr) { @@ -157,7 +157,7 @@ void DataArrayHDF5::polynomCoefficients(const none_t t) { ndsize_t DataArrayHDF5::dimensionCount() const { - boost::optional g = dimension_group(); + std::optional g = dimension_group(); ndsize_t count = 0; if (g) { count = g->objectCount(); @@ -168,7 +168,7 @@ ndsize_t DataArrayHDF5::dimensionCount() const { shared_ptr DataArrayHDF5::getDimension(ndsize_t index) const { shared_ptr dim; - boost::optional g = dimension_group(); + std::optional g = dimension_group(); if (g) { string str_id = util::numToStr(index); @@ -219,7 +219,7 @@ std::shared_ptr DataArrayHDF5::createDataFrameDimensi H5Group DataArrayHDF5::createDimensionGroup(ndsize_t index) { - boost::optional g = dimension_group(true); + std::optional g = dimension_group(true); ndsize_t dim_max = dimensionCount() + 1; if (index > dim_max || index <= 0) @@ -236,7 +236,7 @@ H5Group DataArrayHDF5::createDimensionGroup(ndsize_t index) { bool DataArrayHDF5::deleteDimensions() { string dim_id; - boost::optional g = dimension_group(); + std::optional g = dimension_group(); for (ndsize_t i = dimensionCount(); i > 0; --i) { dim_id = util::numToStr(i); if (g->hasGroup(dim_id)) { diff --git a/backend/hdf5/DataArrayHDF5.hpp b/backend/hdf5/DataArrayHDF5.hpp index 4ae6432e0..0ae1e4003 100644 --- a/backend/hdf5/DataArrayHDF5.hpp +++ b/backend/hdf5/DataArrayHDF5.hpp @@ -57,7 +57,7 @@ class DataArrayHDF5 : virtual public base::IDataArray, public EntityWithSources //-------------------------------------------------- - boost::optional label() const; + std::optional label() const; void label(const std::string &label); @@ -66,7 +66,7 @@ class DataArrayHDF5 : virtual public base::IDataArray, public EntityWithSources void label(const none_t t); - boost::optional unit() const; + std::optional unit() const; void unit(const std::string &unit); @@ -75,7 +75,7 @@ class DataArrayHDF5 : virtual public base::IDataArray, public EntityWithSources void unit(const none_t t); - boost::optional expansionOrigin() const; + std::optional expansionOrigin() const; void expansionOrigin(double expansion_origin); diff --git a/backend/hdf5/DimensionHDF5.cpp b/backend/hdf5/DimensionHDF5.cpp index 293ec573b..278f9b0bf 100644 --- a/backend/hdf5/DimensionHDF5.cpp +++ b/backend/hdf5/DimensionHDF5.cpp @@ -142,8 +142,8 @@ DimensionType SampledDimensionHDF5::dimensionType() const { } -boost::optional SampledDimensionHDF5::label() const { - boost::optional ret; +std::optional SampledDimensionHDF5::label() const { + std::optional ret; string label; bool have_attr = group.getAttr("label", label); if (have_attr) { @@ -167,8 +167,8 @@ void SampledDimensionHDF5::label(const none_t t) { } -boost::optional SampledDimensionHDF5::unit() const { - boost::optional ret; +std::optional SampledDimensionHDF5::unit() const { + std::optional ret; string unit; bool have_attr = group.getAttr("unit", unit); if (have_attr) { @@ -209,8 +209,8 @@ void SampledDimensionHDF5::samplingInterval(double sampling_interval) { } -boost::optional SampledDimensionHDF5::offset() const { - boost::optional ret; +std::optional SampledDimensionHDF5::offset() const { + std::optional ret; double offset = 0; if (group.getAttr("offset", offset)) { ret = offset; @@ -249,8 +249,8 @@ DimensionType SetDimensionHDF5::dimensionType() const { } -boost::optional SetDimensionHDF5::label() const { - boost::optional ret; +std::optional SetDimensionHDF5::label() const { + std::optional ret; string label; bool have_attr = group.getAttr("label", label); if (have_attr) { @@ -336,9 +336,9 @@ DataFrameDimensionHDF5::DataFrameDimensionHDF5(const H5Group &group, ndsize_t in this->group.setAttr("column_index", col_index); } -boost::optional DataFrameDimensionHDF5::columnIndex() const { +std::optional DataFrameDimensionHDF5::columnIndex() const { unsigned idx; - boost::optional col_index; + std::optional col_index; if (group.hasAttr("column_index")) { group.getAttr("column_index", idx); @@ -348,8 +348,8 @@ boost::optional DataFrameDimensionHDF5::columnIndex() const { return col_index; } -boost::optional DataFrameDimensionHDF5::checkColumnIndex(boost::optional col_index) const { - boost::optional column_index = col_index; +std::optional DataFrameDimensionHDF5::checkColumnIndex(std::optional col_index) const { + std::optional column_index = col_index; if (!col_index) { column_index = columnIndex(); } @@ -373,8 +373,8 @@ DimensionType DataFrameDimensionHDF5::dimensionType() const { } -std::string DataFrameDimensionHDF5::unit(boost::optional col_index) const { - boost::optional column_index = checkColumnIndex(col_index); +std::string DataFrameDimensionHDF5::unit(std::optional col_index) const { + std::optional column_index = checkColumnIndex(col_index); nix::DataFrame df = dataFrame(); std::vector cols = df.columns(); @@ -382,8 +382,8 @@ std::string DataFrameDimensionHDF5::unit(boost::optional col_index) co } -std::string DataFrameDimensionHDF5::label(boost::optional col_index) const { - boost::optional column_index; +std::string DataFrameDimensionHDF5::label(std::optional col_index) const { + std::optional column_index; nix::DataFrame df = dataFrame(); if (!col_index) { column_index = columnIndex(); @@ -400,8 +400,8 @@ std::string DataFrameDimensionHDF5::label(boost::optional col_index) c } -Column DataFrameDimensionHDF5::column(boost::optional col_index) const { - boost::optional column_index = checkColumnIndex(col_index); +Column DataFrameDimensionHDF5::column(std::optional col_index) const { + std::optional column_index = checkColumnIndex(col_index); nix::DataFrame df = dataFrame(); std::vector cols = df.columns(); @@ -409,8 +409,8 @@ Column DataFrameDimensionHDF5::column(boost::optional col_index) const } -nix::DataType DataFrameDimensionHDF5::columnDataType(boost::optional col_index) const { - boost::optional column_index = checkColumnIndex(col_index); +nix::DataType DataFrameDimensionHDF5::columnDataType(std::optional col_index) const { + std::optional column_index = checkColumnIndex(col_index); nix::DataFrame df = dataFrame(); std::vector all_cols = df.columns(); @@ -480,8 +480,8 @@ H5Group RangeDimensionHDF5::redirectGroup() const { } -boost::optional RangeDimensionHDF5::label() const { - boost::optional ret; +std::optional RangeDimensionHDF5::label() const { + std::optional ret; string label; H5Group g = redirectGroup(); bool have_attr = g.getAttr("label", label); @@ -508,8 +508,8 @@ void RangeDimensionHDF5::label(const none_t t) { } -boost::optional RangeDimensionHDF5::unit() const { - boost::optional ret; +std::optional RangeDimensionHDF5::unit() const { + std::optional ret; string unit; H5Group g = redirectGroup(); bool have_attr = g.getAttr("unit", unit); diff --git a/backend/hdf5/DimensionHDF5.hpp b/backend/hdf5/DimensionHDF5.hpp index 1798976a1..ba0b8cb8c 100644 --- a/backend/hdf5/DimensionHDF5.hpp +++ b/backend/hdf5/DimensionHDF5.hpp @@ -79,7 +79,7 @@ class SampledDimensionHDF5 : virtual public base::ISampledDimension, public Dime DimensionType dimensionType() const; - boost::optional label() const; + std::optional label() const; void label(const std::string &label); @@ -88,7 +88,7 @@ class SampledDimensionHDF5 : virtual public base::ISampledDimension, public Dime void label(const none_t t); - boost::optional unit() const; + std::optional unit() const; void unit(const std::string &unit); @@ -103,7 +103,7 @@ class SampledDimensionHDF5 : virtual public base::ISampledDimension, public Dime void samplingInterval(double sampling_interval); - boost::optional offset() const; + std::optional offset() const; void offset(double offset); @@ -127,7 +127,7 @@ class SetDimensionHDF5 : virtual public base::ISetDimension, public DimensionHDF DimensionType dimensionType() const; - boost::optional label() const; + std::optional label() const; void label(const std::string &label); @@ -155,7 +155,7 @@ class DataFrameDimensionHDF5 : virtual public base::IDataFrameDimension, public std::shared_ptr entity_block; std::shared_ptr entity_file; - boost::optional checkColumnIndex(boost::optional col_index) const; + std::optional checkColumnIndex(std::optional col_index) const; public: DataFrameDimensionHDF5(const H5Group &group, ndsize_t index); @@ -171,15 +171,15 @@ class DataFrameDimensionHDF5 : virtual public base::IDataFrameDimension, public DimensionType dimensionType() const; - boost::optional columnIndex() const; + std::optional columnIndex() const; - Column column(boost::optional col_index) const; + Column column(std::optional col_index) const; - std::string label(boost::optional col_index) const; + std::string label(std::optional col_index) const; - std::string unit(boost::optional col_index) const; + std::string unit(std::optional col_index) const; - nix::DataType columnDataType(boost::optional col_index) const; + nix::DataType columnDataType(std::optional col_index) const; std::shared_ptr dataFrame() const; @@ -206,7 +206,7 @@ class RangeDimensionHDF5 : virtual public base::IRangeDimension, public Dimensio bool alias() const; - boost::optional label() const; + std::optional label() const; void label(const std::string &label); @@ -215,7 +215,7 @@ class RangeDimensionHDF5 : virtual public base::IRangeDimension, public Dimensio void label(const none_t t); - boost::optional unit() const; + std::optional unit() const; void unit(const std::string &unit); diff --git a/backend/hdf5/EntityWithSourcesHDF5.cpp b/backend/hdf5/EntityWithSourcesHDF5.cpp index ce057044e..b5303bbfc 100644 --- a/backend/hdf5/EntityWithSourcesHDF5.cpp +++ b/backend/hdf5/EntityWithSourcesHDF5.cpp @@ -1,3 +1,4 @@ + // Copyright (c) 2013, German Neuroinformatics Node (G-Node) // // All rights reserved. @@ -45,7 +46,7 @@ EntityWithSourcesHDF5::EntityWithSourcesHDF5 (const std::shared_ptr &file ndsize_t EntityWithSourcesHDF5::sourceCount() const { - boost::optional g = sources_refs(false); + std::optional g = sources_refs(false); return g ? g->objectCount() : size_t(0); } @@ -57,7 +58,7 @@ bool EntityWithSourcesHDF5::hasSource(const std::string &id) const { std::shared_ptr EntityWithSourcesHDF5::getSource(const std::string &name_or_id) const { std::shared_ptr source; - boost::optional g = sources_refs(false); + std::optional g = sources_refs(false); std::string id = name_or_id; @@ -78,7 +79,7 @@ std::shared_ptr EntityWithSourcesHDF5::getSource(const std::string &nam } std::shared_ptr EntityWithSourcesHDF5::getSource(const size_t index) const { - boost::optional g = sources_refs(false); + std::optional g = sources_refs(false); std::string id = g ? g->objectName(index) : ""; return getSource(id); } @@ -97,7 +98,7 @@ void EntityWithSourcesHDF5::sources(const std::vector &sources) { void EntityWithSourcesHDF5::addSource(const std::string &id) { if (id.empty()) throw EmptyString("addSource"); - boost::optional g = sources_refs(true); + std::optional g = sources_refs(true); Block tmp(entity_block); auto found = tmp.findSources(util::IdFilter(id)); @@ -111,7 +112,7 @@ void EntityWithSourcesHDF5::addSource(const std::string &id) { bool EntityWithSourcesHDF5::removeSource(const std::string &id) { - boost::optional g = sources_refs(false); + std::optional g = sources_refs(false); bool removed = false; if (g) { diff --git a/backend/hdf5/FileHDF5.cpp b/backend/hdf5/FileHDF5.cpp index acea2d90c..ec0eb0f65 100644 --- a/backend/hdf5/FileHDF5.cpp +++ b/backend/hdf5/FileHDF5.cpp @@ -102,7 +102,7 @@ bool FileHDF5::hasBlock(const std::string &name_or_id) const { shared_ptr FileHDF5::getBlock(const std::string &name_or_id) const { shared_ptr block; - boost::optional group = data.findGroupByNameOrAttribute("entity_id", name_or_id); + std::optional group = data.findGroupByNameOrAttribute("entity_id", name_or_id); if (group) block = make_shared(file(), *group); @@ -153,7 +153,7 @@ bool FileHDF5::hasSection(const std::string &name_or_id) const { shared_ptr FileHDF5::getSection(const std::string &name_or_id) const { shared_ptr sec; - boost::optional group = metadata.findGroupByNameOrAttribute("entity_id", name_or_id); + std::optional group = metadata.findGroupByNameOrAttribute("entity_id", name_or_id); if (group) sec = make_shared(file(), *group); diff --git a/backend/hdf5/GroupHDF5.cpp b/backend/hdf5/GroupHDF5.cpp index 53a572135..74474a599 100644 --- a/backend/hdf5/GroupHDF5.cpp +++ b/backend/hdf5/GroupHDF5.cpp @@ -20,8 +20,8 @@ using namespace nix::base; namespace nix { namespace hdf5 { -boost::optional GroupHDF5::groupForObjectType(ObjectType type, bool create) const { - boost::optional p; +std::optional GroupHDF5::groupForObjectType(ObjectType type, bool create) const { + std::optional p; switch (type) { case ObjectType::DataArray: @@ -40,20 +40,20 @@ boost::optional GroupHDF5::groupForObjectType(ObjectType type, bool cre //TODO default: - p = boost::optional(create); + p = std::optional(create); } return p; } -boost::optional GroupHDF5::findEntityGroup(const nix::Identity &ident) const { - boost::optional p = groupForObjectType(ident.type()); +std::optional GroupHDF5::findEntityGroup(const nix::Identity &ident) const { + std::optional p = groupForObjectType(ident.type()); if (!p) { return p; } - boost::optional g; + std::optional g; const std::string &iname = ident.name(); const std::string &iid = ident.id(); @@ -67,7 +67,7 @@ boost::optional GroupHDF5::findEntityGroup(const nix::Identity &ident) bool foundNeedle = p->hasObject(needle); if (foundNeedle) { - g = boost::make_optional(p->openGroup(needle, false)); + g = std::make_optional(p->openGroup(needle, false)); } else if (haveName) { g = p->findGroupByAttribute("name", iname); } @@ -77,7 +77,7 @@ boost::optional GroupHDF5::findEntityGroup(const nix::Identity &ident) g->getAttr("name", ename); if (ename != iname) { - return boost::optional(); + return std::optional(); } } @@ -118,12 +118,12 @@ GroupHDF5::GroupHDF5(const std::shared_ptr &file, } bool GroupHDF5::hasEntity(const nix::Identity &ident) const { - boost::optional p = findEntityGroup(ident); + std::optional p = findEntityGroup(ident); return !!p; } std::shared_ptr GroupHDF5::getEntity(const nix::Identity &ident) const { - boost::optional eg = findEntityGroup(ident); + std::optional eg = findEntityGroup(ident); switch (ident.type()) { case ObjectType::DataArray: { @@ -161,21 +161,21 @@ std::shared_ptr GroupHDF5::getEntity(const nix::Identity &ident) } std::shared_ptrGroupHDF5::getEntity(ObjectType type, ndsize_t index) const { - boost::optional eg = groupForObjectType(type); + std::optional eg = groupForObjectType(type); std::string name = eg ? eg->objectName(index) : ""; return getEntity({name, "", type}); } ndsize_t GroupHDF5::entityCount(ObjectType type) const { - boost::optional g = groupForObjectType(type); + std::optional g = groupForObjectType(type); return g ? g->objectCount() : ndsize_t(0); } bool GroupHDF5::removeEntity(const nix::Identity &ident) { - boost::optional p = groupForObjectType(ident.type()); - boost::optional eg = findEntityGroup(ident); + std::optional p = groupForObjectType(ident.type()); + std::optional eg = findEntityGroup(ident); if (!p || !eg) { return false; @@ -190,7 +190,7 @@ bool GroupHDF5::removeEntity(const nix::Identity &ident) { void GroupHDF5::addEntity(const nix::Identity &ident) { - boost::optional p = groupForObjectType(ident.type(), true); + std::optional p = groupForObjectType(ident.type(), true); if(!block()->hasEntity(ident)) { throw std::runtime_error("Entity does not exist in this block!"); } diff --git a/backend/hdf5/GroupHDF5.hpp b/backend/hdf5/GroupHDF5.hpp index a12e9de05..ffb86a876 100644 --- a/backend/hdf5/GroupHDF5.hpp +++ b/backend/hdf5/GroupHDF5.hpp @@ -25,9 +25,9 @@ class GroupHDF5 : virtual public base::IGroup, public EntityWithSourcesHDF5, // Helper methods for generic entity related methods below - boost::optional groupForObjectType(ObjectType ot, bool create = false) const; + std::optional groupForObjectType(ObjectType ot, bool create = false) const; - boost::optional findEntityGroup(const nix::Identity &ident) const; + std::optional findEntityGroup(const nix::Identity &ident) const; public: diff --git a/backend/hdf5/NamedEntityHDF5.cpp b/backend/hdf5/NamedEntityHDF5.cpp index 89fb507cb..1ff816494 100644 --- a/backend/hdf5/NamedEntityHDF5.cpp +++ b/backend/hdf5/NamedEntityHDF5.cpp @@ -91,8 +91,8 @@ void NamedEntityHDF5::definition(const string &definition) { } -boost::optional NamedEntityHDF5::definition() const { - boost::optional ret; +std::optional NamedEntityHDF5::definition() const { + std::optional ret; string definition; bool have_attr = group().getAttr("definition", definition); if (have_attr) { @@ -125,4 +125,4 @@ int NamedEntityHDF5::compare(const std::shared_ptr &other) const { NamedEntityHDF5::~NamedEntityHDF5() {} } // ns nix::hdf5 -} // ns nix \ No newline at end of file +} // ns nix diff --git a/backend/hdf5/NamedEntityHDF5.hpp b/backend/hdf5/NamedEntityHDF5.hpp index 022fa74d2..043bfdde8 100644 --- a/backend/hdf5/NamedEntityHDF5.hpp +++ b/backend/hdf5/NamedEntityHDF5.hpp @@ -53,7 +53,7 @@ class NamedEntityHDF5 : virtual public base::INamedEntity, public EntityHDF5 { std::string name() const; - boost::optional definition() const; + std::optional definition() const; void definition(const std::string &definition); diff --git a/backend/hdf5/PropertyHDF5.cpp b/backend/hdf5/PropertyHDF5.cpp index 2ba33c8e1..a345e8d8e 100644 --- a/backend/hdf5/PropertyHDF5.cpp +++ b/backend/hdf5/PropertyHDF5.cpp @@ -141,8 +141,8 @@ void PropertyHDF5::definition(const string &definition) { } -boost::optional PropertyHDF5::definition() const { - boost::optional ret; +std::optional PropertyHDF5::definition() const { + std::optional ret; string definition; bool have_attr = dataset().getAttr("definition", definition); if (have_attr) { @@ -172,8 +172,8 @@ void PropertyHDF5::unit(const string &unit) { } -boost::optional PropertyHDF5::unit() const { - boost::optional ret; +std::optional PropertyHDF5::unit() const { + std::optional ret; string unit; if (dataset().getAttr("unit", unit)) { ret = unit; @@ -196,8 +196,8 @@ void PropertyHDF5::uncertainty(double uncertainty) { } -boost::optional PropertyHDF5::uncertainty() const { - boost::optional ret; +std::optional PropertyHDF5::uncertainty() const { + std::optional ret; double error; nix::FormatVersion ver(this->entity_file->version()); if (ver < nix::FormatVersion({1, 1, 1})) { diff --git a/backend/hdf5/PropertyHDF5.hpp b/backend/hdf5/PropertyHDF5.hpp index ea1f8d9e8..d89bca2cc 100644 --- a/backend/hdf5/PropertyHDF5.hpp +++ b/backend/hdf5/PropertyHDF5.hpp @@ -72,7 +72,7 @@ class PropertyHDF5 : virtual public base::IProperty { std::string name() const; - boost::optional definition() const; + std::optional definition() const; void definition(const std::string &definition); @@ -87,7 +87,7 @@ class PropertyHDF5 : virtual public base::IProperty { void unit(const std::string &unit); - boost::optional unit() const; + std::optional unit() const; void unit(const none_t t); @@ -96,7 +96,7 @@ class PropertyHDF5 : virtual public base::IProperty { void uncertainty(double uncertainty); - boost::optional uncertainty() const; + std::optional uncertainty() const; void uncertainty(const none_t t); @@ -114,7 +114,7 @@ class PropertyHDF5 : virtual public base::IProperty { std::vector values(void) const; - void values(const boost::none_t t); + void values(const none_t t); bool isValidEntity() const; diff --git a/backend/hdf5/SectionHDF5.cpp b/backend/hdf5/SectionHDF5.cpp index 2aeee02c0..1d81d0d36 100644 --- a/backend/hdf5/SectionHDF5.cpp +++ b/backend/hdf5/SectionHDF5.cpp @@ -75,8 +75,8 @@ void SectionHDF5::repository(const string &repository) { } -boost::optional SectionHDF5::repository() const { - boost::optional ret; +std::optional SectionHDF5::repository() const { + std::optional ret; string repository; if (group().getAttr("repository", repository)) { ret = repository; @@ -149,7 +149,7 @@ shared_ptr SectionHDF5::parent() const { ndsize_t SectionHDF5::sectionCount() const { - boost::optional g = section_group(); + std::optional g = section_group(); return g ? g->objectCount() : size_t(0); } @@ -161,10 +161,10 @@ bool SectionHDF5::hasSection(const string &name_or_id) const { shared_ptr SectionHDF5::getSection(const string &name_or_id) const { shared_ptr section; - boost::optional g = section_group(); + std::optional g = section_group(); if(g) { - boost::optional group = g->findGroupByNameOrAttribute("entity_id", name_or_id); + std::optional group = g->findGroupByNameOrAttribute("entity_id", name_or_id); if (group) { auto p = const_pointer_cast(shared_from_this()); section = make_shared(file(), p, *group); @@ -176,7 +176,7 @@ shared_ptr SectionHDF5::getSection(const string &name_or_id) const { shared_ptr SectionHDF5::getSection(ndsize_t index) const { - boost::optional g = section_group(); + std::optional g = section_group(); string name = g ? g->objectName(index) : ""; return getSection(name); } @@ -184,7 +184,7 @@ shared_ptr SectionHDF5::getSection(ndsize_t index) const { shared_ptr SectionHDF5::createSection(const string &name, const string &type) { string new_id = util::createId(); - boost::optional g = section_group(true); + std::optional g = section_group(true); auto p = const_pointer_cast(shared_from_this()); H5Group grp = g->openGroup(name, true); @@ -193,7 +193,7 @@ shared_ptr SectionHDF5::createSection(const string &name, const string bool SectionHDF5::deleteSection(const string &name_or_id) { - boost::optional g = section_group(); + std::optional g = section_group(); bool deleted = false; if (g) { @@ -220,7 +220,7 @@ bool SectionHDF5::deleteSection(const string &name_or_id) { ndsize_t SectionHDF5::propertyCount() const { - boost::optional g = property_group(); + std::optional g = property_group(); return g ? g->objectCount() : size_t(0); } @@ -232,10 +232,10 @@ bool SectionHDF5::hasProperty(const string &name_or_id) const { shared_ptr SectionHDF5::getProperty(const string &name_or_id) const { shared_ptr prop; - boost::optional g = property_group(); + std::optional g = property_group(); if (g) { - boost::optional dset = g->findDataByNameOrAttribute("entity_id", name_or_id); + std::optional dset = g->findDataByNameOrAttribute("entity_id", name_or_id); if (dset) prop = make_shared(file(), *dset); } @@ -245,7 +245,7 @@ shared_ptr SectionHDF5::getProperty(const string &name_or_id) const { shared_ptr SectionHDF5::getProperty(ndsize_t index) const { - boost::optional g = property_group(); + std::optional g = property_group(); string name = g ? g->objectName(index) : ""; return getProperty(name); } @@ -253,7 +253,7 @@ shared_ptr SectionHDF5::getProperty(ndsize_t index) const { shared_ptr SectionHDF5::createProperty(const string &name, const DataType &dtype, const NDSize &shape) { string new_id = util::createId(); - boost::optional g = property_group(true); + std::optional g = property_group(true); DataSet ds = g->createData(name, data_type_to_h5_filetype(dtype), shape, Compression::DeflateNormal, {}, shape, true, false); return make_shared(file(), ds, new_id, name); @@ -283,7 +283,7 @@ shared_ptr SectionHDF5::createProperty(const string &name, const vect bool SectionHDF5::deleteProperty(const string &name_or_id) { - boost::optional g = property_group(); + std::optional g = property_group(); bool deleted = false; if (g && hasProperty(name_or_id)) { g->removeData(getProperty(name_or_id)->name()); diff --git a/backend/hdf5/SectionHDF5.hpp b/backend/hdf5/SectionHDF5.hpp index ce62d97d9..c821d6eea 100644 --- a/backend/hdf5/SectionHDF5.hpp +++ b/backend/hdf5/SectionHDF5.hpp @@ -77,7 +77,7 @@ class SectionHDF5 : public NamedEntityHDF5, virtual public base::ISection, void repository(const std::string &repository); - boost::optional repository() const; + std::optional repository() const; void repository(const none_t t); diff --git a/backend/hdf5/SourceHDF5.cpp b/backend/hdf5/SourceHDF5.cpp index f7b2cda5a..30ebd44c3 100644 --- a/backend/hdf5/SourceHDF5.cpp +++ b/backend/hdf5/SourceHDF5.cpp @@ -44,10 +44,10 @@ bool SourceHDF5::hasSource(const string &name_or_id) const { shared_ptr SourceHDF5::getSource(const string &name_or_id) const { shared_ptr source; - boost::optional g = source_group(); + std::optional g = source_group(); if (g) { - boost::optional group = g->findGroupByNameOrAttribute("entity_id", name_or_id); + std::optional group = g->findGroupByNameOrAttribute("entity_id", name_or_id); if (group) source = make_shared(file(), parentBlock(), *group); } @@ -57,21 +57,21 @@ shared_ptr SourceHDF5::getSource(const string &name_or_id) const { shared_ptr SourceHDF5::getSource(ndsize_t index) const { - boost::optional g = source_group(); + std::optional g = source_group(); string name = g ? g->objectName(index) : ""; return getSource(name); } ndsize_t SourceHDF5::sourceCount() const { - boost::optional g = source_group(false); + std::optional g = source_group(false); return g ? g->objectCount() : size_t(0); } shared_ptr SourceHDF5::createSource(const string &name, const string &type) { string id = util::createId(); - boost::optional g = source_group(true); + std::optional g = source_group(true); H5Group group = g->openGroup(name, true); return make_shared(file(), parentBlock(), group, id, type, name); @@ -79,7 +79,7 @@ shared_ptr SourceHDF5::createSource(const string &name, const string &t bool SourceHDF5::deleteSource(const string &name_or_id) { - boost::optional g = source_group(); + std::optional g = source_group(); bool deleted = false; if(g) { diff --git a/backend/hdf5/SourceHDF5.hpp b/backend/hdf5/SourceHDF5.hpp index fb4e3fbcf..8bd3cb2ac 100644 --- a/backend/hdf5/SourceHDF5.hpp +++ b/backend/hdf5/SourceHDF5.hpp @@ -14,7 +14,6 @@ #include #include -#include namespace nix { namespace hdf5 { diff --git a/backend/hdf5/h5x/H5Group.cpp b/backend/hdf5/h5x/H5Group.cpp index 3baa1a34f..fedc4a770 100644 --- a/backend/hdf5/h5x/H5Group.cpp +++ b/backend/hdf5/h5x/H5Group.cpp @@ -18,11 +18,11 @@ optGroup::optGroup(const H5Group &parent, const std::string &g_name) : parent(parent), g_name(g_name) {} -boost::optional optGroup::operator() (bool create) const { +std::optional optGroup::operator() (bool create) const { if (parent.hasGroup(g_name)) { - g = boost::optional(parent.openGroup(g_name)); + g = std::optional(parent.openGroup(g_name)); } else if (create) { - g = boost::optional(parent.openGroup(g_name, true)); + g = std::optional(parent.openGroup(g_name, true)); } return g; } @@ -73,8 +73,8 @@ ndsize_t H5Group::objectCount() const { } -boost::optional H5Group::findGroupByAttribute(const std::string &attribute, const std::string &value) const { - boost::optional ret; +std::optional H5Group::findGroupByAttribute(const std::string &attribute, const std::string &value) const { + std::optional ret; // look up first direct sub-group that has given attribute with given value for (ndsize_t index = 0; index < objectCount(); index++) { @@ -96,9 +96,9 @@ boost::optional H5Group::findGroupByAttribute(const std::string &attrib } -boost::optional H5Group::findDataByAttribute(const std::string &attribute, const std::string &value) const { +std::optional H5Group::findDataByAttribute(const std::string &attribute, const std::string &value) const { std::vector dsets; - boost::optional ret; + std::optional ret; // look up all direct sub-datasets that have the given attribute for (ndsize_t index = 0; index < objectCount(); index++) { @@ -339,26 +339,26 @@ bool H5Group::removeAllLinks(const std::string &name) { } -boost::optional H5Group::findGroupByNameOrAttribute(std::string const &attr, std::string const &value) const { +std::optional H5Group::findGroupByNameOrAttribute(std::string const &attr, std::string const &value) const { if (hasObject(value)) { - return boost::make_optional(openGroup(value, false)); + return std::make_optional(openGroup(value, false)); } else if (util::looksLikeUUID(value)) { return findGroupByAttribute(attr, value); } else { - return boost::optional(); + return std::optional(); } } -boost::optional H5Group::findDataByNameOrAttribute(std::string const &attr, std::string const &value) const { +std::optional H5Group::findDataByNameOrAttribute(std::string const &attr, std::string const &value) const { if (hasObject(value)) { - return boost::make_optional(openData(value)); + return std::make_optional(openData(value)); } else if (util::looksLikeUUID(value)) { return findDataByAttribute(attr, value); } else { - return boost::optional(); + return std::optional(); } } diff --git a/backend/hdf5/h5x/H5Group.hpp b/backend/hdf5/h5x/H5Group.hpp index 9fc480e95..c5b2b588e 100644 --- a/backend/hdf5/h5x/H5Group.hpp +++ b/backend/hdf5/h5x/H5Group.hpp @@ -16,10 +16,9 @@ #include #include -#include - #include #include +#include namespace nix { namespace hdf5 { @@ -99,7 +98,7 @@ class NIXAPI H5Group : public LocID { * * @return The name of the first group object found. */ - boost::optional findGroupByAttribute(const std::string &attribute, const std::string &value) const; + std::optional findGroupByAttribute(const std::string &attribute, const std::string &value) const; /** * @brief Look for the first sub-data in the group with the given @@ -111,7 +110,7 @@ class NIXAPI H5Group : public LocID { * * @return The name of the first dataset object found. */ - boost::optional findDataByAttribute(const std::string &attribute, const std::string &value) const; + std::optional findDataByAttribute(const std::string &attribute, const std::string &value) const; /** * @brief Look for the first sub-data in the group with the given @@ -124,7 +123,7 @@ class NIXAPI H5Group : public LocID { * * @return Optional containing the located H5Group or empty optional otherwise. */ - boost::optional findGroupByNameOrAttribute(std::string const &attribute, std::string const &value) const; + std::optional findGroupByNameOrAttribute(std::string const &attribute, std::string const &value) const; /** * @brief Look for the first sub-data in the group with the given @@ -137,7 +136,7 @@ class NIXAPI H5Group : public LocID { * * @return Optional containing the located Dataset or empty optional otherwise. */ - boost::optional findDataByNameOrAttribute(std::string const &attribute, std::string const &value) const; + std::optional findDataByNameOrAttribute(std::string const &attribute, std::string const &value) const; /** * @brief Create a new hard link with the given name inside this group, @@ -249,7 +248,7 @@ bool H5Group::getData(const std::string &name, T &value) const * unset optional is returned. */ struct NIXAPI optGroup { - mutable boost::optional g; + mutable std::optional g; H5Group parent; std::string g_name; @@ -268,7 +267,7 @@ struct NIXAPI optGroup { * * @return An optional with the opened group or unset. */ - boost::optional operator() (bool create = false) const; + std::optional operator() (bool create = false) const; }; diff --git a/include/nix/Block.hpp b/include/nix/Block.hpp index 7a8923cbf..18cd494b2 100644 --- a/include/nix/Block.hpp +++ b/include/nix/Block.hpp @@ -65,7 +65,7 @@ namespace nix { * b.metadata(); * * // remove associated metadata from a block - * b.metadata(boost::none); + * b.metadata(nix::none); * ~~~ * * ### Deleting a block diff --git a/include/nix/DataArray.hpp b/include/nix/DataArray.hpp index 0fa88d3b1..b0a295677 100644 --- a/include/nix/DataArray.hpp +++ b/include/nix/DataArray.hpp @@ -134,7 +134,7 @@ class NIXAPI DataArray : public base::EntityWithSources, publi * * @return The label of the data array. */ - boost::optional label() const { + std::optional label() const { return backend()->label(); } @@ -159,7 +159,7 @@ class NIXAPI DataArray : public base::EntityWithSources, publi * * @return The unit of the data array. */ - boost::optional unit() const { + std::optional unit() const { return backend()->unit(); } @@ -186,7 +186,7 @@ class NIXAPI DataArray : public base::EntityWithSources, publi * * @return The expansion origin. */ - boost::optional expansionOrigin() const { + std::optional expansionOrigin() const { return backend()->expansionOrigin(); } diff --git a/include/nix/Dimensions.hpp b/include/nix/Dimensions.hpp index b2aa69064..2e36aad33 100644 --- a/include/nix/Dimensions.hpp +++ b/include/nix/Dimensions.hpp @@ -14,6 +14,8 @@ #include +#include + namespace nix { class DataArray; class Dimension; @@ -24,11 +26,11 @@ class Dimension; * These constants are used to control the behaviour of the index finding. */ enum class PositionMatch { - Equal, - Less, - Greater, - GreaterOrEqual, - LessOrEqual + Equal, + Less, + Greater, + GreaterOrEqual, + LessOrEqual }; /** @@ -39,8 +41,8 @@ enum class PositionMatch { * Exclusive means [start, end), i.e. start is included, end is not */ enum class RangeMatch { - Inclusive, - Exclusive + Inclusive, + Exclusive }; /** @@ -50,11 +52,11 @@ enum class RangeMatch { * the data range. */ enum class PositionInRange{ - InRange, - Greater, - Less, + InRange, + Greater, + Less, - NoRange = -1 + NoRange = -1 }; /** @@ -82,7 +84,7 @@ enum class PositionInRange{ */ class NIXAPI SampledDimension : public base::ImplContainer { -public: + public: /** * @brief Constructor that creates an uninitialized SampledDimension. @@ -160,7 +162,7 @@ class NIXAPI SampledDimension : public base::ImplContainer label() const { + std::optional label() const { return backend()->label(); } @@ -188,7 +190,7 @@ class NIXAPI SampledDimension : public base::ImplContainer unit() const { + std::optional unit() const { return backend()->unit(); } @@ -217,7 +219,7 @@ class NIXAPI SampledDimension : public base::ImplContainersamplingInterval(); + return backend()->samplingInterval(); } /** @@ -237,7 +239,7 @@ class NIXAPI SampledDimension : public base::ImplContainer offset() const { + std::optional offset() const { return backend()->offset(); } @@ -257,7 +259,7 @@ class NIXAPI SampledDimension : public base::ImplContaineroffset(t); } @@ -290,7 +292,7 @@ class NIXAPI SampledDimension : public base::ImplContainer indexOf(const double position, PositionMatch match) const; + std::optional indexOf(const double position, PositionMatch match) const; /** @@ -310,7 +312,7 @@ class NIXAPI SampledDimension : public base::ImplContainer> indexOf(const double start, const double end, RangeMatch match) const; + std::optional> indexOf(const double start, const double end, RangeMatch match) const; /** * @deprecated This function has been deprecated please use @@ -335,10 +337,10 @@ class NIXAPI SampledDimension : public base::ImplContainer> indexOf(double start, double end, const double sampling_interval, const double offset, - const RangeMatch match) const; + std::optional> indexOf(double start, double end, const double sampling_interval, const double offset, + const RangeMatch match) const; /** @@ -354,9 +356,9 @@ class NIXAPI SampledDimension : public base::ImplContainer>> indexOf(const std::vector &start_positions, - const std::vector &end_positions, - const RangeMatch match) const; + std::vector>> indexOf(const std::vector &start_positions, + const std::vector &end_positions, + const RangeMatch match) const; /** * @deprecated This function has been deprecated please use @@ -504,7 +506,7 @@ class NIXAPI DataFrameDimension : public base::ImplContainer columnIndex() const { + std::optional columnIndex() const { return backend()->columnIndex(); } @@ -529,7 +531,7 @@ class NIXAPI DataFrameDimension : public base::ImplContainer col_index = {}) const { + std::string label(std::optional col_index = {}) const { return backend()->label(col_index); } @@ -544,7 +546,7 @@ class NIXAPI DataFrameDimension : public base::ImplContainer col_index = {}) const { + std::string unit(std::optional col_index = {}) const { return backend()->unit(col_index); } @@ -559,7 +561,7 @@ class NIXAPI DataFrameDimension : public base::ImplContainer col_index = {}) const { + nix::DataType columnDataType(std::optional col_index = {}) const { return backend()->columnDataType(col_index); } @@ -584,9 +586,9 @@ class NIXAPI DataFrameDimension : public base::ImplContainer - void ticks(std::vector &ticks, boost::optional col_index = {}, bool resize=false, ndsize_t offset=0) const { + void ticks(std::vector &ticks, std::optional col_index = {}, bool resize=false, ndsize_t offset=0) const { nix::DataFrame df = data(); - boost::optional column_index; + std::optional column_index; if (!col_index) { column_index = columnIndex(); } else { @@ -603,37 +605,37 @@ class NIXAPI DataFrameDimension : public base::ImplContainer indexOf(const double position, const PositionMatch match) const; - - /** - * @brief Converts a range defined by start and end position to the corresponding indices in the dimension. - * - * @param start_position The start position that should be converted to a corresponding index in the dimension. - * @param end_position The start position that should be converted to a corresponding index in the dimension. - * @param range_match The matching rule for the position {@link RangeMatch}. - * - * @return an boost::optional containing a std::pair of start and end index. - */ - boost::optional> indexOf(double start_position, double end_position, RangeMatch range_match) const; + * @brief returns the index in this dimension that matches the given position. + * + * @param position The position that should be converted to a corresponding index in the dimension. + * @param match The matching rule for the position {@link PositionMatch}. + * + * @return an std::optional containing the index. + */ + std::optional indexOf(const double position, const PositionMatch match) const; + + /** + * @brief Converts a range defined by start and end position to the corresponding indices in the dimension. + * + * @param start_position The start position that should be converted to a corresponding index in the dimension. + * @param end_position The start position that should be converted to a corresponding index in the dimension. + * @param range_match The matching rule for the position {@link RangeMatch}. + * + * @return an std::optional containing a std::pair of start and end index. + */ + std::optional> indexOf(double start_position, double end_position, RangeMatch range_match) const; /** - * @brief Converts a range defined by start and end position to the corresponding indices in the dimension. Mostly needed internally. - * - * @param start_position The start position that should be converted to a corresponding index in the dimension. - * @param end_position The start position that should be converted to a corresponding index in the dimension. - * @param tick_count The number of of ticks stored in this dimension. - * @param range_match The matching rule for the range {@link RangeMatch}. - * - * @return an boost::optional containing a std::pair of start and end index. - */ - boost::optional> indexOf(double start_position, double end_position, ndsize_t tick_count, RangeMatch range_match) const; + * @brief Converts a range defined by start and end position to the corresponding indices in the dimension. Mostly needed internally. + * + * @param start_position The start position that should be converted to a corresponding index in the dimension. + * @param end_position The start position that should be converted to a corresponding index in the dimension. + * @param tick_count The number of of ticks stored in this dimension. + * @param range_match The matching rule for the range {@link RangeMatch}. + * + * @return an std::optional containing a std::pair of start and end index. + */ + std::optional> indexOf(double start_position, double end_position, ndsize_t tick_count, RangeMatch range_match) const; /** * @brief Converts a set of start and end positions to a vector of pairs of start and end indices. @@ -642,11 +644,11 @@ class NIXAPI DataFrameDimension : public base::ImplContainer>> indexOf(const std::vector &start_positions, - const std::vector &end_positions, - const RangeMatch range_match) const; + * @return A std::vector of std::optionals containing pairs of start and end indices. + */ + std::vector>> indexOf(const std::vector &start_positions, + const std::vector &end_positions, + const RangeMatch range_match) const; /** * @brief returns the number of entries in the dimension, aka the number of @@ -703,7 +705,7 @@ class NIXAPI DataFrameDimension : public base::ImplContainer { -public: + public: /** * @brief Constructor that creates an uninitialized SetDimension. @@ -781,7 +783,7 @@ class NIXAPI SetDimension : public base::ImplContainer { * * @return The label of the dimension. */ - boost::optional label() const { + std::optional label() const { return backend()->label(); } @@ -827,7 +829,7 @@ class NIXAPI SetDimension : public base::ImplContainer { * * @param t None */ - void labels(const boost::none_t t) { + void labels(const none_t t) { backend()->labels(t); } @@ -840,7 +842,7 @@ class NIXAPI SetDimension : public base::ImplContainer { * * @return An optional containing the index, if valid. */ - boost::optional indexOf(const double position, const PositionMatch match) const; + std::optional indexOf(const double position, const PositionMatch match) const; /** @@ -852,7 +854,7 @@ class NIXAPI SetDimension : public base::ImplContainer { * * @return optional containing a pair of ndsize_t. */ - boost::optional> indexOf(const double start, const double end, const RangeMatch match) const; + std::optional> indexOf(const double start, const double end, const RangeMatch match) const; /** * @brief returns the start and end indices corresponding to the provided start and end positions. @@ -864,7 +866,7 @@ class NIXAPI SetDimension : public base::ImplContainer { * * @return optional containing a pair of ndsize_t. */ - boost::optional> indexOf(const double start, const double end, std::vector &set_labels, const RangeMatch match) const; + std::optional> indexOf(const double start, const double end, std::vector &set_labels, const RangeMatch match) const; /** * @brief converts vectors of start and end positions to a vector of optionals containg start and end indices. @@ -875,9 +877,9 @@ class NIXAPI SetDimension : public base::ImplContainer { * * @return vector of optionals containing a pair of start and end indices */ - std::vector>> indexOf(const std::vector &start_positions, - const std::vector &end_positions, - const RangeMatch match) const; + std::vector>> indexOf(const std::vector &start_positions, + const std::vector &end_positions, + const RangeMatch match) const; /** @@ -916,7 +918,7 @@ class NIXAPI SetDimension : public base::ImplContainer { */ class NIXAPI RangeDimension : public base::ImplContainer { -public: + public: /** * @brief Constructor that creates an uninitialized RangeDimension. @@ -1013,7 +1015,7 @@ class NIXAPI RangeDimension : public base::ImplContainer * * @return The label of the dimension. */ - boost::optional label() const { + std::optional label() const { return backend()->label(); } @@ -1041,7 +1043,7 @@ class NIXAPI RangeDimension : public base::ImplContainer * * @return The unit of the dimension. */ - boost::optional unit() const { + std::optional unit() const { return backend()->unit(); } @@ -1134,10 +1136,10 @@ class NIXAPI RangeDimension : public base::ImplContainer * @param matching PositionMatch enum entry that defines the matching * behavior. * - * @return boost optional containing the index if valid + * @return std optional containing the index if valid * */ - boost::optional indexOf(const double position, PositionMatch matching) const; + std::optional indexOf(const double position, PositionMatch matching) const; /** @@ -1152,11 +1154,11 @@ class NIXAPI RangeDimension : public base::ImplContainer * @param range RangeMatch enum, controls whether end is included or not, * defaults to RangeMatch::Inclusive * - * @return Start and end indices returned in a boost::optional + * @return Start and end indices returned in a std::optional * which is invalid if out of range. */ - boost::optional> indexOf(double start, double end, std::vector ticks, - RangeMatch match = RangeMatch::Exclusive) const; + std::optional> indexOf(double start, double end, std::vector ticks, + RangeMatch match = RangeMatch::Exclusive) const; /** @@ -1201,7 +1203,7 @@ class NIXAPI RangeDimension : public base::ImplContainer DEPRECATED std::pair indexOf(const double start, const double end) const; - /** + /** * @brief Returns a vector of start and end indices of given start and end positions. * * Method will return the index equal or larger than the respective positions @@ -1222,7 +1224,7 @@ class NIXAPI RangeDimension : public base::ImplContainer bool strict, RangeMatch match = RangeMatch::Inclusive) const; - /** + /** * @brief Returns a vector of start and end indices of given start and end positions. * * Method will return the index equal or larger than the respective positions @@ -1234,9 +1236,9 @@ class NIXAPI RangeDimension : public base::ImplContainer * * @return Vector of optional pairs of start and end indices. */ - std::vector>> indexOf(const std::vector &start_positions, - const std::vector &end_positions, - RangeMatch match = RangeMatch::Exclusive) const; + std::vector>> indexOf(const std::vector &start_positions, + const std::vector &end_positions, + RangeMatch match = RangeMatch::Exclusive) const; /** * @brief Returns a vector containing a number of ticks @@ -1299,7 +1301,7 @@ class NIXAPI RangeDimension : public base::ImplContainer */ class NIXAPI Dimension : public base::ImplContainer { -public: + public: /** * @brief Constructor that creates an uninitialized Dimension. @@ -1379,7 +1381,7 @@ class NIXAPI Dimension : public base::ImplContainer { */ Dimension(const SetDimension &other); - /** + /** * @brief Copy constructor that converts a DataFrameDimension to Dimension. * * Copying of all NIX front facing objects like Dimension is a rather cheap operation. diff --git a/include/nix/MultiTag.hpp b/include/nix/MultiTag.hpp index 51095af09..8a58370de 100644 --- a/include/nix/MultiTag.hpp +++ b/include/nix/MultiTag.hpp @@ -181,7 +181,7 @@ class NIXAPI MultiTag : public base::EntityWithSources { * * @param t None */ - void extents(const boost::none_t t) { + void extents(const nix::none_t t) { backend()->extents(t); } @@ -214,7 +214,7 @@ class NIXAPI MultiTag : public base::EntityWithSources { * * @param t None */ - void units(const boost::none_t t) { + void units(const nix::none_t t) { backend()->units(t); } diff --git a/include/nix/None.hpp b/include/nix/None.hpp index fe6d2b8b6..da9ca373e 100644 --- a/include/nix/None.hpp +++ b/include/nix/None.hpp @@ -11,12 +11,12 @@ #ifndef NIX_NONE_H #define NIX_NONE_H -#include +#include namespace nix { -typedef boost::none_t none_t; -const none_t none = boost::none; +typedef std::nullopt_t none_t; +const none_t none = std::nullopt; } diff --git a/include/nix/Property.hpp b/include/nix/Property.hpp index 5ccabf33f..5804461d0 100644 --- a/include/nix/Property.hpp +++ b/include/nix/Property.hpp @@ -125,7 +125,7 @@ class NIXAPI Property : public base::Entity { * * @return The definition of the property. */ - boost::optional definition() const { + std::optional definition() const { return backend()->definition(); } @@ -161,7 +161,7 @@ class NIXAPI Property : public base::Entity { * * @return The uncertainty. */ - boost::optional uncertainty() const { + std::optional uncertainty() const { return backend()->uncertainty(); } @@ -170,7 +170,7 @@ class NIXAPI Property : public base::Entity { * * @param t None */ - void uncertainty(const boost::none_t t) { + void uncertainty(const nix::none_t t) { return backend()->uncertainty(t); } @@ -186,7 +186,7 @@ class NIXAPI Property : public base::Entity { * * @return The unit for all values. */ - boost::optional unit() const { + std::optional unit() const { return backend()->unit(); } @@ -195,7 +195,7 @@ class NIXAPI Property : public base::Entity { * * @param t None */ - void unit(const boost::none_t t) { + void unit(const nix::none_t t) { return backend()->unit(t); } @@ -240,7 +240,7 @@ class NIXAPI Property : public base::Entity { /** * @brief Deletes all values from the property. */ - void values(const boost::none_t t) { + void values(const nix::none_t t) { backend()->values(t); } diff --git a/include/nix/Section.hpp b/include/nix/Section.hpp index 6ea084e0a..bfe02b35d 100644 --- a/include/nix/Section.hpp +++ b/include/nix/Section.hpp @@ -97,7 +97,7 @@ class NIXAPI Section : public base::NamedEntity { * * @return The URL to the repository. */ - boost::optional repository() const { + std::optional repository() const { return backend()->repository(); } @@ -106,7 +106,7 @@ class NIXAPI Section : public base::NamedEntity { * * @param t None */ - void repository(const boost::none_t t) { + void repository(const nix::none_t t) { backend()->repository(t); } @@ -149,7 +149,7 @@ class NIXAPI Section : public base::NamedEntity { * * @param t None */ - void link(const boost::none_t t) { + void link(const nix::none_t t) { backend()->link(t); } diff --git a/include/nix/Tag.hpp b/include/nix/Tag.hpp index 0d8de4f0e..93991f03c 100644 --- a/include/nix/Tag.hpp +++ b/include/nix/Tag.hpp @@ -135,7 +135,7 @@ class NIXAPI Tag : public base::EntityWithSources { * * @param t None */ - void units(const boost::none_t t) { + void units(const none_t t) { backend()->units(t); } @@ -189,7 +189,7 @@ class NIXAPI Tag : public base::EntityWithSources { * * @param t None */ - void extent(const boost::none_t t) { + void extent(const none_t t) { backend()->extent(t); } diff --git a/include/nix/base/IDataArray.hpp b/include/nix/base/IDataArray.hpp index 62c3cd8d3..9317b0faf 100644 --- a/include/nix/base/IDataArray.hpp +++ b/include/nix/base/IDataArray.hpp @@ -36,7 +36,7 @@ class NIXAPI IDataArray : virtual public base::IEntityWithSources { // Element getters and setters //-------------------------------------------------- - virtual boost::optional label() const = 0; + virtual std::optional label() const = 0; virtual void label(const std::string &label) = 0; @@ -45,7 +45,7 @@ class NIXAPI IDataArray : virtual public base::IEntityWithSources { virtual void label(const none_t t) = 0; - virtual boost::optional unit() const = 0; + virtual std::optional unit() const = 0; virtual void unit(const std::string &unit) = 0; @@ -54,7 +54,7 @@ class NIXAPI IDataArray : virtual public base::IEntityWithSources { virtual void unit(const none_t t) = 0; - virtual boost::optional expansionOrigin()const = 0; + virtual std::optional expansionOrigin()const = 0; virtual void expansionOrigin(double expansion_origin) = 0; diff --git a/include/nix/base/IDimensions.hpp b/include/nix/base/IDimensions.hpp index c70fb118a..f58e54760 100644 --- a/include/nix/base/IDimensions.hpp +++ b/include/nix/base/IDimensions.hpp @@ -17,8 +17,8 @@ #include #include #include +#include -#include #include #include @@ -46,7 +46,7 @@ namespace base { class NIXAPI IDimension { protected: - typedef boost::none_t none_t; + typedef std::nullopt_t none_t; public: @@ -70,7 +70,7 @@ class NIXAPI ISampledDimension : virtual public IDimension { public: - virtual boost::optional label() const = 0; + virtual std::optional label() const = 0; virtual void label(const std::string &label) = 0; @@ -79,7 +79,7 @@ class NIXAPI ISampledDimension : virtual public IDimension { virtual void label(const none_t t) = 0; - virtual boost::optional unit() const = 0; + virtual std::optional unit() const = 0; virtual void unit(const std::string &unit) = 0; @@ -94,7 +94,7 @@ class NIXAPI ISampledDimension : virtual public IDimension { virtual void samplingInterval(double interval) = 0; - virtual boost::optional offset() const = 0; + virtual std::optional offset() const = 0; virtual void offset(double offset) = 0; @@ -116,17 +116,17 @@ class NIXAPI IDataFrameDimension : virtual public IDimension { public: - virtual std::string label(boost::optional col_index) const = 0; + virtual std::string label(std::optional col_index) const = 0; - virtual std::string unit(boost::optional col_index) const = 0; + virtual std::string unit(std::optional col_index) const = 0; - virtual nix::DataType columnDataType(boost::optional col_index) const = 0; + virtual nix::DataType columnDataType(std::optional col_index) const = 0; - virtual nix::Column column(boost::optional col_index) const = 0; + virtual nix::Column column(std::optional col_index) const = 0; virtual std::shared_ptr dataFrame() const = 0; - virtual boost::optional columnIndex() const = 0; + virtual std::optional columnIndex() const = 0; }; @@ -139,7 +139,7 @@ class NIXAPI ISetDimension : virtual public IDimension { public: - virtual boost::optional label() const = 0; + virtual std::optional label() const = 0; virtual void label(const std::string &label) = 0; @@ -165,7 +165,7 @@ class NIXAPI IRangeDimension : virtual public IDimension { public: - virtual boost::optional label() const = 0; + virtual std::optional label() const = 0; virtual bool alias() const = 0; @@ -177,7 +177,7 @@ class NIXAPI IRangeDimension : virtual public IDimension { virtual void label(const none_t t) = 0; - virtual boost::optional unit() const = 0; + virtual std::optional unit() const = 0; virtual void unit(const std::string &unit) = 0; diff --git a/include/nix/base/INamedEntity.hpp b/include/nix/base/INamedEntity.hpp index f8dfa82bd..101e45b44 100644 --- a/include/nix/base/INamedEntity.hpp +++ b/include/nix/base/INamedEntity.hpp @@ -12,10 +12,9 @@ #include -#include - #include #include +#include namespace nix { namespace base { @@ -42,7 +41,7 @@ class NIXAPI INamedEntity : virtual public IEntity { virtual void definition(const std::string &definition) = 0; - virtual boost::optional definition() const = 0; + virtual std::optional definition() const = 0; virtual void definition(const none_t t) = 0; diff --git a/include/nix/base/IProperty.hpp b/include/nix/base/IProperty.hpp index a5318008f..81828af32 100644 --- a/include/nix/base/IProperty.hpp +++ b/include/nix/base/IProperty.hpp @@ -38,7 +38,7 @@ class NIXAPI IProperty : virtual public base::IEntity { virtual void definition(const std::string &definition) = 0; - virtual boost::optional definition() const = 0; + virtual std::optional definition() const = 0; virtual void definition(const none_t t) = 0; @@ -50,7 +50,7 @@ class NIXAPI IProperty : virtual public base::IEntity { virtual void unit(const std::string &unit) = 0; - virtual boost::optional unit() const = 0; + virtual std::optional unit() const = 0; virtual void unit(const none_t t) = 0; @@ -59,7 +59,7 @@ class NIXAPI IProperty : virtual public base::IEntity { virtual void uncertainty(double uncertainty) = 0; - virtual boost::optional uncertainty() const = 0; + virtual std::optional uncertainty() const = 0; virtual void uncertainty(const none_t t) = 0; @@ -77,7 +77,7 @@ class NIXAPI IProperty : virtual public base::IEntity { virtual std::vector values(void) const = 0; - virtual void values(const boost::none_t t) = 0; + virtual void values(const none_t t) = 0; virtual ~IProperty() {} diff --git a/include/nix/base/ISection.hpp b/include/nix/base/ISection.hpp index 26f67a146..74e7ea539 100644 --- a/include/nix/base/ISection.hpp +++ b/include/nix/base/ISection.hpp @@ -41,10 +41,10 @@ class NIXAPI ISection : virtual public base::INamedEntity { virtual void repository(const std::string &repository) = 0; - virtual boost::optional repository() const = 0; + virtual std::optional repository() const = 0; - virtual void repository(const boost::none_t t) = 0; + virtual void repository(const none_t t) = 0; virtual void link(const std::string &id) = 0; diff --git a/include/nix/base/NamedEntity.hpp b/include/nix/base/NamedEntity.hpp index d90f35f40..2546d0091 100644 --- a/include/nix/base/NamedEntity.hpp +++ b/include/nix/base/NamedEntity.hpp @@ -114,7 +114,7 @@ class NamedEntity : public Entity { * * @return The definition of the entity. */ - boost::optional definition() const { + std::optional definition() const { return Entity::backend()->definition(); } @@ -171,14 +171,14 @@ struct NIXAPI has_name { template typename std::enable_if::value, - boost::optional>::type + std::optional>::type getEntityName(const Entity &e) { - return boost::make_optional(e.name()); + return std::make_optional(e.name()); } template typename std::enable_if::value, - boost::optional>::type + std::optional>::type getEntityName(const Entity &e) { return nix::none; } @@ -194,7 +194,7 @@ getEntityName(const Entity &e) { * with or {@link nix::none}. */ template -boost::optional getEntityName(const Entity &e) { +std::optional getEntityName(const Entity &e) { return base::getEntityName(e); } diff --git a/include/nix/util/dataAccess.hpp b/include/nix/util/dataAccess.hpp index 935b6b22c..f2d930e0d 100644 --- a/include/nix/util/dataAccess.hpp +++ b/include/nix/util/dataAccess.hpp @@ -22,6 +22,7 @@ #include #include +#include namespace nix { namespace util { @@ -46,7 +47,7 @@ namespace util { * @throws nix::IncompatibleDimension The the dimensions are incompatible. * @throws nix::OutOfBounds If the position either too large or too small for the dimension. */ -NIXAPI boost::optional positionToIndex(double position, const PositionMatch match, const SetDimension &dimension); +NIXAPI std::optional positionToIndex(double position, const PositionMatch match, const SetDimension &dimension); NIXAPI DEPRECATED ndsize_t positionToIndex(double position, const std::string &unit, const SetDimension &dimension); @@ -70,7 +71,7 @@ NIXAPI DEPRECATED ndsize_t positionToIndex(double position, const std::string &u * @throws nix::IncompatibleDimension The the dimensions are incompatible. * @throws nix::OutOfBounds If the position either too large or too small for the dimension. */ -NIXAPI boost::optional positionToIndex(double position, const std::string &unit, const PositionMatch match, const DataFrameDimension &dimension); +NIXAPI std::optional positionToIndex(double position, const std::string &unit, const PositionMatch match, const DataFrameDimension &dimension); /** * @brief Converts a position to an index according to the dimension descriptor. @@ -91,7 +92,7 @@ NIXAPI boost::optional positionToIndex(double position, const std::str * @throws nix::IncompatibleDimension The the dimensions are incompatible. * @throws nix::OutOfBounds If the position either too large or too small for the dimension. */ -NIXAPI boost::optional positionToIndex(double position, const PositionMatch match, const DataFrameDimension &dimension); +NIXAPI std::optional positionToIndex(double position, const PositionMatch match, const DataFrameDimension &dimension); /** @@ -111,7 +112,7 @@ NIXAPI boost::optional positionToIndex(double position, const Position * @throws nix::IncompatibleDimension The the dimensions are incompatible. * @throws nix::OutOfBounds If the position either too large or too small for the dimension. */ -NIXAPI boost::optional positionToIndex(double position, const std::string &unit, const PositionMatch match, const SampledDimension &dimension); +NIXAPI std::optional positionToIndex(double position, const std::string &unit, const PositionMatch match, const SampledDimension &dimension); NIXAPI DEPRECATED ndsize_t positionToIndex(double position, const std::string &unit, const SampledDimension &dimension); @@ -131,7 +132,7 @@ NIXAPI DEPRECATED ndsize_t positionToIndex(double position, const std::string & * @throws nix::IncompatibleDimension The the dimensions are incompatible. * @throws nix::OutOfBounds If the position either too large or too small for the dimension. */ -NIXAPI boost::optional positionToIndex(double position, const std::string &unit, const PositionMatch position_match, const RangeDimension &dimension); +NIXAPI std::optional positionToIndex(double position, const std::string &unit, const PositionMatch position_match, const RangeDimension &dimension); NIXAPI DEPRECATED ndsize_t positionToIndex(double position, const std::string &unit, const RangeDimension &dimension); @@ -155,11 +156,11 @@ NIXAPI DEPRECATED ndsize_t positionToIndex(double position, const std::string &u * @throws nix::IncompatibleDimension The the dimensions are incompatible. * @throws nix::OutOfBounds If the position either too large or too small for the dimension. */ -NIXAPI std::vector>> positionToIndex(const std::vector &start_positions, - const std::vector &end_positions, - const std::vector &units, - const RangeMatch rangeMatching, - const SampledDimension &dimension); +NIXAPI std::vector>> positionToIndex(const std::vector &start_positions, + const std::vector &end_positions, + const std::vector &units, + const RangeMatch rangeMatching, + const SampledDimension &dimension); /** * @deprecated this function has been deprecated see {@link nix::util::positionToIndex(const std::vector&, const std::vector&, const std::vector &, const RangeMatch, const SampledDimension&)} @@ -170,10 +171,10 @@ NIXAPI DEPRECATED std::vector> positionToIndex(con const SampledDimension &dimension); -NIXAPI std::vector>> positionToIndex(const std::vector &start_positions, - const std::vector &end_positions, - const RangeMatch rangeMatching, - const SetDimension &dimension); +NIXAPI std::vector>> positionToIndex(const std::vector &start_positions, + const std::vector &end_positions, + const RangeMatch rangeMatching, + const SetDimension &dimension); /** * @deprecated this function has been deprecated see {@link nix::util::positionToIndex(const std::vector&, const std::vector&, const std::vector &, const RangeMatch, const SetDimension&)} @@ -184,11 +185,11 @@ NIXAPI DEPRECATED std::vector> positionToIndex(con const SetDimension &dimension); -NIXAPI std::vector>> positionToIndex(const std::vector &start_positions, - const std::vector &end_positions, - const std::vector &units, - const RangeMatch rangeMatching, - const RangeDimension &dimension); +NIXAPI std::vector>> positionToIndex(const std::vector &start_positions, + const std::vector &end_positions, + const std::vector &units, + const RangeMatch rangeMatching, + const RangeDimension &dimension); /** * @deprecated this function has been deprecated see {@link nix::util::positionToIndex(const std::vector&, const std::vector&, const std::vector &, const RangeMatch, const RangeDimension&)} @@ -199,10 +200,10 @@ NIXAPI DEPRECATED std::vector> positionToIndex(con const RangeDimension &dimension); -NIXAPI std::vector>> positionToIndex(const std::vector &start_positions, - const std::vector &end_positions, - const RangeMatch range_matching, - const DataFrameDimension &dimension); +NIXAPI std::vector>> positionToIndex(const std::vector &start_positions, + const std::vector &end_positions, + const RangeMatch range_matching, + const DataFrameDimension &dimension); /** diff --git a/include/nix/valid/checks.hpp b/include/nix/valid/checks.hpp index 527491230..eb0b6c39c 100644 --- a/include/nix/valid/checks.hpp +++ b/include/nix/valid/checks.hpp @@ -16,9 +16,9 @@ #include -#include #include +#include namespace nix { namespace valid { @@ -133,7 +133,7 @@ namespace valid { return value == val; } }; - // needed because: for bizarre reasons bool converts to int when compared to boost::optional + // needed because: for bizarre reasons bool converts to int when compared to std::optional template<> struct isEqual { const bool value; @@ -151,7 +151,7 @@ namespace valid { * * One Check struct that checks whether the given value casts to true * or to false. - * T can be: boost::optional, boost::none, nix-entity + * T can be: std::optional, std::nullopt, nix-entity * and any basic type. */ struct notFalse { @@ -167,7 +167,7 @@ namespace valid { * * One Check struct that checks whether the given value casts to false * or to true. - * T can be: boost::optional, boost::none, nix-entity + * T can be: std::optional, std::nullopt, nix-entity * and any basic type. */ struct isFalse { @@ -217,7 +217,7 @@ namespace valid { virtual bool operator()(const std::string &u) const = 0; - bool operator()(const boost::optional &u) const { + bool operator()(const std::optional &u) const { // note: relying on short-curcuiting here return u && (*this)(*u); } @@ -235,14 +235,14 @@ namespace valid { * * One Check struct that checks whether the given string(s) represent(s) * a valid atomic or compound SI unit. - * Parameter can be of type boost optional (containing nothing or + * Parameter can be of type std optional (containing nothing or * string) or of type string or a vector of strings. */ struct isValidUnit : public isUnit { bool operator()(const std::string &u) const { return (util::isSIUnit(u) || util::isCompoundSIUnit(u)); } - bool operator()(const boost::optional &u) const { + bool operator()(const std::optional &u) const { return isUnit::operator()(u); } bool operator()(const std::vector &u) const { @@ -255,14 +255,14 @@ namespace valid { * * One Check struct that checks whether the given string(s) represent(s) * a valid atomic SI unit. - * Parameter can be of type boost optional (containing nothing or + * Parameter can be of type std optional (containing nothing or * string) or of type string or a vector of strings. */ struct isAtomicUnit : public isUnit { bool operator()(const std::string &u) const { return util::isSIUnit(u); } - bool operator()(const boost::optional &u) const { + bool operator()(const std::optional &u) const { return isUnit::operator()(u); } bool operator()(const std::vector &u) const { @@ -275,14 +275,14 @@ namespace valid { * * One Check struct that checks whether the given string(s) represent(s) * a valid compound SI unit. - * Parameter can be of type boost optional (containing nothing or + * Parameter can be of type std optional (containing nothing or * string) or of type string or a vector of strings. */ struct isCompoundUnit : public isUnit { bool operator()(const std::string &u) const { return util::isCompoundSIUnit(u); } - bool operator()(const boost::optional &u) const { + bool operator()(const std::optional &u) const { return isUnit::operator()(u); } bool operator()(const std::vector &u) const { @@ -296,8 +296,8 @@ namespace valid { * One Check struct that checks whether the given value can be * considered set, by applying {@link notFalse} and {@link notEmpty} * checks. Value thus is set if: STL cotnainer not empty OR - * bool is true OR boost optional is set OR number is not 0. - * Parameter can be of above types or even boost none_t. + * bool is true OR std optional is set OR number is not 0. + * Parameter can be of above types or even nix none_t. * NOTE: use this if you don't know wheter a type has and "empty" * method. */ diff --git a/include/nix/valid/conditions.hpp b/include/nix/valid/conditions.hpp index 42d86c44d..2e9d6e03e 100644 --- a/include/nix/valid/conditions.hpp +++ b/include/nix/valid/conditions.hpp @@ -19,6 +19,7 @@ #include #include +#include namespace nix { namespace valid { @@ -55,7 +56,7 @@ namespace valid { std::string id = nix::util::numToStr( ID::value>().get(parent) ); - boost::optional name = nix::getEntityName(parent); + std::optional name = nix::getEntityName(parent); // execute getter call & check for error try { @@ -110,7 +111,7 @@ namespace valid { std::string id = nix::util::numToStr( ID::value>().get(parent) ); - boost::optional name = nix::getEntityName(parent); + std::optional name = nix::getEntityName(parent); // execute getter call & check for error try { diff --git a/include/nix/valid/helper.hpp b/include/nix/valid/helper.hpp index ea6f0407b..36fd24fb8 100644 --- a/include/nix/valid/helper.hpp +++ b/include/nix/valid/helper.hpp @@ -15,10 +15,9 @@ #include -#include - #include #include +#include namespace nix { namespace valid { @@ -32,7 +31,7 @@ namespace valid { struct NIXAPI Message { std::string id; std::string msg; - boost::optional name; + std::optional name; Message() { } @@ -41,7 +40,7 @@ namespace valid { { } - Message(std::string id, std::string msg, boost::optional name) + Message(std::string id, std::string msg, std::optional name) : id(std::move(id)), msg(std::move(msg)), name(std::move(name)) {} }; @@ -144,7 +143,7 @@ namespace valid { * * Helper function that gets all the units from all the dimensions * of the given DataArray and returns them as vector of strings. - * For all units not set (since boost::optional) it inserts an empty + * For all units not set (since std::optional) it inserts an empty * string andfor all dims that have no unit (since SetDimension) it * inserts the string "SetDimension". Thus the number of returned * units matches the number of dimensions and indices. diff --git a/src/DataArray.cpp b/src/DataArray.cpp index 95b239894..86921d1d9 100644 --- a/src/DataArray.cpp +++ b/src/DataArray.cpp @@ -26,7 +26,7 @@ static void convertData(DataType source, DataType destination, void *data, size_ void DataArray::ioRead(DataType dtype, void *data, const NDSize &count, const NDSize &offset) const { const std::vector poly = polynomCoefficients(); - boost::optional opt_origin = expansionOrigin(); + std::optional opt_origin = expansionOrigin(); if (poly.size() || opt_origin) { size_t data_esize = data_type_to_size(dtype); diff --git a/src/Dimensions.cpp b/src/Dimensions.cpp index f86220084..7ecfa359b 100644 --- a/src/Dimensions.cpp +++ b/src/Dimensions.cpp @@ -69,6 +69,7 @@ Dimension::Dimension(const DataFrameDimension &other) { } + SetDimension Dimension::asSetDimension() const { if (dimensionType() != DimensionType::Set) { throw IncompatibleDimensions("Dimension is not of type Set and thus cannot be cast to this type", "asSetDimension"); @@ -165,7 +166,6 @@ SampledDimension::SampledDimension(std::shared_ptr &&ptr) } - SampledDimension::SampledDimension(const SampledDimension &other) : ImplContainer(other) { @@ -196,8 +196,8 @@ void SampledDimension::samplingInterval(double interval) { } -boost::optional getSampledIndex(const double position, const double offset, const double sampling_interval, const PositionMatch match) { - boost::optional index; +std::optional getSampledIndex(const double position, const double offset, const double sampling_interval, const PositionMatch match) { + std::optional index; if (position < offset && (match != PositionMatch::Greater && match != PositionMatch::GreaterOrEqual)) { return index; } @@ -230,46 +230,48 @@ boost::optional getSampledIndex(const double position, const double of ndsize_t SampledDimension::indexOf(const double position) const { - boost::optional index = indexOf(position, PositionMatch::GreaterOrEqual); + std::optional index = indexOf(position, PositionMatch::GreaterOrEqual); if (!index) { throw nix::OutOfBounds("SampledDimension::indexOf: An invalid position was encountered! position < offset?"); } return *index; } -boost::optional SampledDimension::indexOf(const double position, const PositionMatch match) const { + +std::optional SampledDimension::indexOf(const double position, const PositionMatch match) const { double offset = backend()->offset() ? *(backend()->offset()) : 0.0; double sampling_interval = backend()->samplingInterval(); - boost::optional index = getSampledIndex(position, offset, sampling_interval, match); + std::optional index = getSampledIndex(position, offset, sampling_interval, match); return index; } std::pair SampledDimension::indexOf(const double start, const double end) const { - boost::optional> pair = indexOf(start, end, RangeMatch::Inclusive); + std::optional> pair = indexOf(start, end, RangeMatch::Inclusive); if (!pair) { throw nix::OutOfBounds("SampledDimension::indexOf: An invalid range was encountered!"); } return *pair; } -boost::optional> SampledDimension::indexOf(const double start, const double end, const RangeMatch range_matching) const { + +std::optional> SampledDimension::indexOf(const double start, const double end, const RangeMatch range_matching) const { double offset = backend()->offset() ? *(backend()->offset()) : 0.0; double sampling_interval = backend()->samplingInterval(); return indexOf(start, end, sampling_interval, offset, range_matching); } -boost::optional> SampledDimension::indexOf(double start, double end, const double sampling_interval, - const double offset, const RangeMatch match) const { - boost::optional> indices; +std::optional> SampledDimension::indexOf(double start, double end, const double sampling_interval, + const double offset, const RangeMatch match) const { + std::optional> indices; PositionMatch pos_match = match == RangeMatch::Inclusive ? PositionMatch::LessOrEqual : PositionMatch::Less; if (start > end) { return indices; } - boost::optional si = getSampledIndex(start, offset, sampling_interval, PositionMatch::GreaterOrEqual); - boost::optional ei = getSampledIndex(end, offset, sampling_interval, pos_match); + std::optional si = getSampledIndex(start, offset, sampling_interval, PositionMatch::GreaterOrEqual); + std::optional ei = getSampledIndex(end, offset, sampling_interval, pos_match); if (si && ei && *si <= *ei) { indices = std::pair(*si, *ei); @@ -278,14 +280,14 @@ boost::optional> SampledDimension::indexOf(double } -std::vector>> SampledDimension::indexOf(const std::vector &start_positions, - const std::vector &end_positions, - const RangeMatch range_matching) const { +std::vector>> SampledDimension::indexOf(const std::vector &start_positions, + const std::vector &end_positions, + const RangeMatch range_matching) const { if (start_positions.size() != end_positions.size()) { throw runtime_error("Dimension::IndexOf - Number of start and end positions must match!"); } - std::vector>> indices; + std::vector>> indices; double offset = backend()->offset() ? *(backend()->offset()) : 0.0; double sampling_interval = backend()->samplingInterval(); for (size_t i = 0; i < start_positions.size(); ++i) { @@ -294,6 +296,7 @@ std::vector>> SampledDimension::in return indices; } + std::vector> SampledDimension::indexOf(const std::vector &start_positions, const std::vector &end_positions) const { if (start_positions.size() != end_positions.size()) { @@ -303,7 +306,7 @@ std::vector> SampledDimension::indexOf(const std:: std::vector> indices; double offset = backend()->offset() ? *(backend()->offset()) : 0.0; double sampling_interval = backend()->samplingInterval(); - boost::optional> pair; + std::optional> pair; for (size_t i = 0; i < start_positions.size(); ++i) { pair = indexOf(start_positions[i], end_positions[i], sampling_interval, offset, RangeMatch::Inclusive); if (!pair) { @@ -374,6 +377,7 @@ SetDimension::SetDimension(const std::shared_ptr &p_impl) { } + SetDimension::SetDimension(std::shared_ptr &&ptr) : ImplContainer(std::move(ptr)) { @@ -392,8 +396,8 @@ void SetDimension::label(const std::string &label) { } -boost::optional getSetIndex(const double position, std::vector labels, const PositionMatch match) { - boost::optional index; +std::optional getSetIndex(const double position, std::vector labels, const PositionMatch match) { + std::optional index; if (position < 0 && (match != PositionMatch::Greater && match != PositionMatch::GreaterOrEqual)) { return index; } @@ -430,7 +434,7 @@ boost::optional getSetIndex(const double position, std::vector getSetIndex(const double position, std::vector SetDimension::indexOf(const double position, const PositionMatch match) const { +std::optional SetDimension::indexOf(const double position, const PositionMatch match) const { std::vector lbls = labels(); return getSetIndex(position, lbls, match); } -boost::optional> SetDimension::indexOf(double start, double end, std::vector &set_labels, const RangeMatch match) const { +std::optional> SetDimension::indexOf(double start, double end, std::vector &set_labels, const RangeMatch match) const { if (set_labels.size() == 0) { set_labels = labels(); } - boost::optional> index; + std::optional> index; if (start > end) { return index; } PositionMatch end_match = match == RangeMatch::Inclusive ? PositionMatch::LessOrEqual : PositionMatch::Less; - boost::optional si = getSetIndex(start, set_labels, PositionMatch::GreaterOrEqual); - boost::optional ei = getSetIndex(end, set_labels, end_match); + std::optional si = getSetIndex(start, set_labels, PositionMatch::GreaterOrEqual); + std::optional ei = getSetIndex(end, set_labels, end_match); if (si && ei && *si <= *ei) { index = std::pair(*si, *ei); } @@ -464,20 +468,20 @@ boost::optional> SetDimension::indexOf(double star } -boost::optional> SetDimension::indexOf(const double start, const double end, const RangeMatch match) const { +std::optional> SetDimension::indexOf(const double start, const double end, const RangeMatch match) const { std::vector set_labels = labels(); return indexOf(start, end, set_labels, match); } -std::vector>> SetDimension::indexOf(const std::vector &start_positions, - const std::vector &end_positions, - const RangeMatch match) const { +std::vector>> SetDimension::indexOf(const std::vector &start_positions, + const std::vector &end_positions, + const RangeMatch match) const { if (start_positions.size() != end_positions.size()) { throw runtime_error("Dimension::IndexOf - Number of start and end positions must match!"); } - std::vector>> indices; + std::vector>> indices; std::vector set_labels = labels(); for (size_t i = 0; i < start_positions.size(); ++i) { indices.push_back(indexOf(start_positions[i], end_positions[i], set_labels, match)); @@ -554,6 +558,7 @@ void RangeDimension::label(const std::string &label) { backend()->label(label); } + void RangeDimension::unit(const std::string &unit) { util::checkEmptyString(unit, "unit"); if (!(util::isSIUnit(unit))) { @@ -594,8 +599,8 @@ PositionInRange RangeDimension::positionInRange(const double position) const { } -boost::optional getIndex(const double position, std::vector &ticks, PositionMatch matching) { - boost::optional idx; +std::optional getIndex(const double position, std::vector &ticks, PositionMatch matching) { + std::optional idx; // check easy cases first ... if (ticks.size() == 0) return idx; @@ -616,20 +621,20 @@ boost::optional getIndex(const double position, std::vector &t if ((lower + 1) < ticks.end()) { idx = lower + 1 - ticks.begin(); } else { - idx = boost::none; + idx = std::nullopt; } } } else if (matching == PositionMatch::LessOrEqual && *lower > position) { if (lower - 1 >= ticks.begin()) { idx = lower - 1 - ticks.begin(); } else { - idx = boost::none; + idx = std::nullopt; } } else if (matching == PositionMatch::Less && *lower >= position) { if ((lower - 1) >= ticks.begin()) { idx = lower - 1 - ticks.begin(); } else { - idx = boost::none; + idx = std::nullopt; } } else { // exact match if (lower != ticks.end() && *lower == position) { @@ -640,30 +645,30 @@ boost::optional getIndex(const double position, std::vector &t } -boost::optional RangeDimension::indexOf(const double position, PositionMatch matching) const { +std::optional RangeDimension::indexOf(const double position, PositionMatch matching) const { vector ticks = this->ticks(); - boost::optional index = getIndex(position, ticks, matching); + std::optional index = getIndex(position, ticks, matching); return index; } -boost::optional> RangeDimension::indexOf(double start, double end, - std::vector ticks, - RangeMatch match) const { +std::optional> RangeDimension::indexOf(double start, double end, + std::vector ticks, + RangeMatch match) const { if (ticks.size() == 0) { ticks = this->ticks(); } - boost::optional> range; + std::optional> range; if (start > end){ return range; } - boost::optional si = getIndex(start, ticks, PositionMatch::GreaterOrEqual); + std::optional si = getIndex(start, ticks, PositionMatch::GreaterOrEqual); if (!si) { return range; } PositionMatch endMatching = (match == RangeMatch::Inclusive) ? PositionMatch::LessOrEqual : PositionMatch::Less; - boost::optional ei = getIndex(end, ticks, endMatching); + std::optional ei = getIndex(end, ticks, endMatching); if (ei && *si <= *ei) { range = std::pair(*si, *ei); } @@ -674,7 +679,7 @@ boost::optional> RangeDimension::indexOf(double st ndsize_t RangeDimension::indexOf(const double position, bool less_or_equal) const { vector ticks = this->ticks(); PositionMatch matching = less_or_equal ? PositionMatch::LessOrEqual : PositionMatch::GreaterOrEqual; - boost::optional index = getIndex(position, ticks, matching); + std::optional index = getIndex(position, ticks, matching); if (index) return *index; else @@ -684,8 +689,8 @@ ndsize_t RangeDimension::indexOf(const double position, bool less_or_equal) cons pair RangeDimension::indexOf(const double start, const double end) const { vector ticks = this->ticks(); - boost::optional si = getIndex(start, ticks, PositionMatch::GreaterOrEqual); - boost::optional ei = getIndex(end, ticks, PositionMatch::LessOrEqual); + std::optional si = getIndex(start, ticks, PositionMatch::GreaterOrEqual); + std::optional ei = getIndex(end, ticks, PositionMatch::LessOrEqual); if (!ei || !si) { throw nix::OutOfBounds("RangeDimension::indexOf: start or end of range are out of Bounds!"); } @@ -696,7 +701,7 @@ pair RangeDimension::indexOf(const double start, const doubl std::vector> RangeDimension::indexOf(const std::vector &start_positions, const std::vector &end_positions, bool strict, RangeMatch match) const { - std::vector>> optionalIndices; + std::vector>> optionalIndices; optionalIndices = indexOf(start_positions, end_positions, match); std::vector> indices; for(auto o: optionalIndices) { @@ -710,17 +715,17 @@ std::vector> RangeDimension::indexOf(const std::ve } -std::vector>> RangeDimension::indexOf(const std::vector &start_positions, - const std::vector &end_positions, - RangeMatch match) const { +std::vector>> RangeDimension::indexOf(const std::vector &start_positions, + const std::vector &end_positions, + RangeMatch match) const { if (start_positions.size() != end_positions.size()) { throw runtime_error("Dimension::IndexOf - Number of start and end positions must match!"); } - std::vector>> indices; + std::vector>> indices; vector ticks = this->ticks(); for (size_t i = 0; i < start_positions.size(); ++i) { - boost::optional> range; + std::optional> range; range = this->indexOf(start_positions[i], end_positions[i], ticks, match); indices.push_back(range); } @@ -789,8 +794,8 @@ DataFrameDimension::DataFrameDimension(const DataFrameDimension &other) } -boost::optional getDataFrameIndex(const double position, const ndsize_t tick_count, const PositionMatch match) { - boost::optional index; +std::optional getDataFrameIndex(const double position, const ndsize_t tick_count, const PositionMatch match) { + std::optional index; if (position < 0 && (match != PositionMatch::Greater && match != PositionMatch::GreaterOrEqual)) { return index; } @@ -825,7 +830,7 @@ boost::optional getDataFrameIndex(const double position, const ndsize_ if (match == PositionMatch::Less || match == PositionMatch::LessOrEqual) { index = tick_count - 1; } else { - index = boost::none; + index = std::nullopt; } } @@ -833,21 +838,21 @@ boost::optional getDataFrameIndex(const double position, const ndsize_ } -boost::optional DataFrameDimension::indexOf(const double position, const PositionMatch pos_match) const { +std::optional DataFrameDimension::indexOf(const double position, const PositionMatch pos_match) const { ndsize_t tick_count = this->size(); return getDataFrameIndex(position, tick_count, pos_match); } -boost::optional> DataFrameDimension::indexOf(double start, double end, ndsize_t tick_count, const RangeMatch match) const { - boost::optional> index; +std::optional> DataFrameDimension::indexOf(double start, double end, ndsize_t tick_count, const RangeMatch match) const { + std::optional> index; if (start > end) { return index; } PositionMatch end_match = (match == RangeMatch::Inclusive ? PositionMatch::LessOrEqual : PositionMatch::Less); - boost::optional si = getDataFrameIndex(start, tick_count, PositionMatch::GreaterOrEqual); - boost::optional ei = getDataFrameIndex(end, tick_count, end_match); + std::optional si = getDataFrameIndex(start, tick_count, PositionMatch::GreaterOrEqual); + std::optional ei = getDataFrameIndex(end, tick_count, end_match); if (si && ei && *si <= *ei) { index = std::pair(*si, *ei); @@ -857,21 +862,21 @@ boost::optional> DataFrameDimension::indexOf(doubl } -boost::optional> DataFrameDimension::indexOf(double start, double end, const RangeMatch match) const { +std::optional> DataFrameDimension::indexOf(double start, double end, const RangeMatch match) const { ndsize_t tick_count = this->size(); return indexOf(start, end, tick_count, match); } -std::vector>> DataFrameDimension::indexOf(const std::vector &start_positions, - const std::vector &end_positions, - const RangeMatch match) const { +std::vector>> DataFrameDimension::indexOf(const std::vector &start_positions, + const std::vector &end_positions, + const RangeMatch match) const { if (start_positions.size() != end_positions.size()) { throw runtime_error("DataFrameDimension::IndexOf - Number of start and end positions must match!"); } ndsize_t tick_count = this->size(); - std::vector>> indices; + std::vector>> indices; for (size_t i = 0; i < start_positions.size(); ++i) { indices.push_back(indexOf(start_positions[i], end_positions[i], tick_count, match)); } diff --git a/src/File.cpp b/src/File.cpp index 235b92d02..e8d6b27f5 100644 --- a/src/File.cpp +++ b/src/File.cpp @@ -15,9 +15,9 @@ #endif #include -#include +#include -namespace bfs = boost::filesystem; +namespace fs = std::filesystem; namespace nix { @@ -26,7 +26,7 @@ File File::open(const std::string &name, const std::string &impl, Compression compression, OpenFlags flags) { - if (mode == nix::FileMode::ReadOnly && !bfs::exists(bfs::path{name})) { + if (mode == nix::FileMode::ReadOnly && !fs::exists(fs::path{name})) { throw std::runtime_error("Cannot open non-existent file in ReadOnly mode!"); } if (compression == Compression::Auto) { diff --git a/src/util/dataAccess.cpp b/src/util/dataAccess.cpp index f5c71a758..5cf923b03 100644 --- a/src/util/dataAccess.cpp +++ b/src/util/dataAccess.cpp @@ -17,8 +17,6 @@ #include #include -#include - using namespace std; using namespace boost; @@ -50,12 +48,12 @@ void scalePositions(const vector &starts, const vector &ends, } -vector>> positionToIndex(const vector &start_positions, - const vector &end_positions, - const vector &units, - const RangeMatch range_matching, - const Dimension &dimension) { - vector>> indices; +vector>> positionToIndex(const vector &start_positions, + const vector &end_positions, + const vector &units, + const RangeMatch range_matching, + const Dimension &dimension) { + vector>> indices; if (dimension.dimensionType() == DimensionType::Sample) { SampledDimension dim; dim = dimension; @@ -81,7 +79,7 @@ vector> positionToIndex(const vector &start_pos const vector &end_positions, const vector &units, const SampledDimension &dimension) { - vector>> opt_ranges = positionToIndex(start_positions, end_positions, units, RangeMatch::Inclusive, dimension); + vector>> opt_ranges = positionToIndex(start_positions, end_positions, units, RangeMatch::Inclusive, dimension); vector> ranges; for (auto o : opt_ranges) { if (o) { @@ -93,11 +91,11 @@ vector> positionToIndex(const vector &start_pos return ranges; } -vector>> positionToIndex(const vector &start_positions, - const vector &end_positions, - const vector &units, - const RangeMatch range_matching, - const SampledDimension &dimension) { +vector>> positionToIndex(const vector &start_positions, + const vector &end_positions, + const vector &units, + const RangeMatch range_matching, + const SampledDimension &dimension) { if (start_positions.size() != end_positions.size() || start_positions.size() != units.size() ) { throw std::runtime_error("util::positionToIndex: Invalid numbers of start and end positions, or units!"); } @@ -110,14 +108,14 @@ vector>> positionToIndex(const vector } -vector>> positionToIndex(const vector &start_positions, - const vector &end_positions, - const RangeMatch range_matching, - const SetDimension &dimension) { +vector>> positionToIndex(const vector &start_positions, + const vector &end_positions, + const RangeMatch range_matching, + const SetDimension &dimension) { if (start_positions.size() != end_positions.size()) { throw std::runtime_error("util::positionToIndex: Invalid numbers of start and end positions!"); } - vector>> indices = dimension.indexOf(start_positions, end_positions, range_matching); + vector>> indices = dimension.indexOf(start_positions, end_positions, range_matching); return indices; } @@ -126,7 +124,7 @@ vector> positionToIndex(const vector &start_pos const vector &units, const SetDimension &dimension) { vector> indices; - vector>> opt_indices = positionToIndex(start_positions, end_positions, RangeMatch::Inclusive, dimension); + vector>> opt_indices = positionToIndex(start_positions, end_positions, RangeMatch::Inclusive, dimension); for (auto o : opt_indices) { if (!o) { throw nix::OutOfBounds("util::positionToIndex: An invalid range was encountered!"); @@ -137,11 +135,11 @@ vector> positionToIndex(const vector &start_pos } -vector>> positionToIndex(const vector &start_positions, - const vector &end_positions, - const vector &units, - const RangeMatch range_matching, - const RangeDimension &dimension) { +vector>> positionToIndex(const vector &start_positions, + const vector &end_positions, + const vector &units, + const RangeMatch range_matching, + const RangeDimension &dimension) { if (start_positions.size() != end_positions.size() || start_positions.size() != units.size() ) { throw std::runtime_error("util::positionToIndex: Invalid numbers of start and end positions, or units!"); } @@ -158,7 +156,7 @@ vector> positionToIndex(const vector &start_pos const vector &end_positions, const vector &units, const RangeDimension &dimension) { - vector>> opt_ranges = positionToIndex(start_positions, end_positions, units, RangeMatch::Inclusive, dimension); + vector>> opt_ranges = positionToIndex(start_positions, end_positions, units, RangeMatch::Inclusive, dimension); vector> ranges; for (auto o : opt_ranges) { if (o) { @@ -170,20 +168,20 @@ vector> positionToIndex(const vector &start_pos return ranges; } -vector>> positionToIndex(const vector &start_positions, - const vector &end_positions, - const RangeMatch range_matching, - const DataFrameDimension &dimension) { +vector>> positionToIndex(const vector &start_positions, + const vector &end_positions, + const RangeMatch range_matching, + const DataFrameDimension &dimension) { if (start_positions.size() != end_positions.size()) { throw std::runtime_error("util::positionToIndex: Invalid numbers of start and end positions!"); } - vector>> indices = dimension.indexOf(start_positions, end_positions, range_matching); + vector>> indices = dimension.indexOf(start_positions, end_positions, range_matching); return indices; } -optional positionToIndex(double position, const string &unit, const PositionMatch match, const Dimension &dimension) { - optional pos; +std::optional positionToIndex(double position, const string &unit, const PositionMatch match, const Dimension &dimension) { + std::optional pos; if (dimension.dimensionType() == DimensionType::Sample) { SampledDimension dim; dim = dimension; @@ -207,16 +205,16 @@ optional positionToIndex(double position, const string &unit, const Po ndsize_t positionToIndex(double position, const string &unit, const SampledDimension &dimension) { - optional index = positionToIndex(position, unit, PositionMatch::GreaterOrEqual, dimension); + std::optional index = positionToIndex(position, unit, PositionMatch::GreaterOrEqual, dimension); if (!index) { throw nix::OutOfBounds("util::positionToIndex: An invalid position was encoutered!"); } return *index; } -optional positionToIndex(double position, const string &unit, const PositionMatch match, const SampledDimension &dimension) { - optional index; - boost::optional dim_unit = dimension.unit(); +std::optional positionToIndex(double position, const string &unit, const PositionMatch match, const SampledDimension &dimension) { + std::optional index; + std::optional dim_unit = dimension.unit(); double scaling = 1.0; if (!dim_unit && unit != "none") { throw IncompatibleDimensions("Position is given with a unit, the dimension has none!", @@ -236,34 +234,34 @@ optional positionToIndex(double position, const string &unit, const Po ndsize_t positionToIndex(double position, const string &unit, const SetDimension &dimension) { - optional index = positionToIndex(position, PositionMatch::GreaterOrEqual, dimension); + std::optional index = positionToIndex(position, PositionMatch::GreaterOrEqual, dimension); if (!index) { throw nix::OutOfBounds("util::positionToIndex: An invalid position was encoutered!"); } return *index; } -optional positionToIndex(double position, const PositionMatch match, const SetDimension &dimension) { - optional index = dimension.indexOf(position, match); +std::optional positionToIndex(double position, const PositionMatch match, const SetDimension &dimension) { + std::optional index = dimension.indexOf(position, match); return index; } -optional positionToIndex(double position, const PositionMatch position_match, const DataFrameDimension &dimension) { - optional index = dimension.indexOf(position, position_match); +std::optional positionToIndex(double position, const PositionMatch position_match, const DataFrameDimension &dimension) { + std::optional index = dimension.indexOf(position, position_match); return index; } ndsize_t positionToIndex(double position, const string &unit, const RangeDimension &dimension) { - boost::optional index = positionToIndex(position, unit, PositionMatch::GreaterOrEqual, dimension); + std::optional index = positionToIndex(position, unit, PositionMatch::GreaterOrEqual, dimension); if (!index) { throw nix::OutOfBounds("PositionToIndex: An invalid index was encountered"); } return *index; } -boost::optional positionToIndex(double position, const string &unit, const PositionMatch position_match, const RangeDimension &dimension) { +std::optional positionToIndex(double position, const string &unit, const PositionMatch position_match, const RangeDimension &dimension) { string dim_unit = dimension.unit() ? *dimension.unit() : "none"; double scaling = 1.0; if (unit != "none") { @@ -274,7 +272,7 @@ boost::optional positionToIndex(double position, const string &unit, c "nix::util::positionToIndex"); } } - boost::optional index = dimension.indexOf(position * scaling, position_match); + std::optional index = dimension.indexOf(position * scaling, position_match); return index; } @@ -387,13 +385,13 @@ void getOffsetAndCount(const Tag &tag, const DataArray &array, NDSize &offset, N NDSize temp_offset(position.size()); NDSize temp_count(position.size(), 1); for (size_t i = 0; i < position.size(); ++i) { - vector>> ranges = positionToIndex({position[i]}, - {position[i] + extent[i]}, - {units[i]}, - match, - dimensions[i]); + vector>> ranges = positionToIndex({position[i]}, + {position[i] + extent[i]}, + {units[i]}, + match, + dimensions[i]); if (!ranges[0]) { - optional ofst = positionToIndex(position[i], units[i], PositionMatch::GreaterOrEqual, dimensions[i]); + std::optional ofst = positionToIndex(position[i], units[i], PositionMatch::GreaterOrEqual, dimensions[i]); if (extent[i] != 0. || !ofst) { throw nix::OutOfBounds("util::offsetAndCount:An invalid range was encountered!"); } @@ -477,10 +475,10 @@ void getOffsetAndCount(const MultiTag &tag, const DataArray &array, const vector } } - vector>>> data_indices; + vector>>> data_indices; for (size_t dim_index = 0; dim_index < dimensions.size(); ++dim_index) { vector temp_units(start_positions[dim_index].size(), units[dim_index]); - vector>> ranges = positionToIndex(start_positions[dim_index], end_positions[dim_index], + vector>> ranges = positionToIndex(start_positions[dim_index], end_positions[dim_index], temp_units, match, dimensions[dim_index]); data_indices.push_back(ranges); @@ -491,14 +489,14 @@ void getOffsetAndCount(const MultiTag &tag, const DataArray &array, const vector NDSize data_offset(dimcount_sizet, 0); NDSize data_count(dimcount_sizet, 1); for (size_t dim_index =0; dim_index < dimensions.size(); ++dim_index) { // for each dimension - optional> opt_range = data_indices[dim_index][i]; + std::optional> opt_range = data_indices[dim_index][i]; if (opt_range) { data_offset[dim_index] = (*opt_range).first; ndsize_t count = (*opt_range).second - (*opt_range).first; data_count[dim_index] += count; } else { if (end_positions[dim_index][i] == start_positions[dim_index][i]) { - optional ofst = positionToIndex(end_positions[dim_index][i], units[dim_index], PositionMatch::GreaterOrEqual, dimensions[dim_index]); + std::optional ofst = positionToIndex(end_positions[dim_index][i], units[dim_index], PositionMatch::GreaterOrEqual, dimensions[dim_index]); if (!ofst) { throw nix::OutOfBounds("util::offsetAndCount:An invalid range was encountered!"); } @@ -605,9 +603,9 @@ DataView dataSlice(const DataArray &array, const std::vector &start, con if (my_start[i] > my_end[i]) { throw std::invalid_argument("Start position must not be larger than end position."); } - std::vector>> indices = positionToIndex({start[i]}, {end[i]}, {my_units[i]}, match, dim); + std::vector>> indices = positionToIndex({start[i]}, {end[i]}, {my_units[i]}, match, dim); if (!indices[0]) { - optional ofst = positionToIndex(my_start[i], my_units[i], PositionMatch::GreaterOrEqual, dim); + std::optional ofst = positionToIndex(my_start[i], my_units[i], PositionMatch::GreaterOrEqual, dim); if (my_end[i] - my_start[i] > std::numeric_limits::epsilon() || !ofst) { throw nix::OutOfBounds("util::offsetAndCount:An invalid range was encountered!"); } diff --git a/test/BaseTestDataAccess.cpp b/test/BaseTestDataAccess.cpp index 895258d2e..1df2bfbd6 100644 --- a/test/BaseTestDataAccess.cpp +++ b/test/BaseTestDataAccess.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -29,7 +30,6 @@ using namespace nix; using namespace std; -using namespace boost; void BaseTestDataAccess::testPositionToIndexRangeDimension() { string unit = "ms"; @@ -66,7 +66,7 @@ void BaseTestDataAccess::testPositionToIndexRangeDimension() { CPPUNIT_ASSERT_THROW(util::positionToIndex({5.0, 1.2}, {1.4}, {unit, unit}, RangeMatch::Inclusive, rangeDim), std::runtime_error); - vector>> range = util::positionToIndex({0.0}, {7.0}, {unit}, RangeMatch::Inclusive, rangeDim); + vector>> range = util::positionToIndex({0.0}, {7.0}, {unit}, RangeMatch::Inclusive, rangeDim); CPPUNIT_ASSERT(range[0] && (*range[0]).first == 0 && (*range[0]).second == 4); range = util::positionToIndex({0.0}, {7.0}, {unit}, RangeMatch::Exclusive, rangeDim); CPPUNIT_ASSERT(range[0] && (*range[0]).first == 0 && (*range[0]).second == 4); @@ -139,7 +139,7 @@ void BaseTestDataAccess::testPositionToIndexSampledDimension() { CPPUNIT_ASSERT_THROW(util::positionToIndex(1.0, unit, sampledDim), nix::IncompatibleDimensions); sampledDim.unit(unit); - vector>> ranges = util::positionToIndex({0.0, 2.0, 10.0}, {10.0, 2.0, 5.0}, {unit, unit, unit}, RangeMatch::Inclusive, sampledDim); + vector>> ranges = util::positionToIndex({0.0, 2.0, 10.0}, {10.0, 2.0, 5.0}, {unit, unit, unit}, RangeMatch::Inclusive, sampledDim); CPPUNIT_ASSERT(ranges.size() == 3); CPPUNIT_ASSERT(ranges[0] && (*ranges[0]).first == 0 && (*ranges[0]).second == 10); CPPUNIT_ASSERT(ranges[1] && (*ranges[1]).first == 2 && (*ranges[1]).second == 2); @@ -198,7 +198,7 @@ void BaseTestDataAccess::testPositionToIndexSetDimension() { CPPUNIT_ASSERT_THROW(util::positionToIndex({5.0, 0.}, {10.5}, RangeMatch::Inclusive, setDim), std::runtime_error); - vector>> ranges = util::positionToIndex({5.0, 0.}, {10.5, 1.0}, RangeMatch::Inclusive, setDim); + vector>> ranges = util::positionToIndex({5.0, 0.}, {10.5, 1.0}, RangeMatch::Inclusive, setDim); CPPUNIT_ASSERT(ranges.size() == 2); CPPUNIT_ASSERT(!ranges[0]); CPPUNIT_ASSERT(ranges[1] && (*ranges[1]).first == 0 && (*ranges[1]).second == 1); @@ -212,12 +212,12 @@ void BaseTestDataAccess::testPositionToIndexSetDimension() { void BaseTestDataAccess::testPositionToIndexDataFrameDimension() { CPPUNIT_ASSERT_NO_THROW(util::positionToIndex(12.2, PositionMatch::GreaterOrEqual, dfDim)); // no throw even though not valid - boost::optional pos = util::positionToIndex(12.2, PositionMatch::GreaterOrEqual, dfDim); + std::optional pos = util::positionToIndex(12.2, PositionMatch::GreaterOrEqual, dfDim); CPPUNIT_ASSERT(!pos); CPPUNIT_ASSERT_THROW(util::positionToIndex({1.0, 2.0}, {0.0}, RangeMatch::Exclusive, dfDim), std::runtime_error); - vector>> ranges = util::positionToIndex({0.0, 12.0, 5.0}, {9.0, 15.0, 0.0}, RangeMatch::Exclusive, dfDim); + vector>> ranges = util::positionToIndex({0.0, 12.0, 5.0}, {9.0, 15.0, 0.0}, RangeMatch::Exclusive, dfDim); CPPUNIT_ASSERT(ranges.size() == 3); CPPUNIT_ASSERT(ranges[0]); CPPUNIT_ASSERT(!ranges[1]); diff --git a/test/BaseTestDataArray.cpp b/test/BaseTestDataArray.cpp index 43a582eb3..43ab96481 100644 --- a/test/BaseTestDataArray.cpp +++ b/test/BaseTestDataArray.cpp @@ -65,7 +65,7 @@ void BaseTestDataArray::testDefinition() { std::string def = nix::util::createId(); array1.definition(def); CPPUNIT_ASSERT(*array1.definition() == def); - array1.definition(boost::none); + array1.definition(nix::none); CPPUNIT_ASSERT(array1.definition() == nix::none); } @@ -287,7 +287,7 @@ void BaseTestDataArray::testPolynomial() { CPPUNIT_ASSERT(array2.polynomCoefficients().size() == 0); array2.expansionOrigin(3); - boost::optional retval = array2.expansionOrigin(); + std::optional retval = array2.expansionOrigin(); CPPUNIT_ASSERT(*retval == 3); array2.expansionOrigin(nix::none); CPPUNIT_ASSERT(array2.expansionOrigin() == nix::none); @@ -332,7 +332,7 @@ void BaseTestDataArray::testPolynomial() { } // expansionOrigin alone - dap.polynomCoefficients(boost::none); + dap.polynomCoefficients(nix::none); dap.getData(DataType::Int32, dvin_poly.data(), nix::NDSize({2, 3}), nix::NDSize({0, 0})); CPPUNIT_ASSERT_EQUAL(dv.size(), dvin_poly.size()); for (size_t i = 0; i < dvin_poly.size(); i++) { @@ -345,7 +345,7 @@ void BaseTestDataArray::testLabel() { std::string testStr = "somestring"; array1.label(testStr); CPPUNIT_ASSERT(*array1.label() == testStr); - array1.label(boost::none); + array1.label(nix::none); CPPUNIT_ASSERT(array1.label() == nix::none); CPPUNIT_ASSERT_THROW(array1.label(""), EmptyString); } @@ -369,7 +369,7 @@ void BaseTestDataArray::testPolynomialSetter() { CPPUNIT_ASSERT(array1.polynomCoefficients().size() == 0); array1.expansionOrigin(3); - boost::optional retval = array1.expansionOrigin(); + std::optional retval = array1.expansionOrigin(); CPPUNIT_ASSERT(*retval == 3); array1.expansionOrigin(nix::none); CPPUNIT_ASSERT(array1.expansionOrigin() == nix::none); @@ -540,7 +540,7 @@ void BaseTestDataArray::testDataFrameDimension() { CPPUNIT_ASSERT_EQUAL(df.rows(), dim.size()); CPPUNIT_ASSERT_EQUAL(dim.label(), df.name()); - boost::optional col(0); + std::optional col(0); CPPUNIT_ASSERT_NO_THROW(dim.label(col)); CPPUNIT_ASSERT_EQUAL(dim.label(col), cols[0].name); @@ -580,7 +580,7 @@ void BaseTestDataArray::testDataFrameDimension() { CPPUNIT_ASSERT_THROW(array2.appendDataFrameDimension(df, "test"), nix::OutOfBounds); dim = array2.appendDataFrameDimension(df, "current"); - boost::optional col_index = dim.columnIndex(); + std::optional col_index = dim.columnIndex(); CPPUNIT_ASSERT(col_index && *col_index == 0); array2.deleteDimensions(); diff --git a/test/BaseTestDimension.cpp b/test/BaseTestDimension.cpp index cd19a866e..b72d97627 100644 --- a/test/BaseTestDimension.cpp +++ b/test/BaseTestDimension.cpp @@ -108,8 +108,8 @@ void BaseTestDimension::testSampledDimUnit() { CPPUNIT_ASSERT_THROW(sd.unit(invalidUnit), InvalidUnit); CPPUNIT_ASSERT_NO_THROW(sd.unit(validUnit)); CPPUNIT_ASSERT(*(sd.unit()) == validUnit); - CPPUNIT_ASSERT_NO_THROW(sd.unit(boost::none)); - CPPUNIT_ASSERT(sd.unit() == boost::none); + CPPUNIT_ASSERT_NO_THROW(sd.unit(nix::none)); + CPPUNIT_ASSERT(sd.unit() == nix::none); data_array.deleteDimensions(); } @@ -145,8 +145,8 @@ void BaseTestDimension::testSampledDimOffset() { sd = d; CPPUNIT_ASSERT_NO_THROW(sd.offset(offset)); CPPUNIT_ASSERT(*(sd.offset()) == offset); - CPPUNIT_ASSERT_NO_THROW(sd.offset(boost::none)); - CPPUNIT_ASSERT(sd.offset() == boost::none); + CPPUNIT_ASSERT_NO_THROW(sd.offset(nix::none)); + CPPUNIT_ASSERT(sd.offset() == nix::none); data_array.deleteDimensions(); } @@ -299,7 +299,7 @@ void BaseTestDimension::testSampledDimIndexOf() { CPPUNIT_ASSERT(sd.indexOf(0.0, PositionMatch::Greater) && *sd.indexOf(0.0, PositionMatch::Greater) == 2); // test ranges offset = -1, sampling interval = 1 - boost::optional> range = sd.indexOf(0.0, 0.0, RangeMatch::Inclusive); + std::optional> range = sd.indexOf(0.0, 0.0, RangeMatch::Inclusive); CPPUNIT_ASSERT(range && (*range).first == 1 && (*range).second == 1); range = sd.indexOf(0.0, 0.0, RangeMatch::Exclusive); CPPUNIT_ASSERT(!range); @@ -319,7 +319,7 @@ void BaseTestDimension::testSampledDimIndexOf() { // test vector of ranges, offset = -1, sampling interval = 1 CPPUNIT_ASSERT_THROW(sd.indexOf({1.0, 20.0, 40.0}, {10.9, 12.}, RangeMatch::Exclusive), std::runtime_error); - std::vector>> ranges = sd.indexOf({1.0, 12.0, 1.0, 5.0}, {10.9, 20.0, 40.0, 5.0}, RangeMatch::Inclusive); + std::vector>> ranges = sd.indexOf({1.0, 12.0, 1.0, 5.0}, {10.9, 20.0, 40.0, 5.0}, RangeMatch::Inclusive); CPPUNIT_ASSERT(ranges.size() == 4); CPPUNIT_ASSERT(ranges[0] && (*ranges[0]).first == 2 && (*ranges[0]).second == 11 && sd.positionAt((*ranges[0]).first) >= 1.0 && sd.positionAt((*ranges[0]).second) <= 10.9); @@ -497,7 +497,7 @@ void BaseTestDimension::testSetDimLabels() { CPPUNIT_ASSERT(new_labels[i] == retrieved_labels[i]); } - sd.labels(boost::none); + sd.labels(nix::none); retrieved_labels = sd.labels(); CPPUNIT_ASSERT_EQUAL(static_cast(0), retrieved_labels.size()); @@ -513,7 +513,7 @@ void BaseTestDimension::testSetDimIndexOf() { sd = d; sd.labels(labels); - boost::optional index; + std::optional index; index = sd.indexOf(-1.0, PositionMatch::Less); CPPUNIT_ASSERT(!index); index = sd.indexOf(-1.0, PositionMatch::LessOrEqual); @@ -560,7 +560,7 @@ void BaseTestDimension::testSetDimIndexOf() { index = sd.indexOf(5.0, PositionMatch::Greater); CPPUNIT_ASSERT(!index); - sd.labels(boost::none); + sd.labels(nix::none); index = sd.indexOf(5.0, PositionMatch::Less); CPPUNIT_ASSERT(index && *index == 4); index = sd.indexOf(5.0, PositionMatch::LessOrEqual); @@ -583,7 +583,7 @@ void BaseTestDimension::testSetDimIndexOf() { index = sd.indexOf(5.5, PositionMatch::Greater); CPPUNIT_ASSERT(index && *index == 6); - boost::optional> range = sd.indexOf(0.0, 0.0, RangeMatch::Inclusive); + std::optional> range = sd.indexOf(0.0, 0.0, RangeMatch::Inclusive); CPPUNIT_ASSERT(range && (*range).first == 0 && (*range).second == 0); range = sd.indexOf(0.0, 0.0, RangeMatch::Exclusive); CPPUNIT_ASSERT(!range); @@ -614,7 +614,7 @@ void BaseTestDimension::testSetDimIndexOf() { range = sd.indexOf(3.0, 7.0, RangeMatch::Exclusive); CPPUNIT_ASSERT(range && (*range).first == 3 && (*range).second == 4); - std::vector>> ranges; + std::vector>> ranges; CPPUNIT_ASSERT_THROW(sd.indexOf({0.0, -1.0, 1.0}, {1.0, 2.0}, RangeMatch::Inclusive), std::runtime_error); ranges = sd.indexOf({0.0, -1.0, 1.0, 1.0}, {1.0, 4.0, 9.0, 1.0}, RangeMatch::Inclusive); CPPUNIT_ASSERT(ranges.size() == 4); @@ -799,7 +799,7 @@ void BaseTestDimension::testRangeDimIndexOf() { CPPUNIT_ASSERT(*rd.indexOf(110., PositionMatch::Less) == 4); CPPUNIT_ASSERT(!rd.indexOf(110., PositionMatch::Equal)); - boost::optional> range; + std::optional> range; range = rd.indexOf(40., 100., {}, RangeMatch::Inclusive); CPPUNIT_ASSERT(range && (*range).first == 4 && (*range).second == 4); range = rd.indexOf(40., 100., {}, RangeMatch::Exclusive); @@ -839,7 +839,7 @@ void BaseTestDimension::testRangeDimIndexOf() { CPPUNIT_ASSERT(ranges[0].first == 0 && ranges[0].second == 3); CPPUNIT_ASSERT(ranges[1].first == 0 && ranges[1].second == 4); - std::vector>> optranges; + std::vector>> optranges; optranges = rd.indexOf({40., -100.}, {100., 100.}, RangeMatch::Inclusive); CPPUNIT_ASSERT(optranges.size() == 2); CPPUNIT_ASSERT(optranges[0] && (*optranges[0]).first == 4 && (*optranges[0]).second == 4); @@ -935,7 +935,7 @@ void BaseTestDimension::testDataFrameDimIndexOf() { DataFrameDimension dfDim; dfDim = d; - boost::optional pos = dfDim.indexOf(12.2, PositionMatch::GreaterOrEqual); + std::optional pos = dfDim.indexOf(12.2, PositionMatch::GreaterOrEqual); CPPUNIT_ASSERT(!pos); pos = dfDim.indexOf(12.2, PositionMatch::Greater); CPPUNIT_ASSERT(!pos); @@ -990,7 +990,7 @@ void BaseTestDimension::testDataFrameDimIndexOf() { pos = dfDim.indexOf(-0.5, PositionMatch::Less); CPPUNIT_ASSERT(!pos); - boost::optional> range = dfDim.indexOf(0.0, 0.0, RangeMatch::Inclusive); + std::optional> range = dfDim.indexOf(0.0, 0.0, RangeMatch::Inclusive); CPPUNIT_ASSERT(range && (*range).first == 0 && (*range).second == 0); range = dfDim.indexOf(0.0, 0.0, RangeMatch::Exclusive); CPPUNIT_ASSERT(!range); @@ -1020,7 +1020,7 @@ void BaseTestDimension::testDataFrameDimIndexOf() { range = dfDim.indexOf(3.0, 9.0, RangeMatch::Exclusive); CPPUNIT_ASSERT(range && (*range).first == 3 && (*range).second == 8); - std::vector>> ranges; + std::vector>> ranges; CPPUNIT_ASSERT_THROW(dfDim.indexOf({0.0, -1.0, 1.0}, {1.0, 2.0}, RangeMatch::Inclusive), std::runtime_error); ranges = dfDim.indexOf({0.0, -1.0, 1.0, 1.0}, {1.0, 4.0, 9.0, 1.0}, RangeMatch::Inclusive); CPPUNIT_ASSERT(ranges.size() == 4); diff --git a/test/BaseTestGroup.cpp b/test/BaseTestGroup.cpp index f9d7a0493..5c2eedc53 100644 --- a/test/BaseTestGroup.cpp +++ b/test/BaseTestGroup.cpp @@ -42,7 +42,7 @@ void BaseTestGroup::testDefinition() { std::string def = nix::util::createId(); g.definition(def); CPPUNIT_ASSERT(*g.definition() == def); - g.definition(boost::none); + g.definition(nix::none); CPPUNIT_ASSERT(g.definition() == nix::none); } diff --git a/test/BaseTestSection.cpp b/test/BaseTestSection.cpp index 401909262..c3257ab89 100644 --- a/test/BaseTestSection.cpp +++ b/test/BaseTestSection.cpp @@ -78,7 +78,7 @@ void BaseTestSection::testRepository() { std::string rep = "http://foo.bar/" + util::createId(); section.repository(rep); CPPUNIT_ASSERT(section.repository() == rep); - section.repository(boost::none); + section.repository(nix::none); CPPUNIT_ASSERT(!section.repository()); CPPUNIT_ASSERT_THROW(section.repository(""), EmptyString); } diff --git a/test/TestOptionalObligatory.hpp b/test/TestOptionalObligatory.hpp index a4fcff823..0375003ae 100644 --- a/test/TestOptionalObligatory.hpp +++ b/test/TestOptionalObligatory.hpp @@ -45,9 +45,9 @@ namespace test { * Check if the given info about an attribute's getter-setter pair * amounts to correct optional attribute behaviour; * - * @param bool telling whether attribute getter returns boost::optional + * @param bool telling whether attribute getter returns std::optional * @param bool telling whether attribute getter returns value == true - * @param bool telling whether attribute setter accepts boost::none + * @param bool telling whether attribute setter accepts nix::none * * @return bool */ @@ -57,9 +57,9 @@ namespace test { * Check if the given info about an attribute's getter-setter pair * amounts to correct obligatory attribute behaviour; * - * @param bool telling whether attribute getter returns boost::optional + * @param bool telling whether attribute getter returns std::optional * @param bool telling whether attribute getter returns value == true - * @param bool telling whether attribute setter accepts boost::none + * @param bool telling whether attribute setter accepts nix::none * * @return bool */ @@ -72,7 +72,7 @@ namespace test { template class accepts_noneT { - template struct Check; + template struct Check; template static char func(Check *); template static int func(...); public: @@ -83,7 +83,7 @@ namespace test { template \ class accepts_noneT \ { \ - template struct Check; \ + template struct Check; \ template static char func(Check *); \ template static int func(...); \ public: \ @@ -153,9 +153,9 @@ class TestOptionalObligatory : public CPPUNIT_NS::TestFixture { nix::Feature feature; time_t startup_time; nix::Variant dummy; - bool is_opt; // whether getter return value is boost::optional + bool is_opt; // whether getter return value is std::optional bool is_set; // whether getter return value is set - // bool accepts_none; // whether setter accepts boost::none (declared in place) + // bool accepts_none; // whether setter accepts nix::none (declared in place) std::string summary; diff --git a/test/TestValidate.cpp b/test/TestValidate.cpp index 3b1a55f12..68ef14d72 100644 --- a/test/TestValidate.cpp +++ b/test/TestValidate.cpp @@ -257,7 +257,7 @@ void TestValidate::test() { // check if nix::getEntityName works correctly // this is here because there is currently no better place // and we only use that function in the validation code - boost::optional name = nix::getEntityName(block); + std::optional name = nix::getEntityName(block); CPPUNIT_ASSERT(!!name); CPPUNIT_ASSERT_EQUAL(*name, block.name()); diff --git a/test/TestValidate.hpp b/test/TestValidate.hpp index 81828e151..6b6e02958 100644 --- a/test/TestValidate.hpp +++ b/test/TestValidate.hpp @@ -25,7 +25,6 @@ #include #include -#include // define some tag like class with units- & unit-getter that allows compound units struct tag_tmp { @@ -42,8 +41,8 @@ struct tag_tmp { return units_ref.front(); } - boost::optional unito() const { - boost::optional ret = units_ref.front(); + std::optional unito() const { + std::optional ret = units_ref.front(); return ret; } }; diff --git a/test/hdf5/TestH5Group.cpp b/test/hdf5/TestH5Group.cpp index 1d396e8ef..417c918e0 100644 --- a/test/hdf5/TestH5Group.cpp +++ b/test/hdf5/TestH5Group.cpp @@ -195,13 +195,13 @@ void TestH5Group::testOpen() { std::string idout; - boost::optional a = root.findGroupByNameOrAttribute("entity_id", "name_a"); + std::optional a = root.findGroupByNameOrAttribute("entity_id", "name_a"); CPPUNIT_ASSERT(a); CPPUNIT_ASSERT(a->hasAttr("entity_id")); a->getAttr("entity_id", idout); CPPUNIT_ASSERT_EQUAL(uuid, idout); - boost::optional b = root.findGroupByNameOrAttribute("entity_id", uuid); + std::optional b = root.findGroupByNameOrAttribute("entity_id", uuid); CPPUNIT_ASSERT(b); CPPUNIT_ASSERT(b->hasAttr("entity_id")); b->getAttr("entity_id", idout);