MWAWRSRCParser.hxx
Go to the documentation of this file.
00001 /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */
00002 
00003 /* libmwaw
00004 * Version: MPL 2.0 / LGPLv2+
00005 *
00006 * The contents of this file are subject to the Mozilla Public License Version
00007 * 2.0 (the "License"); you may not use this file except in compliance with
00008 * the License or as specified alternatively below. You may obtain a copy of
00009 * the License at http://www.mozilla.org/MPL/
00010 *
00011 * Software distributed under the License is distributed on an "AS IS" basis,
00012 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013 * for the specific language governing rights and limitations under the
00014 * License.
00015 *
00016 * Major Contributor(s):
00017 * Copyright (C) 2002 William Lachance (wrlach@gmail.com)
00018 * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
00019 * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch)
00020 * Copyright (C) 2006, 2007 Andrew Ziem
00021 * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr)
00022 *
00023 *
00024 * All Rights Reserved.
00025 *
00026 * For minor contributions see the git repository.
00027 *
00028 * Alternatively, the contents of this file may be used under the terms of
00029 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00030 * in which case the provisions of the LGPLv2+ are applicable
00031 * instead of those above.
00032 */
00033 
00034 #ifndef MWAW_RSRC_PARSER_H
00035 #define MWAW_RSRC_PARSER_H
00036 
00037 #include <map>
00038 #include <string>
00039 #include <vector>
00040 
00041 #include "libmwaw_internal.hxx"
00042 #include "MWAWDebug.hxx"
00043 
00046 class MWAWRSRCParser
00047 {
00048 public:
00049   struct Version;
00050 
00052   MWAWRSRCParser(MWAWInputStreamPtr input);
00054   ~MWAWRSRCParser();
00055 
00057   bool parse();
00058 
00060   MWAWInputStreamPtr getInput()
00061   {
00062     return m_input;
00063   }
00064 
00066   MWAWEntry getEntry(std::string type, int id) const;
00067 
00069   std::multimap<std::string, MWAWEntry> &getEntriesMap()
00070   {
00071     if (!m_parsed)
00072       parse();
00073     return m_entryMap;
00074   }
00076   std::multimap<std::string, MWAWEntry> const &getEntriesMap() const
00077   {
00078     if (!m_parsed)
00079       const_cast<MWAWRSRCParser *>(this)->parse();
00080     return m_entryMap;
00081   }
00082 
00084   bool parseSTR(MWAWEntry const &entry, std::string &str);
00085 
00087   bool parseSTRList(MWAWEntry const &entry, std::vector<std::string> &list);
00088 
00090   bool parsePICT(MWAWEntry const &entry, librevenge::RVNGBinaryData &pict);
00091 
00093   bool parseClut(MWAWEntry const &entry, std::vector<MWAWColor> &list);
00094 
00096   bool parseVers(MWAWEntry const &entry, Version &vers);
00097 
00099   void setAsciiName(char const *name)
00100   {
00101     m_asciiName = name;
00102   }
00104   std::string const &asciiName() const
00105   {
00106     return m_asciiName;
00107   }
00109   libmwaw::DebugFile &ascii()
00110   {
00111     return m_asciiFile;
00112   }
00113 protected:
00115   bool parseMap(MWAWEntry const &entry, long dataBegin);
00116 
00118   MWAWInputStreamPtr m_input;
00120   std::multimap<std::string, MWAWEntry> m_entryMap;
00122   bool m_parsed;
00124   libmwaw::DebugFile m_asciiFile;
00126   std::string m_asciiName;
00127 private:
00128   MWAWRSRCParser(MWAWRSRCParser const &orig);
00129   MWAWRSRCParser &operator=(MWAWRSRCParser const &orig);
00130 
00131 public:
00133   struct Version {
00134     Version() : m_majorVersion(-1), m_minorVersion(0), m_countryCode(0),
00135       m_string(""), m_versionString(""), m_extra("")
00136     {
00137     }
00139     friend std::ostream &operator<< (std::ostream &o, Version const &vers);
00141     int m_majorVersion;
00143     int m_minorVersion;
00145     int m_countryCode;
00147     std::string m_string;
00149     std::string m_versionString;
00151     std::string m_extra;
00152   };
00153 
00154 };
00155 
00156 #endif
00157 // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: