serialization/preprocessor.hpp

Go to the documentation of this file.
00001 /* $Id: preprocessor.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2003 by David White <dave@whitevine.net>
00004    Copyright (C) 2005 - 2012 by Guillaume Melquiond <guillaume.melquiond@gmail.com>
00005    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2 of the License, or
00010    (at your option) any later version.
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY.
00013 
00014    See the COPYING file for more details.
00015 */
00016 
00017 /** @file */
00018 
00019 #ifndef SERIALIZATION_PREPROCESSOR_HPP_INCLUDED
00020 #define SERIALIZATION_PREPROCESSOR_HPP_INCLUDED
00021 
00022 #include <iosfwd>
00023 #include <map>
00024 #include <vector>
00025 
00026 #include "game_errors.hpp"
00027 
00028 class config_writer;
00029 class config;
00030 
00031 struct preproc_define;
00032 typedef std::map< std::string, preproc_define > preproc_map;
00033 
00034 struct preproc_define
00035 {
00036     preproc_define() : value(), arguments(), textdomain(), linenum(0), location() {}
00037     explicit preproc_define(std::string const &val) : value(val), arguments(), textdomain(), linenum(0), location() {}
00038     preproc_define(std::string const &val, std::vector< std::string > const &args,
00039                    std::string const &domain, int line, std::string const &loc)
00040         : value(val), arguments(args), textdomain(domain), linenum(line), location(loc) {}
00041     std::string value;
00042     std::vector< std::string > arguments;
00043     std::string textdomain;
00044     int linenum;
00045     std::string location;
00046     void write(config_writer&, const std::string&) const;
00047     void write_argument(config_writer&, const std::string&) const;
00048     void read(const config&);
00049     void read_argument(const config &);
00050     static preproc_map::value_type read_pair(const config &);
00051     bool operator==(preproc_define const &) const;
00052     bool operator<(preproc_define const &) const;
00053     bool operator!=(preproc_define const &v) const { return !operator==(v); }
00054 };
00055 
00056 std::ostream& operator<<(std::ostream& stream, const preproc_define& def);
00057 
00058 struct preproc_config {
00059     struct error : public game::error {
00060         error(const std::string& message) : game::error(message) {}
00061     };
00062 };
00063 
00064 std::string lineno_string(const std::string &lineno);
00065 
00066 std::ostream& operator<<(std::ostream& stream, const preproc_map::value_type& def);
00067 
00068 /**
00069  * Function to use the WML preprocessor on a file.
00070  *
00071  * @param defines                 A map of symbols defined.
00072  *
00073  * @returns                       The resulting preprocessed file data.
00074  */
00075 std::istream *preprocess_file(std::string const &fname, preproc_map *defines = NULL);
00076 
00077 void preprocess_resource(const std::string& res_name, preproc_map *defines_map,
00078             bool write_cfg=false, bool write_plain_cfg=false, std::string target_directory="");
00079 
00080 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:09 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs