Coverage Report

Created: 2026-02-14 08:08

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/contrib/x86_64-unknown-linux-gnu/include/ebml/EbmlFloat.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 file is part of libebml.
9
**
10
** This library is free software; you can redistribute it and/or
11
** modify it under the terms of the GNU Lesser General Public
12
** License as published by the Free Software Foundation; either
13
** version 2.1 of the License, or (at your option) any later version.
14
**
15
** This library is distributed in the hope that it will be useful,
16
** but WITHOUT ANY WARRANTY; without even the implied warranty of
17
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
** Lesser General Public License for more details.
19
**
20
** You should have received a copy of the GNU Lesser General Public
21
** License along with this library; if not, write to the Free Software
22
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
**
24
** See http://www.gnu.org/licenses/lgpl-2.1.html for LGPL licensing information.
25
**
26
** Contact license@matroska.org if any conditions of this licensing are
27
** not clear to you.
28
**
29
**********************************************************************/
30
31
/*!
32
  \file
33
  \version \$Id$
34
  \author Steve Lhomme     <robux4 @ users.sf.net>
35
*/
36
#ifndef LIBEBML_FLOAT_H
37
#define LIBEBML_FLOAT_H
38
39
#include "EbmlTypes.h"
40
#include "EbmlElement.h"
41
42
namespace libebml {
43
44
/*!
45
    \class EbmlFloat
46
    \brief Handle all operations on a float EBML element
47
*/
48
class EBML_DLL_API EbmlFloat : public EbmlElement {
49
  public:
50
    enum Precision {
51
       FLOAT_32
52
      ,FLOAT_64
53
    };
54
55
    EbmlFloat(Precision prec = FLOAT_32);
56
    EbmlFloat(double DefaultValue, Precision prec = FLOAT_32);
57
    EbmlFloat(const EbmlFloat & ElementToClone) = default;
58
59
    bool ValidateSize() const override
60
0
    {
61
0
      return (GetSize() == 4 || GetSize() == 8);
62
0
    }
63
64
    filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false) override;
65
    filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) override;
66
    filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false) override;
67
68
    void SetPrecision(const EbmlFloat::Precision prec = FLOAT_32)
69
0
    {
70
0
      if (prec == FLOAT_64)
71
0
        SetSize_(8);
72
0
      else
73
0
        SetSize_(4); // default size
74
0
    }
75
76
77
//    EbmlFloat & operator=(const float NewValue) { Value = NewValue; return *this;}
78
0
    EbmlFloat & operator=(const double NewValue) { Value = NewValue; SetValueIsSet(); return *this;}
79
80
    bool IsSmallerThan(const EbmlElement *Cmp) const override;
81
82
    operator float() const;
83
    operator double() const;
84
85
    EbmlFloat &SetValue(double NewValue);
86
    double GetValue() const;
87
88
    void SetDefaultValue(double);
89
90
    double DefaultVal() const;
91
92
0
    bool IsDefaultValue() const override {
93
0
      return (DefaultISset() && Value == DefaultValue);
94
0
    }
95
96
#if defined(EBML_STRICT_API)
97
    private:
98
#else
99
    protected:
100
#endif
101
    double Value; /// The actual value of the element
102
    double DefaultValue;
103
};
104
105
} // namespace libebml
106
107
#endif // LIBEBML_FLOAT_H