forked from EvergreenCrypto/docker-finance
root: macro: layout reorg, related refactor
This commit is contained in:
90
container/src/root/macro/common/common.hh
Normal file
90
container/src/root/macro/common/common.hh
Normal file
@@ -0,0 +1,90 @@
|
||||
// docker-finance | modern accounting for the power-user
|
||||
//
|
||||
// Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
//! \file
|
||||
//! \author Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
//! \note File intended to be loaded into ROOT.cern framework / Cling interpreter
|
||||
//! \since docker-finance 1.0.0
|
||||
|
||||
#ifndef CONTAINER_SRC_ROOT_MACRO_COMMON_COMMON_HH_
|
||||
#define CONTAINER_SRC_ROOT_MACRO_COMMON_COMMON_HH_
|
||||
|
||||
#include <initializer_list>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
//! \namespace docker_finance
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace docker_finance
|
||||
{
|
||||
//! \namespace docker_finance::macro
|
||||
//! \brief ROOT macros
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace macro
|
||||
{
|
||||
//! \namespace docker_finance::macro::internal
|
||||
//! \brief ROOT macros for internal use only
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace internal
|
||||
{
|
||||
//! \brief Wrapper to ROOT Cling commands
|
||||
//! \ingroup cpp_macro_impl
|
||||
//! \since docker-finance 1.0.0
|
||||
class Command final
|
||||
{
|
||||
public:
|
||||
Command() = default;
|
||||
~Command() = default;
|
||||
|
||||
Command(const Command&) = default;
|
||||
Command& operator=(const Command&) = default;
|
||||
|
||||
Command(Command&&) = default;
|
||||
Command& operator=(Command&&) = default;
|
||||
|
||||
private:
|
||||
static void cmd_handler(const std::initializer_list<std::string>& command)
|
||||
{
|
||||
for (const auto& cmd : command)
|
||||
{
|
||||
std::cout << "Interpreting: '" << cmd << "'" << std::endl;
|
||||
gInterpreter->ProcessLine(cmd.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
//! \brief Load given file path
|
||||
static void load(const std::string& path)
|
||||
{
|
||||
std::string cmd{".L ./" + path};
|
||||
Command::cmd_handler({cmd});
|
||||
}
|
||||
|
||||
//! \brief Load given file paths
|
||||
static void load(const std::initializer_list<std::string>& commands)
|
||||
{
|
||||
for (const auto& cmd : commands)
|
||||
Command::load(cmd);
|
||||
}
|
||||
};
|
||||
} // namespace internal
|
||||
} // namespace macro
|
||||
} // namespace docker_finance
|
||||
|
||||
#endif // CONTAINER_SRC_ROOT_MACRO_COMMON_COMMON_HH_
|
||||
|
||||
// # vim: sw=2 sts=2 si ai et
|
||||
85
container/src/root/macro/common/crypto.hh
Normal file
85
container/src/root/macro/common/crypto.hh
Normal file
@@ -0,0 +1,85 @@
|
||||
// docker-finance | modern accounting for the power-user
|
||||
//
|
||||
// Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
//! \file
|
||||
//! \author Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
//! \note File intended to be loaded into ROOT.cern framework / Cling interpreter
|
||||
//! \since docker-finance 1.0.0
|
||||
|
||||
#ifndef CONTAINER_SRC_ROOT_MACRO_COMMON_CRYPTO_HH_
|
||||
#define CONTAINER_SRC_ROOT_MACRO_COMMON_CRYPTO_HH_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "../../src/hash.hh"
|
||||
#include "../../src/random.hh"
|
||||
|
||||
//! \namespace docker_finance
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace docker_finance
|
||||
{
|
||||
//! \namespace docker_finance::macro
|
||||
//! \brief ROOT macros
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace macro
|
||||
{
|
||||
|
||||
//! \namespace docker_finance::macro::crypto::botan
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace crypto::botan
|
||||
{
|
||||
//! \brief ROOT's Botan Hash instance
|
||||
//! \ingroup cpp_macro
|
||||
auto g_Hash = std::make_unique<::docker_finance::crypto::botan::Hash>();
|
||||
|
||||
//! \brief ROOT's Botan Random instance
|
||||
//! \ingroup cpp_macro
|
||||
auto g_Random = std::make_unique<::docker_finance::crypto::botan::Random>();
|
||||
} // namespace crypto::botan
|
||||
|
||||
//! \namespace docker_finance::macro::crypto::cryptopp
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace crypto::cryptopp
|
||||
{
|
||||
//! \brief ROOT's Crypto++ Hash instance
|
||||
//! \ingroup cpp_macro
|
||||
auto g_Hash = std::make_unique<::docker_finance::crypto::cryptopp::Hash>();
|
||||
|
||||
//! \brief ROOT's Crypto++ Random instance
|
||||
//! \ingroup cpp_macro
|
||||
auto g_Random = std::make_unique<::docker_finance::crypto::cryptopp::Random>();
|
||||
} // namespace crypto::cryptopp
|
||||
|
||||
//! \namespace docker_finance::macro::crypto::libsodium
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace crypto::libsodium
|
||||
{
|
||||
//! \brief ROOT's libsodium Hash instance
|
||||
//! \ingroup cpp_macro
|
||||
auto g_Hash = std::make_unique<::docker_finance::crypto::libsodium::Hash>();
|
||||
|
||||
//! \brief ROOT's libsodium Random instance
|
||||
//! \ingroup cpp_macro
|
||||
auto g_Random = std::make_unique<::docker_finance::crypto::libsodium::Random>();
|
||||
} // namespace crypto::libsodium
|
||||
|
||||
} // namespace macro
|
||||
} // namespace docker_finance
|
||||
|
||||
#endif // CONTAINER_SRC_ROOT_MACRO_COMMON_CRYPTO_HH_
|
||||
|
||||
// # vim: sw=2 sts=2 si ai et
|
||||
79
container/src/root/macro/common/utility.hh
Normal file
79
container/src/root/macro/common/utility.hh
Normal file
@@ -0,0 +1,79 @@
|
||||
// docker-finance | modern accounting for the power-user
|
||||
//
|
||||
// Copyright (C) 2021-2024 Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
//! \file
|
||||
//! \author Aaron Fiore (Founder, Evergreen Crypto LLC)
|
||||
//! \note File intended to be loaded into ROOT.cern framework / Cling interpreter
|
||||
//! \since docker-finance 1.0.0
|
||||
|
||||
#ifndef CONTAINER_SRC_ROOT_MACRO_COMMON_UTILITY_HH_
|
||||
#define CONTAINER_SRC_ROOT_MACRO_COMMON_UTILITY_HH_
|
||||
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
//! \namespace docker_finance
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace docker_finance
|
||||
{
|
||||
//! \namespace docker_finance::macro
|
||||
//! \brief ROOT macros
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace macro
|
||||
{
|
||||
//! \namespace docker_finance::macro::internal
|
||||
//! \brief ROOT macros for internal use only
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace internal
|
||||
{
|
||||
//! \namespace docker_finance::macro::internal::utility
|
||||
//! \brief To help grease the wheels of the machine
|
||||
//! \since docker-finance 1.0.0
|
||||
namespace utility
|
||||
{
|
||||
//! \brief Get ROOT environment variable
|
||||
//! \param var ROOT variable
|
||||
//! \note ROOT environment variables include shell (and shell caller) environment
|
||||
//! \since docker-finance 1.0.0
|
||||
std::string get_env(const std::string& var)
|
||||
{
|
||||
const auto* env = gSystem->Getenv(var.c_str());
|
||||
if (!env)
|
||||
throw std::runtime_error(
|
||||
std::string{var + " is not set or is unavailable"}.c_str());
|
||||
return std::string{env};
|
||||
}
|
||||
|
||||
//! \brief Make current timestamp
|
||||
//! \return timestamp in "yyyy-mm-ddThh:mm:ssZ" format
|
||||
//! \since docker-finance 1.0.0
|
||||
std::string make_timestamp()
|
||||
{
|
||||
const std::time_t t{std::time({})};
|
||||
std::vector<char> time(std::size("yyyy-mm-ddThh:mm:ssZ"));
|
||||
std::strftime(time.data(), time.size(), "%FT%TZ", std::gmtime(&t));
|
||||
return std::string{time.data()};
|
||||
}
|
||||
} // namespace utility
|
||||
} // namespace internal
|
||||
} // namespace macro
|
||||
} // namespace docker_finance
|
||||
|
||||
#endif // CONTAINER_SRC_ROOT_MACRO_COMMON_UTILITY_HH_
|
||||
|
||||
// # vim: sw=2 sts=2 si ai et
|
||||
Reference in New Issue
Block a user