AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
iDatePartFormatter.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 <ostream>
24
25#include "date/date.hpp"
26
27
28namespace anch {
29 namespace date {
30 namespace formatter {
31
38 public:
43 // Nothing to do
44 }
45
52 virtual void format(const anch::date::Date& date, std::ostream& output) const noexcept = 0;
53
59 virtual std::size_t getSize() const noexcept = 0;
60
67 virtual bool setValue(anch::date::Date& date, const std::string& value) const noexcept = 0;
68
74 virtual const std::string& getPattern() const noexcept = 0;
75
76 // Accessors +
77 protected:
83 static int32_t getYear(const anch::date::Date& date);
84
91 static void setYear(anch::date::Date& date, int32_t year);
92
98 static uint16_t getMonth(const anch::date::Date& date);
99
106 static void setMonth(anch::date::Date& date, uint16_t month);
107
113 static uint16_t getDay(const anch::date::Date& date);
114
121 static void setDay(anch::date::Date& date, uint16_t mday);
122
128 static uint16_t getHour(const anch::date::Date& date);
129
136 static void setHour(anch::date::Date& date, uint16_t hour);
137
143 static uint16_t getMinute(const anch::date::Date& date);
144
151 static void setMinute(anch::date::Date& date, uint16_t minute);
152
158 static uint16_t getSecond(const anch::date::Date& date);
159
166 static void setSecond(anch::date::Date& date, uint16_t second);
167
173 static uint16_t getMillisecond(const anch::date::Date& date);
174
181 static void setMillisecond(anch::date::Date& date, uint16_t milli);
182
188 static uint16_t getMicrosecond(const anch::date::Date& date);
189
196 static void setMicrosecond(anch::date::Date& date, uint16_t micro);
197
203 static uint16_t getNanosecond(const anch::date::Date& date);
204
211 static void setNanosecond(anch::date::Date& date, uint16_t nano);
212 // Accessors -
213 };
214
215 inline int32_t IDatePartFormatter::getYear(const anch::date::Date& date) {
216 return date._years;
217 }
218
220 date._years = year;
221 }
222
224 return date._months;
225 }
226
227 inline void IDatePartFormatter::setMonth(anch::date::Date& date, uint16_t month) {
228 date._months = month;
229 }
230
232 return date._mdays;
233 }
234
235 inline void IDatePartFormatter::setDay(anch::date::Date& date, uint16_t mday) {
236 date._mdays = mday;
237 }
238
240 return date._hours;
241 }
242
243 inline void IDatePartFormatter::setHour(anch::date::Date& date, uint16_t hour) {
244 date._hours = hour;
245 }
246
248 return date._minutes;
249 }
250
251 inline void IDatePartFormatter::setMinute(anch::date::Date& date, uint16_t minute) {
252 date._minutes = minute;
253 }
254
256 return date._seconds;
257 }
258
259 inline void IDatePartFormatter::setSecond(anch::date::Date& date, uint16_t second) {
260 date._seconds = second;
261 }
262
264 return date._milliseconds;
265 }
266
268 date._milliseconds = milli;
269 }
270
272 return date._microseconds;
273 }
274
276 date._microseconds = micro;
277 }
278
280 return date._nanoseconds;
281 }
282
284 date._nanoseconds = nano;
285 }
286
287 }
288 }
289}
Definition date.hpp:45
Definition iDatePartFormatter.hpp:37
static uint16_t getMicrosecond(const anch::date::Date &date)
Definition iDatePartFormatter.hpp:271
static uint16_t getSecond(const anch::date::Date &date)
Definition iDatePartFormatter.hpp:255
static void setMicrosecond(anch::date::Date &date, uint16_t micro)
Definition iDatePartFormatter.hpp:275
static void setMonth(anch::date::Date &date, uint16_t month)
Definition iDatePartFormatter.hpp:227
static uint16_t getHour(const anch::date::Date &date)
Definition iDatePartFormatter.hpp:239
static void setDay(anch::date::Date &date, uint16_t mday)
Definition iDatePartFormatter.hpp:235
static uint16_t getDay(const anch::date::Date &date)
Definition iDatePartFormatter.hpp:231
static void setYear(anch::date::Date &date, int32_t year)
Definition iDatePartFormatter.hpp:219
static void setNanosecond(anch::date::Date &date, uint16_t nano)
Definition iDatePartFormatter.hpp:283
static uint16_t getNanosecond(const anch::date::Date &date)
Definition iDatePartFormatter.hpp:279
static void setMillisecond(anch::date::Date &date, uint16_t milli)
Definition iDatePartFormatter.hpp:267
virtual std::size_t getSize() const noexcept=0
static uint16_t getMonth(const anch::date::Date &date)
Definition iDatePartFormatter.hpp:223
static uint16_t getMinute(const anch::date::Date &date)
Definition iDatePartFormatter.hpp:247
virtual const std::string & getPattern() const noexcept=0
virtual void format(const anch::date::Date &date, std::ostream &output) const noexcept=0
virtual bool setValue(anch::date::Date &date, const std::string &value) const noexcept=0
static int32_t getYear(const anch::date::Date &date)
Definition iDatePartFormatter.hpp:215
static void setHour(anch::date::Date &date, uint16_t hour)
Definition iDatePartFormatter.hpp:243
virtual ~IDatePartFormatter()
Definition iDatePartFormatter.hpp:42
static void setSecond(anch::date::Date &date, uint16_t second)
Definition iDatePartFormatter.hpp:259
static uint16_t getMillisecond(const anch::date::Date &date)
Definition iDatePartFormatter.hpp:263
static void setMinute(anch::date::Date &date, uint16_t minute)
Definition iDatePartFormatter.hpp:251
Date formatter namespace.
Definition date.hpp:31
Date namespace.
AnCH framework base namespace.
Definition app.hpp:28