Tawara  0.1.0
ebml_element.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, 2012, Geoffrey Biggs, geoffrey.biggs@aist.go.jp
5  * RT-Synthesis Research Group
6  * Intelligent Systems Research Institute,
7  * National Institute of Advanced Industrial Science and Technology (AIST),
8  * Japan
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  *
15  * * Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * * Redistributions in binary form must reproduce the above
18  * copyright notice, this list of conditions and the following
19  * disclaimer in the documentation and/or other materials provided
20  * with the distribution.
21  * * Neither the name of Geoffrey Biggs nor AIST, nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #if !defined(TAWARA_EBML_ELEMENT_H_)
40 #define TAWARA_EBML_ELEMENT_H_
41 
42 #include <tawara/el_ids.h>
43 #include <tawara/master_element.h>
44 #include <tawara/tawara_config.h>
45 #include <tawara/string_element.h>
46 #include <tawara/uint_element.h>
47 #include <tawara/win_dll.h>
48 
49 #include <string>
50 
53 
54 namespace tawara
55 {
64  {
65  public:
74  EBMLElement(std::string const& doc_type="tawara");
75 
77  virtual ~EBMLElement() {};
78 
85  unsigned int version() const { return ver_.value(); }
92  unsigned int read_version() const { return read_ver_.value(); }
98  unsigned int max_id_length() const
99  { return max_id_length_.value(); }
101  void max_id_length(unsigned int max_id_length)
102  { max_id_length_.value(max_id_length); }
108  unsigned int max_size_length() const
109  { return max_size_length_.value(); }
111  void max_size_length(unsigned int max_size_length)
112  { max_size_length_.value(max_size_length); }
118  std::string doc_type() const { return doc_type_.value(); }
120  void doc_type(std::string doc_type) { doc_type_.value(doc_type); }
125  unsigned int doc_version() const { return doc_type_ver_.value(); }
127  void doc_version(unsigned int doc_version)
128  { doc_type_ver_.value(doc_version); }
134  unsigned int doc_read_version() const
135  { return doc_type_read_ver_.value(); }
137  void doc_read_version(unsigned int doc_read_version)
138  { doc_type_read_ver_.value(doc_read_version); }
139 
141  virtual std::streamsize write_body(std::ostream& output);
142 
143  protected:
158 
160  virtual std::streamsize body_size() const;
161 
163  virtual std::streamsize read_body(std::istream& input,
164  std::streamsize size);
165 
167  void set_defaults_();
168  }; // class Element
169 }; // namespace tawara
170 
173 
174 #endif // TAWARA_EBML_ELEMENT_H_
175 
unsigned int read_version() const
Get the EBML read version.
Definition: ebml_element.h:92
UIntElement doc_type_ver_
Document type version.
Definition: ebml_element.h:155
virtual ~EBMLElement()
Destructor.
Definition: ebml_element.h:77
void doc_type(std::string doc_type)
Set the document type.
Definition: ebml_element.h:120
unsigned int doc_version() const
Get the document type version.
Definition: ebml_element.h:125
unsigned int version() const
Get the EBML version.
Definition: ebml_element.h:85
std::streamsize size(ID id)
Get the number of bytes required by an ID.
The EBML Header element.
Definition: ebml_element.h:63
#define TAWARA_EXPORT
Definition: win_dll.h:51
void doc_version(unsigned int doc_version)
Set the document type version.
Definition: ebml_element.h:127
UIntElement read_ver_
EBML minimum-version-to-read.
Definition: ebml_element.h:147
unsigned int max_id_length() const
Get the maximum ID length.
Definition: ebml_element.h:98
UIntElement ver_
EBML version.
Definition: ebml_element.h:145
The MasterElement interface.
UIntElement max_id_length_
Maximum ID length in bytes.
Definition: ebml_element.h:149
void max_id_length(unsigned int max_id_length)
Set the maximum ID length.
Definition: ebml_element.h:101
Unsigned integer primitive element.
Definition: uint_element.h:57
String primitive element.
std::string doc_type() const
Get the document type.
Definition: ebml_element.h:118
UIntElement doc_type_read_ver_
Minimum document type version necessary to read.
Definition: ebml_element.h:157
UIntElement max_size_length_
Maximum size length in bytes.
Definition: ebml_element.h:151
unsigned int doc_read_version() const
Get the minimum document type version to read.
Definition: ebml_element.h:134
StringElement doc_type_
EBML document type.
Definition: ebml_element.h:153
void doc_read_version(unsigned int doc_read_version)
Set the minimum required document type version.
Definition: ebml_element.h:137
unsigned int max_size_length() const
Get the maximum size length.
Definition: ebml_element.h:108
void max_size_length(unsigned int max_size_length)
Set the maximum size length.
Definition: ebml_element.h:111