Coverage Report

Created: 2025-10-12 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/contrib/x86_64-unknown-linux-gnu/include/ebml/EbmlSInteger.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
  \author Julien Coloos    <suiryc @ users.sf.net>
36
  \author Moritz Bunkus    <moritz @ bunkus.org>
37
*/
38
#ifndef LIBEBML_SINTEGER_H
39
#define LIBEBML_SINTEGER_H
40
41
#include <cassert>
42
43
#include "EbmlTypes.h"
44
#include "EbmlElement.h"
45
46
namespace libebml {
47
48
const int DEFAULT_INT_SIZE = 1; ///< optimal size stored
49
50
/*!
51
    \class EbmlSInteger
52
    \brief Handle all operations on a signed integer EBML element
53
*/
54
class EBML_DLL_API EbmlSInteger : public EbmlElement {
55
  public:
56
    EbmlSInteger();
57
    EbmlSInteger(int64 DefaultValue);
58
    EbmlSInteger(const EbmlSInteger & ElementToClone) = default;
59
60
0
    EbmlSInteger & operator = (int64 NewValue) {Value = NewValue; SetValueIsSet(); return *this;}
61
62
    /*!
63
      Set the default size of the integer (usually 1,2,4 or 8)
64
    */
65
0
        void SetDefaultSize(uint64 nDefaultSize = DEFAULT_INT_SIZE) override {EbmlElement::SetDefaultSize(nDefaultSize); SetSize_(nDefaultSize);}
66
67
0
    bool ValidateSize() const override {return IsFiniteSize() && (GetSize() <= 8);}
68
    filepos_t RenderData(IOCallback & output, bool bForceRender, bool bWithDefault = false) override;
69
    filepos_t ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA) override;
70
    filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false) override;
71
72
    bool IsSmallerThan(const EbmlElement *Cmp) const override;
73
74
    operator int8() const;
75
    operator int16() const;
76
    operator int32() const;
77
    operator int64() const;
78
79
    EbmlSInteger &SetValue(int64 NewValue);
80
    int64 GetValue() const;
81
82
0
    void SetDefaultValue(int64 aValue) {assert(!DefaultISset()); DefaultValue = aValue; SetDefaultIsSet();}
83
84
0
    int64 DefaultVal() const {assert(DefaultISset()); return DefaultValue;}
85
86
0
    bool IsDefaultValue() const override {
87
0
      return (DefaultISset() && Value == DefaultValue);
88
0
    }
89
90
#if defined(EBML_STRICT_API)
91
    private:
92
#else
93
    protected:
94
#endif
95
    int64 Value; /// The actual value of the element
96
    int64 DefaultValue;
97
};
98
99
} // namespace libebml
100
101
#endif // LIBEBML_SINTEGER_H