Coverage Report

Created: 2025-10-10 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/contrib/x86_64-unknown-linux-gnu/include/ebml/EbmlDate.h
Line
Count
Source
1
/****************************************************************************
2
** libebml : parse EBML files, see http://embl.sourceforge.net/
3
**
4
** <file/class description>
5
**
6
** Copyright (C) 2002-2010 Steve Lhomme.  All rights reserved.
7
**
8
** This library is free software; you can redistribute it and/or
9
** modify it under the terms of the GNU Lesser General Public
10
** License as published by the Free Software Foundation; either
11
** version 2.1 of the License, or (at your option) any later version.
12
**
13
** This library is distributed in the hope that it will be useful,
14
** but WITHOUT ANY WARRANTY; without even the implied warranty of
15
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
** Lesser General Public License for more details.
17
**
18
** You should have received a copy of the GNU Lesser General Public
19
** License along with this library; if not, write to the Free Software
20
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
**
22
** See http://www.gnu.org/licenses/lgpl-2.1.html for LGPL licensing information.
23
**
24
** Contact license@matroska.org if any conditions of this licensing are
25
** not clear to you.
26
**
27
**********************************************************************/
28
29
/*!
30
  \file
31
  \version \$Id$
32
  \author Steve Lhomme     <robux4 @ users.sf.net>
33
*/
34
#ifndef LIBEBML_DATE_H
35
#define LIBEBML_DATE_H
36
37
#include "EbmlTypes.h"
38
#include "EbmlElement.h"
39
40
namespace libebml {
41
42
/*!
43
    \class EbmlDate
44
    \brief Handle all operations related to an EBML date
45
*/
46
class EBML_DLL_API EbmlDate : public EbmlElement {
47
  public:
48
0
    EbmlDate() :EbmlElement(8, false) {}
49
    EbmlDate(const EbmlDate & ElementToClone);
50
51
    /*!
52
      \brief set the date with a UNIX/C/EPOCH form
53
      \param NewDate UNIX/C date in UTC (no timezone)
54
    */
55
0
    void SetEpochDate(int64 NewDate) {myDate = (NewDate - UnixEpochDelay) * 1000000000; SetValueIsSet();}
56
0
    EbmlDate &SetValue(int64 NewValue) {SetEpochDate(NewValue); return *this;}
57
58
    /*!
59
      \brief get the date with a UNIX/C/EPOCH form
60
      \note the date is in UTC (no timezone)
61
    */
62
517
    int64 GetEpochDate() const {return static_cast<int64>(myDate/1000000000 + UnixEpochDelay);}
63
0
    int64 GetValue() const {return GetEpochDate();}
64
65
0
    bool ValidateSize() const override {return IsFiniteSize() && ((GetSize() == 8) || (GetSize() == 0));}
66
67
    /*!
68
      \note no Default date handled
69
    */
70
0
    filepos_t UpdateSize(bool /* bWithDefault = false */, bool /* bForceRender = false */) override {
71
0
      if(!ValueIsSet())
72
0
        SetSize_(0);
73
0
      else
74
0
        SetSize_(8);
75
0
      return GetSize();
76
0
    }
77
78
    bool IsSmallerThan(const EbmlElement *Cmp) const override;
79
80
    filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) override;
81
82
0
    bool IsDefaultValue() const override {
83
0
      return false;
84
0
    }
85
86
#if defined(EBML_STRICT_API)
87
    private:
88
#else
89
    protected:
90
#endif
91
    filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false) override;
92
93
    int64 myDate{0}; ///< internal format of the date
94
95
    static const uint64 UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
96
};
97
98
} // namespace libebml
99
100
#endif // LIBEBML_DATE_H