00001 /* $Id: formula_string_utils.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 #ifndef FORMULA_STRING_UTILS_HPP_INCLUDED 00018 #define FORMULA_STRING_UTILS_HPP_INCLUDED 00019 00020 #include "serialization/string_utils.hpp" 00021 00022 class variable_set; 00023 00024 namespace utils { 00025 00026 /** 00027 * Function which will interpolate variables, starting with '$' in the string 00028 * 'str' with the equivalent symbols in the given symbol table. If 'symbols' 00029 * is NULL, then game event variables will be used instead. 00030 */ 00031 std::string interpolate_variables_into_string(const std::string &str, const string_map * const symbols); 00032 std::string interpolate_variables_into_string(const std::string &str, const variable_set& variables); 00033 00034 /** 00035 * Function that does the same as the above, for t_stringS. 00036 * If a change was made, then the t_string's translation is done in this 00037 * function, rather than at use. This limitation is due to the use of 00038 * create-time interpolation, rather than use-time. 00039 */ 00040 t_string interpolate_variables_into_tstring(const t_string &str, const variable_set& variables); 00041 00042 } 00043 00044 /** Handy wrappers around interpolate_variables_into_string and gettext. */ 00045 std::string vgettext(const char* msgid, const utils::string_map& symbols); 00046 std::string vgettext(const char* domain 00047 , const char* msgid 00048 , const utils::string_map& symbols); 00049 00050 std::string vngettext(const char*, const char*, int, const utils::string_map&); 00051 00052 /** 00053 * @todo Convert all functions. 00054 * 00055 * All function in this file should have an overloaded version with a domain 00056 * and probably convert all callers to use the macro instead of directly calling 00057 * the function. 00058 */ 00059 00060 #ifdef GETTEXT_DOMAIN 00061 #define VGETTEXT(msgid, symbols) vgettext(GETTEXT_DOMAIN, msgid, symbols) 00062 #else 00063 #define VGETTEXT(msgid, symbols) vgettext(msgid, symbols) 00064 #endif 00065 00066 #endif
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:51 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |