Gnash  0.8.11dev
DefineSceneAndFrameLabelDataTag.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 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 #ifndef GNASH_SWF_SCENEANDLABELTAG_H
20 #define GNASH_SWF_SCENEANDLABELTAG_H
21 
22 #include "ControlTag.h"
23 #include "SWF.h"
24 #include "MovieClip.h"
25 #include "SWFStream.h"
26 #include "log.h"
27 
28 #include <string>
29 #include <map>
30 
31 // Forward declarations
32 namespace gnash {
33  class movie_definition;
34 }
35 
36 namespace gnash {
37 namespace SWF {
38 
40 {
41 public:
42 
44  virtual void executeState(MovieClip* /*m*/, DisplayList& /* dlist */) const
45  {
46  log_unimpl("DefineSceneAndFrameLabelDataTag");
47  }
48 
49  static void loader(SWFStream& in, TagType tag, movie_definition& m,
50  const RunResources& /*r*/)
51  {
52  assert(tag == DEFINESCENEANDFRAMELABELDATA);
53 
54  if (!m.isAS3()) {
56  log_swferror("SWF contains DefineSceneAndFrameLabelData tag, "
57  "but is not an AS3 SWF!");
58  );
59  throw ParserException("DefineSceneAndFrameLabelData tag found in "
60  "non-AS3 SWF!");
61  }
62 
63  boost::intrusive_ptr<ControlTag> t(
65 
67  m.addControlTag(t);
68 
69  }
70 
71 private:
72 
74  {
75  read(in);
76  }
77 
78  void read(SWFStream& in) {
79 
80  std::uint32_t scenes = in.read_V32();
81 
82  IF_VERBOSE_PARSE(log_parse("Scene count: %d", scenes));
83 
84  for (size_t i = 0; i < scenes; ++i) {
85  std::uint32_t offset = in.read_V32();
86  std::string name;
87  in.read_string(name);
88  IF_VERBOSE_PARSE(log_parse("Offset %d name: %s", offset, name));
89  _scenes[offset] = name;
90  }
91 
92  std::uint32_t labels = in.read_V32();
93 
94  for (size_t i = 0; i < labels; ++i) {
95  std::uint32_t num = in.read_V32();
96  std::string label;
97  in.read_string(label);
98  IF_VERBOSE_PARSE(log_parse("Frame %d label: %s", num, label));
99  _frames[num] = label;
100  }
101 
102  }
103 
104  std::map<std::uint32_t, std::string> _scenes;
105  std::map<std::uint32_t, std::string> _frames;
106 
107 };
108 
109 } // namespace gnash::SWF
110 } // namespace gnash
111 
112 
113 #endif // GNASH_SWF_SYMBOLCLASSTAG_H
114 
115 
116 // Local Variables:
117 // mode: C++
118 // indent-tabs-mode: t
119 // End:
Client program&#39;s interface to the definition of a movie or sprite.
Definition: movie_definition.h:95
A MovieClip is a container for DisplayObjects.
Definition: MovieClip.h:83
static void loader(SWFStream &in, TagType tag, movie_definition &m, const RunResources &)
Definition: DefineSceneAndFrameLabelDataTag.h:49
void read_string(std::string &to)
Reads a null-terminated string from the given file and assigns it to the given std::string, overriding any previous value of it.
Definition: SWFStream.cpp:395
TagType
SWF tag types. Symbolic names copied from Ming.
Definition: SWF.h:30
An SWF parsing exception.
Definition: GnashException.h:89
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
#define IF_VERBOSE_MALFORMED_SWF(x)
Definition: log.h:404
#define IF_VERBOSE_PARSE(x)
Definition: log.h:378
Control tags are swf tags that control the operation of the movie.
Definition: ControlTag.h:43
void log_parse(StringType msg, Args... args)
Definition: log.h:313
Definition: GnashKey.h:166
std::uint32_t read_V32()
Read a variable length unsigned 32-bit value from the stream. These values continue until either the ...
Definition: SWFStream.h:191
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:53
virtual void executeState(MovieClip *, DisplayList &) const
TODO: implement this.
Definition: DefineSceneAndFrameLabelDataTag.h:44
void log_swferror(StringType msg, Args... args)
Definition: log.h:325
virtual bool isAS3() const
True if the SWFMovie should use AVM2.
Definition: movie_definition.h:410
Definition: GnashKey.h:155
Definition: GnashKey.h:159
Definition: DefineSceneAndFrameLabelDataTag.h:39
virtual void addControlTag(boost::intrusive_ptr< SWF::ControlTag >)
Add an ControlTag to this movie_definition&#39;s playlist.
Definition: movie_definition.h:273
A list of on-stage DisplayObjects, ordered by depth.
Definition: DisplayList.h:64
std::string name
Definition: LocalConnection_as.cpp:149
Definition: GnashKey.h:331
SWF stream wrapper class.
Definition: SWFStream.h:58