AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
dateFormatter.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 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 <http://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include <iostream>
23#include <map>
24#include <vector>
25#include <regex>
26
27#include "date/date.hpp"
28
29
30namespace anch::date {
31
33 typedef anch::date::IDatePartFormatter* (*getInstance)();
34
57
58 // Attributes +
59 private:
61 const static std::regex DATE_PATTERN;
62
64 std::vector<anch::date::IDatePartFormatter*> _formatters;
65
67 size_t _size;
68 // Attributes -
69
70 // Constructors +
71 public:
77 DateFormatter(const std::string& dateFormat) noexcept;
78 // Constructors -
79
80 // Destructor +
81 public:
85 virtual ~DateFormatter() noexcept;
86 // Destructor -
87
88 // Methods +
89 public:
96 static void registerFormatterPart(const std::string& pattern, getInstance instGetter) noexcept;
97
104 void format(const anch::date::Date& date, std::string& output) const noexcept;
105
112 void format(const anch::date::Date& date, std::ostream& output) const noexcept;
113
123 void parse(const std::string& strDate, anch::date::Date& date) const;
124
135 anch::date::Date* parse(const std::string& strDate) const;
136
137 private:
143 void addFormatter(const std::string& strFormatter) noexcept;
144 // Methods -
145
146 };
147
148} // anch::date
virtual ~DateFormatter() noexcept
void parse(const std::string &strDate, anch::date::Date &date) const
static void registerFormatterPart(const std::string &pattern, getInstance instGetter) noexcept
DateFormatter(const std::string &dateFormat) noexcept
void format(const anch::date::Date &date, std::string &output) const noexcept
Definition date.hpp:43
Definition iDatePartFormatter.hpp:35
Date namespace.
anch::date::IDatePartFormatter *(* getInstance)()
Definition dateFormatter.hpp:33
AnCH framework base namespace.
Definition app.hpp:28