Gnash  0.8.11dev
SWFParser.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 // The SWFMovieDefinition is the 'root' definition of a SWF movie, including
20 // movies loaded into another SWF file. Each self-contained SWF file has exactly
21 // one SWFMovieDefinition.
22 
23 #ifndef GNASH_SWFPARSER_H
24 #define GNASH_SWFPARSER_H
25 
26 #include "SWF.h"
27 
28 namespace gnash {
29  class SWFStream;
30  class movie_definition;
31  class RunResources;
32 }
33 
34 namespace gnash {
35 
36 
38 //
41 //
46 //
50 class SWFParser
51 {
52 
53 public:
54  SWFParser(SWFStream& in, movie_definition* md, const RunResources& runResources)
55  :
56  _stream(in),
57  _md(md),
58  _runResources(runResources),
59  _bytesRead(0),
60  _tagOpen(false),
61  _endRead(0),
62  _nextTagEnd(0),
63  _tag(SWF::END) // Initialized to zero to have a well known value
64 
65  {
66  }
67 
69  size_t bytesRead() const {
70  return _bytesRead;
71  }
72 
74  //
78  //
82  //
86  bool read(std::streamsize bytes);
87 
88 private:
89 
90  size_t openTag();
91 
92  void closeTag();
93 
94  SWFStream& _stream;
95 
96  movie_definition* _md;
97 
98  const RunResources& _runResources;
99 
100  size_t _bytesRead;
101 
102  bool _tagOpen;
103 
104  size_t _endRead;
105 
106  size_t _nextTagEnd;
107 
108  SWF::TagType _tag;
109 
110 };
111 
112 } // namespace gnash
113 
114 #endif
SWFParser.h
gnash::SWF::TagLoadersTable::TagLoader
void(* TagLoader)(SWFStream &input, TagType type, movie_definition &m, const RunResources &r)
Signature of an SWF tag loader.
Definition: TagLoadersTable.h:48
gnash::RunResources::tagLoaders
const SWF::TagLoadersTable & tagLoaders() const
Get the loader function table for parsing a SWF.
Definition: RunResources.h:126
gnash::SWF::TagType
TagType
SWF tag types. Symbolic names copied from Ming.
Definition: SWF.h:31
TagLoadersTable.h
_
#define _(String)
Definition: log.h:44
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::SWFStream::read
unsigned read(char *buf, unsigned count)
Read <count> bytes from the source stream and copy that data to <buf>.
Definition: SWFStream.cpp:68
gnash::SWF::SHOWFRAME
@ SHOWFRAME
Definition: SWF.h:33
gnash::movie_definition
Client program's interface to the definition of a movie or sprite.
Definition: movie_definition.h:96
gnash::SWFParser::bytesRead
size_t bytesRead() const
The number of bytes processed by this SWFParser.
Definition: SWFParser.h:69
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::SWFParser::read
bool read(std::streamsize bytes)
Parse a specified number of bytes from the stream.
Definition: SWFParser.cpp:51
gnash::SWFStream::open_tag
SWF::TagType open_tag()
Open an SWF tag and return it's type.
Definition: SWFStream.cpp:505
gnash::key::END
@ END
Definition: GnashKey.h:212
gnash::SWFStream::tell
unsigned long tell()
Return our current (byte) position in the input stream.
Definition: SWFStream.cpp:447
gnash::movie_definition::incrementLoadedFrames
virtual void incrementLoadedFrames()
Definition: movie_definition.h:148
gnash::ParserException
An SWF parsing exception.
Definition: GnashException.h:90
gnash::RunResources
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:54
gnash::SWFStream::close_tag
void close_tag()
Seek to the end of the most-recently-opened tag.
Definition: SWFStream.cpp:582
gnash::SWFStream::get_tag_end_position
unsigned long get_tag_end_position()
Return the file position of the end of the current tag.
Definition: SWFStream.cpp:497
IF_VERBOSE_PARSE
#define IF_VERBOSE_PARSE(x)
Definition: log.h:378
gnash::log_parse
void log_parse(StringType msg, Args... args)
Definition: log.h:313
log.h
gnash::SWF::TagLoadersTable::get
bool get(TagType t, TagLoader &lf) const
Get the TagLoader for a specified TagType.
Definition: TagLoadersTable.cpp:29
gnash::key::f
@ f
Definition: GnashKey.h:152
gnash::image::end
pixel_iterator< T > end(GnashImage &im)
Definition: ImageIterators.h:198
SWF.h
RunResources.h
movie_definition.h
gnash::SWF::TagLoadersTable
Table of SWF tags loaders.
Definition: TagLoadersTable.h:39
gnash::SWFParser::SWFParser
SWFParser(SWFStream &in, movie_definition *md, const RunResources &runResources)
Definition: SWFParser.h:54
gnash::SWFParser
The SWFParser parses tags from a SWFStream.
Definition: SWFParser.h:51
gnash::SWFStream
SWF stream wrapper class.
Definition: SWFStream.h:59
gnash::SWFStream::ensureBytes
void ensureBytes(unsigned long needed)
Ensure the requested number of bytes are available for an aligned read in the currently opened tag.
Definition: SWFStream.cpp:50
gnash::key::SWF
@ SWF
Definition: GnashKey.h:331
gnash::hexify
std::string hexify(const unsigned char *p, size_t length, bool ascii)
Convert a sequence of bytes to hex or ascii format.
Definition: log.cpp:48
SWFStream.h
gnash::key::e
@ e
Definition: GnashKey.h:151
gnash::SWF::END
@ END
Definition: SWF.h:32