vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / media / plugins / matroska / libebml / ebml / EbmlDate.h
blob7adefdd6d51256e97acaa9f51e8c3002cf359aea
1 /****************************************************************************
2 ** libebml : parse EBML files, see http://embl.sourceforge.net/
3 **
4 ** <file/class description>
5 **
6 ** Copyright (C) 2002-2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 ** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
24 ** Contact license@matroska.org if any conditions of this licensing are
25 ** not clear to you.
27 **********************************************************************/
29 /*!
30 \file
31 \version \$Id: EbmlDate.h 1079 2005-03-03 13:18:14Z robux4 $
32 \author Steve Lhomme <robux4 @ users.sf.net>
34 #ifndef LIBEBML_DATE_H
35 #define LIBEBML_DATE_H
37 #include "EbmlTypes.h"
38 #include "EbmlElement.h"
40 START_LIBEBML_NAMESPACE
42 /*!
43 \class EbmlDate
44 \brief Handle all operations related to an EBML date
46 class EBML_DLL_API EbmlDate : public EbmlElement {
47 public:
48 EbmlDate() :EbmlElement(8, false), myDate(0) {}
49 EbmlDate(const EbmlDate & ElementToClone);
51 /*!
52 \brief set the date with a UNIX/C/EPOCH form
53 \param NewDate UNIX/C date in UTC (no timezone)
55 void SetEpochDate(int32 NewDate) {bValueIsSet = true; myDate = int64(NewDate - UnixEpochDelay) * 1000000000; bValueIsSet = true;}
57 /*!
58 \brief get the date with a UNIX/C/EPOCH form
59 \note the date is in UTC (no timezone)
61 int32 GetEpochDate() const {return int32(myDate/1000000000 + UnixEpochDelay);}
63 bool ValidateSize() const {return ((Size == 8) || (Size == 0));}
65 /*!
66 \note no Default date handled
68 uint64 UpdateSize(bool bKeepIntact = false, bool bForceRender = false) {
69 if(!bValueIsSet)
70 Size = 0;
71 else
72 Size = 8;
73 return Size;
76 bool operator<(const EbmlDate & EltCmp) const {return myDate < EltCmp.myDate;}
78 uint64 ReadData(IOCallback & input, ScopeMode ReadFully = SCOPE_ALL_DATA);
80 bool IsDefaultValue() const {
81 return false;
84 protected:
85 uint32 RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact = false);
87 int64 myDate; ///< internal format of the date
89 static const uint64 UnixEpochDelay;
92 END_LIBEBML_NAMESPACE
94 #endif // LIBEBML_DATE_H