AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
dateFormatter.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2012 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include "anch-date-export.hpp"
23
24#include <memory>
25#include <ostream>
26#include <string>
27#include <vector>
28
29#include "date/dateTime.hpp"
30
31
32namespace anch::date {
33
35
38 typedef anch::date::IDatePartFormatter* (*getInstance)();
39
64 class ANCH_DATE_EXPORT DateFormatter {
65
66 // Attributes +
67 private:
69 std::vector<std::unique_ptr<anch::date::IDatePartFormatter>> _formatters;
70
72 std::size_t _size;
73 // Attributes -
74
75 // Constructors +
76 public:
82 explicit DateFormatter(const std::string& dateFormat);
83
87 DateFormatter(const DateFormatter&) = delete;
88
92 DateFormatter(DateFormatter&&) noexcept = default;
93 // Constructors -
94
95 // Destructor +
96 public:
100 virtual ~DateFormatter() noexcept;
101 // Destructor -
102
103 // Methods +
104 public:
111 static void registerFormatterPart(const std::string& pattern, getInstance instGetter) noexcept;
112
119 void format(const anch::date::DateTime& date, std::string& output) const noexcept;
120
127 void format(const anch::date::DateTime& date, std::ostream& output) const noexcept;
128
137 void parse(const std::string& strDate, anch::date::DateTime& date) const;
138
148 anch::date::DateTime parse(const std::string& strDate) const;
149
150 private:
156 void addFormatter(anch::date::IDatePartFormatter* formatter);
157 // Methods -
158
159 };
160
161} // anch::date
DateFormatter(const std::string &dateFormat)
void format(const anch::date::DateTime &date, std::string &output) const noexcept
DateFormatter(DateFormatter &&) noexcept=default
static void registerFormatterPart(const std::string &pattern, getInstance instGetter) noexcept
DateFormatter(const DateFormatter &)=delete
void parse(const std::string &strDate, anch::date::DateTime &date) const
Point in time.
Definition dateTime.hpp:89
Date and time part formatter interface.
Definition iDatePartFormatter.hpp:43
Dates namespace.
anch::date::IDatePartFormatter *(*) getInstance()
Definition dateFormatter.hpp:38
AnCH framework base namespace.
Definition app.hpp:30