summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-07-10 12:08:19 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-07-10 12:08:19 +0200
commitf0a21e78764fd17747033b596b640bbcaf517f49 (patch)
tree564ef37556e9a0c351a5aea874a1e315e67d8d9b
parent1c4bcb0ca012bebe7c7b9408aa85bb5b089e4619 (diff)
feat&fix: Reorganize library, and remove junk CMake files.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
-rw-r--r--examples/cgi/cgi.cc4
-rw-r--r--examples/equiv/equiv.cc2
-rw-r--r--examples/must_pass/CMakeLists.txt12
-rw-r--r--examples/opt/CMakeLists.txt12
-rw-r--r--examples/opt/opt.cc (renamed from examples/must_pass/must_pass.cc)4
-rw-r--r--lib/detail/.keep0
-rw-r--r--lib/detail/error.hpp17
-rw-r--r--lib/fix/network.hpp8
-rw-r--r--lib/fix/parser.hpp2
-rw-r--r--lib/logic/equiv.hpp (renamed from lib/equiv.hpp)0
-rw-r--r--lib/logic/math.hpp (renamed from lib/math.hpp)0
-rw-r--r--lib/logic/opt.hpp (renamed from lib/opt.hpp)32
-rw-r--r--lib/utility/cgi.hpp (renamed from lib/cgi.hpp)4
-rw-r--r--lib/utility/crc32.hpp (renamed from lib/crc32.hpp)4
-rw-r--r--lib/utility/embfs.hpp (renamed from lib/embfs.hpp)0
15 files changed, 59 insertions, 42 deletions
diff --git a/examples/cgi/cgi.cc b/examples/cgi/cgi.cc
index 5586410..d4a4f6a 100644
--- a/examples/cgi/cgi.cc
+++ b/examples/cgi/cgi.cc
@@ -4,7 +4,7 @@
licensed under the MIT license
*/
-#include <lib/cgi.hpp>
+#include <lib/utility/cgi.hpp>
#include <fstream>
#include <sstream>
#include <string>
@@ -73,7 +73,7 @@ int main(int argc, char** argv)
{
// ... let's assume we serve data.
- snu::web::cgi_writer writer;
+ snu::cgi::cgi_writer writer;
std::stringstream ss_file;
std::ifstream fp("index.html");
diff --git a/examples/equiv/equiv.cc b/examples/equiv/equiv.cc
index 326683e..896637d 100644
--- a/examples/equiv/equiv.cc
+++ b/examples/equiv/equiv.cc
@@ -4,7 +4,7 @@
licensed under the MIT license
*/
-#include <lib/equiv.hpp>
+#include <lib/logic/equiv.hpp>
#include <iostream>
/* finally test it */
diff --git a/examples/must_pass/CMakeLists.txt b/examples/must_pass/CMakeLists.txt
deleted file mode 100644
index 8ef683b..0000000
--- a/examples/must_pass/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-
-cmake_minimum_required(VERSION 3.15...3.31)
-
-project(
- MustPass
- VERSION 1.0
- LANGUAGES CXX)
-
-add_executable(MustPass must_pass.cc)
-
-set_property(TARGET MustPass PROPERTY CXX_STANDARD 20)
-target_include_directories(MustPass PUBLIC ../../)
diff --git a/examples/opt/CMakeLists.txt b/examples/opt/CMakeLists.txt
new file mode 100644
index 0000000..b63b1de
--- /dev/null
+++ b/examples/opt/CMakeLists.txt
@@ -0,0 +1,12 @@
+
+cmake_minimum_required(VERSION 3.15...3.31)
+
+project(
+ Opt
+ VERSION 1.0
+ LANGUAGES CXX)
+
+add_executable(Opt opt.cc)
+
+set_property(TARGET Opt PROPERTY CXX_STANDARD 20)
+target_include_directories(Opt PUBLIC ../../)
diff --git a/examples/must_pass/must_pass.cc b/examples/opt/opt.cc
index dbe5bb4..a914d8d 100644
--- a/examples/must_pass/must_pass.cc
+++ b/examples/opt/opt.cc
@@ -4,7 +4,7 @@
licensed under the MIT license
*/
-#include <lib/opt.hpp>
+#include <lib/logic/opt.hpp>
#include <lib/io/print.hpp>
#include <string>
@@ -25,7 +25,7 @@ static auto do_some(const std::string recv_data, const std::string check_data)
const int hash_to_check = do_hash(check_data); /* here we assume this should match opt_hash */
const int opt_hash = do_hash(recv_data); /* we assume that the hash is correct */
- auto opt = snu::opt(snu::eval_eq(hash_to_check, opt_hash)); /* do the compute */
+ auto opt = snu::opt::opt(snu::opt::eval_eq(hash_to_check, opt_hash)); /* do the compute */
return opt;
}
diff --git a/lib/detail/.keep b/lib/detail/.keep
deleted file mode 100644
index e69de29..0000000
--- a/lib/detail/.keep
+++ /dev/null
diff --git a/lib/detail/error.hpp b/lib/detail/error.hpp
new file mode 100644
index 0000000..85a5e25
--- /dev/null
+++ b/lib/detail/error.hpp
@@ -0,0 +1,17 @@
+/*
+ * File: opt.hpp
+ * Author: Amlal El Mahrouss,
+ * Copyright 2023-2025, Amlal El Mahrouss/SNU Systems Corp all rights reserved.
+ */
+
+#ifndef _SNU_ERR_HPP
+#define _SNU_ERR_HPP
+
+#include <stdexcept>
+
+namespace snu
+{
+ using runtime_error = std::runtime_error;
+}
+
+#endif // _SNU_ERR_HPP \ No newline at end of file
diff --git a/lib/fix/network.hpp b/lib/fix/network.hpp
index a99ba05..9186b15 100644
--- a/lib/fix/network.hpp
+++ b/lib/fix/network.hpp
@@ -1,6 +1,6 @@
/*
* File: fix/netowrk.hpp
- * Purpose: Financial Information Protocol network implementation in C++.
+ * Purpose: Financial Information Exchange in C++
* Author: Amlal El Mahrouss (founder@snu.systems)
* Copyright 2025, Amlal El Mahrouss and SNU Systems Corp all rights reserved.
*/
@@ -13,8 +13,8 @@
namespace snu::fix
{
- class network_rx;
- class network_tx;
-}
+ class network_rx;
+ class network_tx;
+} // namespace snu::fix
#endif // ifndef _SNU_FIX_NETWORK_HPP \ No newline at end of file
diff --git a/lib/fix/parser.hpp b/lib/fix/parser.hpp
index bca5353..f643241 100644
--- a/lib/fix/parser.hpp
+++ b/lib/fix/parser.hpp
@@ -1,6 +1,6 @@
/*
* File: fix/parser.hpp
- * Purpose: Financial Information Protocol parser implementation in C++.
+ * Purpose: Financial Information Exchange parser in C++
* Author: Amlal El Mahrouss (founder@snu.systems)
* Copyright 2025, Amlal El Mahrouss and SNU Systems Corp all rights reserved.
*/
diff --git a/lib/equiv.hpp b/lib/logic/equiv.hpp
index 4bb5904..4bb5904 100644
--- a/lib/equiv.hpp
+++ b/lib/logic/equiv.hpp
diff --git a/lib/math.hpp b/lib/logic/math.hpp
index 2613799..2613799 100644
--- a/lib/math.hpp
+++ b/lib/logic/math.hpp
diff --git a/lib/opt.hpp b/lib/logic/opt.hpp
index f4f62a2..d2a9150 100644
--- a/lib/opt.hpp
+++ b/lib/logic/opt.hpp
@@ -7,12 +7,12 @@
#ifndef _SNU_OPT_HPP
#define _SNU_OPT_HPP
-#include <stdexcept>
+#include <lib/detail/error.hpp>
#include <utility>
-namespace snu
+namespace snu::opt
{
- enum class ret
+ enum class return_type
{
invalid = 0,
okay = 100,
@@ -22,14 +22,14 @@ namespace snu
struct opt final
{
- explicit opt(const ret& ret)
- : m_ret(ret)
+ explicit opt(const return_type& return_type)
+ : m_ret(return_type)
{
}
opt& expect(const char* input)
{
- if (m_ret == ret::err)
+ if (m_ret == return_type::err)
{
throw std::runtime_error(input);
}
@@ -38,13 +38,13 @@ namespace snu
}
private:
- ret m_ret;
+ return_type m_ret;
};
template <typename Teller, typename... Lst>
- inline snu::ret eval(Teller tell, Lst&&... arg)
+ inline return_type eval(Teller tell, Lst&&... arg)
{
- return tell(std::forward<Lst>(arg)...) ? snu::ret::okay : snu::ret::err;
+ return tell(std::forward<Lst>(arg)...) ? return_type::okay : return_type::err;
}
namespace traits
@@ -87,26 +87,26 @@ namespace snu
} // namespace traits
template <typename... Lst>
- inline ret eval_less_than(Lst&&... arg)
+ inline return_type eval_less_than(Lst&&... arg)
{
static traits::int_less_than_teller eq;
- return eq(std::forward<Lst>(arg)...) ? ret::okay : ret::err;
+ return eq(std::forward<Lst>(arg)...) ? return_type::okay : return_type::err;
}
template <typename... Lst>
- inline ret eval_eq(Lst&&... arg)
+ inline return_type eval_eq(Lst&&... arg)
{
static traits::int_eq_teller less_than;
- return less_than(std::forward<Lst>(arg)...) ? ret::okay : ret::err;
+ return less_than(std::forward<Lst>(arg)...) ? return_type::okay : return_type::err;
}
template <typename... Lst>
- inline ret eval_greater_than(Lst&&... arg)
+ inline return_type eval_greater_than(Lst&&... arg)
{
static traits::int_greater_than_teller greater_than;
- return greater_than(std::forward<Lst>(arg)...) ? ret::okay : ret::err;
+ return greater_than(std::forward<Lst>(arg)...) ? return_type::okay : return_type::err;
}
-} /* namespace snu */
+} // namespace snu::opt
#endif /* ifndef _SNU_OPT_HPP */
diff --git a/lib/cgi.hpp b/lib/utility/cgi.hpp
index e171eed..b93cde7 100644
--- a/lib/cgi.hpp
+++ b/lib/utility/cgi.hpp
@@ -13,7 +13,7 @@
namespace snu
{
- namespace web
+ namespace cgi
{
/// @brief CGI Writer class, writes to stdout; as CGI expects.
class cgi_writer final
@@ -56,7 +56,7 @@ namespace snu
return this->eval_("text/javascript", ss_html);
}
};
- } // namespace web
+ } // namespace cgi
} // namespace snu
#endif // ifndef _SNU_CGI_HPP \ No newline at end of file
diff --git a/lib/crc32.hpp b/lib/utility/crc32.hpp
index bbdb15c..de78d4e 100644
--- a/lib/crc32.hpp
+++ b/lib/utility/crc32.hpp
@@ -14,7 +14,7 @@
/// @brief Crc32 implementation in C++
/// @author Amlal EL Mahrouss (founder@snu.systems)
-namespace snu
+namespace snu::crc32
{
namespace details
{
@@ -69,6 +69,6 @@ namespace snu
return ~crc;
}
} // namespace details
-} // namespace snu
+} // namespace snu::crc32
#endif // !_SNU_CRC32_HPP \ No newline at end of file
diff --git a/lib/embfs.hpp b/lib/utility/embfs.hpp
index 7beb1db..7beb1db 100644
--- a/lib/embfs.hpp
+++ b/lib/utility/embfs.hpp