• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

sol.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
00003 // 
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017 
00018 #ifndef GNASH_SOL_H
00019 #define GNASH_SOL_H
00020 
00021 #include <boost/cstdint.hpp>
00022 #include <string>
00023 #include <vector>
00024 
00025 #include "dsodefs.h" //DSOEXPORT
00026 #include "amf.h"
00027 
00028 // It comprises of a magic number, followed by the file length, a
00029 // filetype, which appears to always be "TCSO", and what appears to be
00030 // a marker at the end of the header block.
00031 // After the SOL header, the rest is all AMF objects.
00032 
00033 // Magic Number - 2 bytes (always 0x00bf)
00034 // Length       - 4 bytes (the length of the file including the Marker bytes)
00035 // Marker       - 10 bytes (always "TCSO0x000400000000")
00036 // Object Name  - variable (the name of the object as an AMF encoded string)
00037 // Padding      - 4 bytes
00038 // After this is a series of AMF objects
00039 
00043 namespace cygnal
00044 {
00045 
00046 // Forward declarations
00047 class Element;
00048 
00053 class DSOEXPORT SOL {
00054 public:
00055     SOL();
00056     ~SOL();
00057 
00061     size_t size() const { return _amfobjs.size(); }
00062  
00063     size_t fileSize() const { return _filesize; }
00064 
00071     bool extractHeader(const std::vector<boost::uint8_t> &data);
00072 
00078     bool extractHeader(const std::string &filespec);
00079 
00086     bool formatHeader(const std::vector<boost::uint8_t> &data);
00087 
00093     bool formatHeader(const std::string &name);
00094 
00102     bool formatHeader(const std::string &name, int filesize);
00103 
00107     bool writeFile();
00108 
00116     bool writeFile(const std::string &filespec, const std::string &objname);
00117     
00123     bool readFile(const std::string &filespec);
00124 
00128     std::vector<boost::uint8_t> getHeader() { return _header; };
00129 
00131     //
00135     void addObj(boost::shared_ptr<Element> el);
00136 
00141     std::vector<boost::shared_ptr<cygnal::Element> > &getElements() { return _amfobjs; }
00142 
00148     boost::shared_ptr<Element> getElement(size_t size)
00149     {
00150         assert(size<_amfobjs.size());
00151         return _amfobjs[size];
00152     }
00153 
00161     void setFilespec(const std::string &filespec) { _filespec = filespec; };
00162 
00167     const std::string &getFilespec() const { return _filespec; };
00168 
00174     void setObjectName(const std::string &objname) { _objname = objname; };
00175 
00180     const std::string &getObjectName() const { return _objname; };
00181         
00182     bool updateSO(boost::shared_ptr<cygnal::Element> &el);
00183     bool updateSO(int index, boost::shared_ptr<cygnal::Element> &el);
00184     
00188     void dump();
00189 
00190  private:
00193     std::vector<boost::uint8_t> _header;
00194 
00197     std::vector<boost::uint8_t> _data;
00198 
00201     std::string      _objname;
00202 
00205     std::string      _filespec;
00206 
00209     int              _filesize;
00210 
00211  protected:
00214     std::vector<boost::shared_ptr<Element> > _amfobjs;
00215     
00216   };
00217 
00218  
00219 } // end of amf namespace
00220 
00221 // end of _SOL_H_
00222 #endif
00223 
00224 // local Variables:
00225 // mode: C++
00226 // indent-tabs-mode: t
00227 // End:

Generated on Thu Sep 30 2010 14:35:02 for Gnash by  doxygen 1.7.1