1
0
mirror of https://github.com/OlafvdSpek/ctemplate.git synced 2025-09-28 19:05:49 +08:00
This commit is contained in:
Olaf van der Spek 2016-06-04 15:53:24 +02:00
commit 0f8696333b
15 changed files with 29 additions and 37 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python2
#
# Copyright (c) 2008, Google Inc.
# All rights reserved.

View File

@ -19,13 +19,13 @@
#define GOOGLE_NAMESPACE ctemplate
/* the location of <unordered_map> or <hash_map> */
#define HASH_MAP_H <hash_map>
#define HASH_MAP_H <unordered_map>
/* the namespace of hash_map/hash_set */
#define HASH_NAMESPACE stdext
#define HASH_NAMESPACE std
/* the location of <unordered_set> or <hash_set> */
#define HASH_SET_H <hash_set>
#define HASH_SET_H <unordered_set>
/* Define to 1 if you have the <byteswap.h> header file. */
#undef HAVE_BYTESWAP_H

View File

@ -33,6 +33,8 @@
#ifndef TEMPLATE_FIND_PTR_H_
#define TEMPLATE_FIND_PTR_H_
#include <cstddef>
// NOTE: if you are statically linking the template library into your binary
// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
// as a compiler flag in your project file to turn off the dllimports.
@ -42,6 +44,13 @@
namespace ctemplate {
template <class T, class U>
const typename T::value_type* find_ptr0(const T& c, U v)
{
typename T::const_iterator i = c.find(v);
return i == c.end() ? NULL : &*i;
}
template <class T, class U>
typename T::value_type::second_type* find_ptr(T& c, U v)
{

View File

@ -45,7 +45,7 @@
#include <stdlib.h> // for NULL
#include <string.h> // for strcmp
#include <sys/types.h>
#include <hash_map>
#include <unordered_map>
#include <ctemplate/template_string.h> // for StringHash
// NOTE: if you are statically linking the template library into your binary
@ -131,12 +131,12 @@ class CTEMPLATE_DLL_DECL PerExpandData {
private:
#ifdef _MSC_VER
typedef stdext::hash_map<const char*, const void*, StringHash> DataMap;
typedef std::unordered_map<const char*, const void*, StringHash> DataMap;
#else
struct DataEq {
bool operator()(const char* s1, const char* s2) const;
};
typedef stdext::hash_map<const char*, const void*, StringHash, DataEq>
typedef std::unordered_map<const char*, const void*, StringHash, DataEq>
DataMap;
#endif

View File

@ -57,7 +57,7 @@ class PerExpandData;
}
#endif
namespace google_ctemplate_streamhtmlparser {
namespace ctemplate_htmlparser {
class HtmlParser;
}
@ -324,9 +324,6 @@ class CTEMPLATE_DLL_DECL Template {
static bool StringToTemplateCache(const TemplateString& key,
const char* content, Strip);
// INSTEAD, use ReloadAllIfChanged.
bool ReloadIfChanged();
protected:
friend class SectionTemplateNode; // for access to set_state(), ParseState
friend class TemplateTemplateNode; // for recursive call to Expand()
@ -439,7 +436,7 @@ class CTEMPLATE_DLL_DECL Template {
TemplateContext initial_context_;
// Non-null if the template was initialized in an Auto-Escape mode that
// requires a parser (currently TC_HTML, TC_CSS and TC_JS).
google_ctemplate_streamhtmlparser::HtmlParser *htmlparser_;
ctemplate_htmlparser::HtmlParser *htmlparser_;
// A sorted list of trusted variable names, declared here because a unittest
// needs to verify that it is appropriately sorted (an unsorted array would
@ -488,5 +485,4 @@ class CTEMPLATE_DLL_DECL Template {
}
#endif // CTEMPLATE_TEMPLATE_H_

View File

@ -138,5 +138,4 @@ class CTEMPLATE_DLL_DECL TextTemplateAnnotator : public TemplateAnnotator {
}
#endif // TEMPLATE_TEMPLATE_ANNOTATOR_H_

View File

@ -34,7 +34,7 @@
#ifndef TEMPLATE_TEMPLATE_CACHE_H_
#define TEMPLATE_TEMPLATE_CACHE_H_
#include <hash_map> // for stdext::hash_map<>
#include <unordered_map> // for std::unordered_map<>
#include <string> // for string
#include <utility> // for pair
#include <vector> // for vector<>
@ -288,9 +288,9 @@ class CTEMPLATE_DLL_DECL TemplateCache {
public:
typedef std::pair<TemplateId, int> TemplateCacheKey;
private:
typedef stdext::hash_map<TemplateCacheKey, CachedTemplate, TemplateCacheHash>
typedef std::unordered_map<TemplateCacheKey, CachedTemplate, TemplateCacheHash>
TemplateMap;
typedef stdext::hash_map<RefcountedTemplate*, int, RefTplPtrHash> TemplateCallMap;
typedef std::unordered_map<RefcountedTemplate*, int, RefTplPtrHash> TemplateCallMap;
// Where to search for files.
typedef std::vector<std::string> TemplateSearchPath;

View File

@ -236,10 +236,6 @@ class CTEMPLATE_DLL_DECL TemplateDictionary : public TemplateDictionaryInterface
__attribute__((__format__ (__printf__, 4, 5)))
#endif
; // starts at 4 because of implicit 1st arg 'this'
void SetEscapedValueAndShowSection(const TemplateString variable,
const TemplateString value,
const TemplateModifier& escfn,
const TemplateString section_name);
private:
@ -460,5 +456,4 @@ class CTEMPLATE_DLL_DECL TemplateDictionary : public TemplateDictionaryInterface
}
#endif // TEMPLATE_TEMPLATE_DICTIONARY_H_

View File

@ -145,5 +145,4 @@ class CTEMPLATE_DLL_DECL TemplateDictionaryInterface {
}
#endif // TEMPLATE_TEMPLATE_DICTIONARY_INTERFACE_H_

View File

@ -72,5 +72,4 @@ class CTEMPLATE_DLL_DECL StringEmitter : public ExpandEmitter {
}
#endif // TEMPLATE_TEMPLATE_EMITTER_H_

View File

@ -43,5 +43,4 @@ enum Strip { DO_NOT_STRIP, STRIP_BLANK_LINES, STRIP_WHITESPACE,
}
#endif // TEMPLATE_TEMPLATE_ENUMS_H_

View File

@ -348,10 +348,8 @@ bool AddModifier(const char* long_name, const TemplateModifier* modifier);
// is used in a different context (say Javascript) where this
// escaping may be inadequate.
extern CTEMPLATE_DLL_DECL
bool AddXssSafeModifier(const char* long_name,
const TemplateModifier* modifier);
bool AddXssSafeModifier(const char* long_name, const TemplateModifier* modifier);
}
#endif // TEMPLATE_TEMPLATE_MODIFIERS_H_

View File

@ -40,7 +40,7 @@
#define TEMPLATE_TEMPLATE_NAMELIST_H_
#include <time.h> // for time_t
#include <hash_set>
#include <unordered_set>
#include <string>
#include <vector>
#include <ctemplate/template_enums.h> // for Strip
@ -87,7 +87,7 @@ class CTEMPLATE_DLL_DECL TemplateNamelist {
// thing you should do with them is call size() and/or iterate
// between begin() and end(), and the only operations we promise
// the iterators will support are operator* and operator++.
typedef stdext::hash_set<std::string, StringHash> NameListType;
typedef std::unordered_set<std::string, StringHash> NameListType;
typedef std::vector<std::string> MissingListType;
typedef std::vector<std::string> SyntaxListType;
@ -165,5 +165,4 @@ class CTEMPLATE_DLL_DECL TemplateNamelist {
}
#endif // TEMPLATE_TEMPLATE_NAMELIST_H_

View File

@ -34,7 +34,7 @@
#define TEMPLATE_TEMPLATE_STRING_H_
#include <string.h> // for memcmp() and size_t
#include <hash_map>
#include <unordered_map>
#include <string>
#include <vector>
@ -142,7 +142,7 @@ struct CTEMPLATE_DLL_DECL StaticTemplateString {
} do_not_use_directly_;
// This class is a good hash_compare functor to pass in as the third
// argument to stdext::hash_map<>, when creating a map whose keys are
// argument to std::unordered_map<>, when creating a map whose keys are
// StaticTemplateString. NOTE: This class isn't that safe to use,
// because it requires that StaticTemplateStringInitializer has done
// its job. Unfortunately, even when you use the STS_INIT macro
@ -342,7 +342,7 @@ class CTEMPLATE_DLL_DECL StaticTemplateStringInitializer {
// Don't use this. This is used only in auto-generated .varnames.h files.
#define STS_INIT_WITH_HASH(name, str, hash_compare) \
{ { str, sizeof(""str"")-1, hash_compare } }; \
{ { str, sizeof("" str "")-1, hash_compare } }; \
namespace ctemplate_sts_init { \
static const ctemplate::StaticTemplateStringInitializer name##_init(&name); \
}
@ -359,5 +359,4 @@ const StaticTemplateString kStsEmpty =
}
#endif // TEMPLATE_TEMPLATE_STRING_H_

View File

@ -99,8 +99,8 @@ template class __declspec(dllexport) std::vector<std::string>;\n\
-e "s!@ac_windows_dllexport_defines@!$MY_DLLDEF_DEFINES!g" \
-e "s!@ac_cv_cxx_hash_map@!$HASH_MAP_H!g" \
-e "s!@ac_cv_cxx_hash_set@!$HASH_SET_H!g" \
-e "s!@ac_cv_cxx_hash_map_class@!$HASH_NAMESPACE::hash_map!g" \
-e "s!@ac_cv_cxx_hash_set_class@!$HASH_NAMESPACE::hash_set!g" \
-e "s!@ac_cv_cxx_hash_map_class@!$HASH_NAMESPACE::unordered_map!g" \
-e "s!@ac_cv_cxx_hash_set_class@!$HASH_NAMESPACE::unordered_set!g" \
-e "s!@ac_google_attribute@!${HAVE___ATTRIBUTE__:-0}!g" \
-e "s!@ac_google_end_namespace@!$_END_GOOGLE_NAMESPACE_!g" \
-e "s!@ac_google_namespace@!$GOOGLE_NAMESPACE!g" \