Mercurial > minori
diff dep/toml11/toml/storage.hpp @ 318:3b355fa948c7
config: use TOML instead of INI
unfortunately, INI is not enough, and causes some paths including
semicolons to break with our current storage of the library folders.
so, I decided to switch to TOML which does support real arrays...
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 12 Jun 2024 05:25:41 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dep/toml11/toml/storage.hpp Wed Jun 12 05:25:41 2024 -0400 @@ -0,0 +1,43 @@ +// Copyright Toru Niina 2017. +// Distributed under the MIT License. +#ifndef TOML11_STORAGE_HPP +#define TOML11_STORAGE_HPP +#include "utility.hpp" + +namespace toml +{ +namespace detail +{ + +// this contains pointer and deep-copy the content if copied. +// to avoid recursive pointer. +template<typename T> +struct storage +{ + using value_type = T; + + explicit storage(value_type const& v): ptr(toml::make_unique<T>(v)) {} + explicit storage(value_type&& v): ptr(toml::make_unique<T>(std::move(v))) {} + ~storage() = default; + storage(const storage& rhs): ptr(toml::make_unique<T>(*rhs.ptr)) {} + storage& operator=(const storage& rhs) + { + this->ptr = toml::make_unique<T>(*rhs.ptr); + return *this; + } + storage(storage&&) = default; + storage& operator=(storage&&) = default; + + bool is_ok() const noexcept {return static_cast<bool>(ptr);} + + value_type& value() & noexcept {return *ptr;} + value_type const& value() const& noexcept {return *ptr;} + value_type&& value() && noexcept {return std::move(*ptr);} + + private: + std::unique_ptr<value_type> ptr; +}; + +} // detail +} // toml +#endif// TOML11_STORAGE_HPP