summaryrefslogtreecommitdiff
path: root/src/logTypes.hpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-08-21 20:39:52 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2025-08-25 16:00:59 +0100
commitb2416925f8845b70ed25fb4ec7cde8ef11e8c239 (patch)
tree9ed898937ddceca6bcf0e2a6d6dfda3754dceefe /src/logTypes.hpp
downloadwebstat-b2416925f8845b70ed25fb4ec7cde8ef11e8c239.tar.bz2
webstat-b2416925f8845b70ed25fb4ec7cde8ef11e8c239.tar.xz
webstat-b2416925f8845b70ed25fb4ec7cde8ef11e8c239.zip
Initial commit; basic Apache log parsing
Diffstat (limited to 'src/logTypes.hpp')
-rw-r--r--src/logTypes.hpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/logTypes.hpp b/src/logTypes.hpp
new file mode 100644
index 0000000..d4f1b7b
--- /dev/null
+++ b/src/logTypes.hpp
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <optional>
+#include <scn/scan.h>
+#include <string>
+
+namespace WebStat {
+ struct QuotedString : std::string {
+ using std::string::string;
+ using std::string::operator=;
+ };
+
+ struct QueryString : std::optional<std::string> {
+ using std::optional<std::string>::optional;
+ using std::optional<std::string>::operator=;
+ bool operator<=>(const QueryString &) const = default;
+ };
+
+ struct CLFString : std::optional<std::string> {
+ using std::optional<std::string>::optional;
+ using std::optional<std::string>::operator=;
+ bool operator<=>(const CLFString &) const = default;
+ };
+}
+
+namespace scn {
+ using ContextType = scn::v4::basic_scan_context<scn::v4::detail::buffer_range_tag, char>;
+
+ template<> struct scanner<WebStat::QuotedString> : scanner<std::string, char> {
+ static scan_expected<typename ContextType::iterator> scan(WebStat::QuotedString & value, ContextType & ctx);
+ };
+
+ template<> struct scanner<WebStat::QueryString> : scanner<std::string, char> {
+ static scan_expected<typename ContextType::iterator> scan(WebStat::QueryString & value, ContextType & ctx);
+ };
+
+ template<> struct scanner<WebStat::CLFString> : scanner<std::string, char> {
+ static scan_expected<typename ContextType::iterator> scan(WebStat::CLFString & value, ContextType & ctx);
+
+ static void decode(std::string &);
+ };
+}