1
0
mirror of https://github.com/OlafvdSpek/ctemplate.git synced 2025-10-05 19:16:54 +08:00

Remove GOOGLE_NAMESPACE

This commit is contained in:
Olaf van der Spek 2017-01-04 11:57:36 +01:00
parent 936d6937a8
commit 0d0901ec95
17 changed files with 156 additions and 157 deletions

2
src/base/arena-inl.h Normal file → Executable file
View File

@ -138,7 +138,7 @@ template<class T, class C> const int ArenaAllocator<T, C>::kAlignment =
// 'new' must be in the global namespace.
}
using GOOGLE_NAMESPACE::UnsafeArena;
using ctemplate::UnsafeArena;
// Operators for allocation on the arena

View File

@ -135,8 +135,7 @@
/* define if first argument to InterlockedExchange is just LONG */
#undef INTERLOCKED_EXCHANGE_NONVOLATILE
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Name of package */

2
src/ctemplate/template_annotator.h.in Normal file → Executable file
View File

@ -47,7 +47,7 @@
// to.
//
// Template annotation is turned on and the template annotator subclass
// set by methods in @ac_google_namespace@::PerExpandData.
// set by methods in ctemplate::PerExpandData.
#ifndef TEMPLATE_TEMPLATE_ANNOTATOR_H_
#define TEMPLATE_TEMPLATE_ANNOTATOR_H_

2
src/ctemplate/template_namelist.h.in Normal file → Executable file
View File

@ -64,7 +64,7 @@ namespace ctemplate {
// TODO (we wish): Make this macro produce the #include for the auto-generated
// header files, when and if the macro pre-processor supports that
#define RegisterTemplateFilename(var, name) \
const char* const var = @ac_google_namespace@::TemplateNamelist::RegisterTemplate(name);
const char* const var = ctemplate::TemplateNamelist::RegisterTemplate(name);
// Class: TemplateNamelist
// Each time this class is instantiated, the name passed to

2
src/ctemplate/template_string.h.in Normal file → Executable file
View File

@ -339,7 +339,7 @@ class @ac_windows_dllexport@ StaticTemplateStringInitializer {
#define STS_INIT_WITH_HASH(name, str, hash) \
{ { str, sizeof("" str "")-1, hash } }; \
namespace ctemplate_sts_init { \
static const @ac_google_namespace@::StaticTemplateStringInitializer name##_init(&name); \
static const ctemplate::StaticTemplateStringInitializer name##_init(&name); \
}
// We computed this hash value for the empty string online. In debug

14
src/diff_tpl_auto_escape.cc Normal file → Executable file
View File

@ -82,12 +82,12 @@
#include <ctemplate/template_pathops.h>
using std::string;
using std::vector;
using GOOGLE_NAMESPACE::Template;
using GOOGLE_NAMESPACE::TemplateContext;
using GOOGLE_NAMESPACE::Strip;
using GOOGLE_NAMESPACE::STRIP_WHITESPACE;
using GOOGLE_NAMESPACE::STRIP_BLANK_LINES;
using GOOGLE_NAMESPACE::DO_NOT_STRIP;
using ctemplate::Template;
using ctemplate::TemplateContext;
using ctemplate::Strip;
using ctemplate::STRIP_WHITESPACE;
using ctemplate::STRIP_BLANK_LINES;
using ctemplate::DO_NOT_STRIP;
enum {LOG_VERBOSE, LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_FATAL};
@ -102,7 +102,7 @@ struct VariableAndMod {
};
typedef vector<VariableAndMod> VariableAndMods;
static string FLAG_template_dir(GOOGLE_NAMESPACE::kCWD); // "./"
static string FLAG_template_dir(ctemplate::kCWD); // "./"
static string FLAG_strip = ""; // cmd-line arg -s
static bool FLAG_verbose = false; // cmd-line arg -v

24
src/make_tpl_varnames_h.cc Normal file → Executable file
View File

@ -77,7 +77,7 @@
using std::set;
using std::string;
using std::vector;
using GOOGLE_NAMESPACE::Template;
using ctemplate::Template;
enum {LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_FATAL};
@ -243,14 +243,14 @@ static vector<string> SplitIntoLines(const string &input) {
//
// The header entries for ex1.tpl are:
// #include "template/template_string.h"
// static const ::GOOGLE_NAMESPACE::StaticTemplateString ke_USER =
// static const ::ctemplate::StaticTemplateString ke_USER =
// STS_INIT_WITH_HASH(ke_USER, "USER", 3254611514008215315LLU);
//
// The header entries for ex2.tpl are:
// #include "template/template_string.h"
// static const ::GOOGLE_NAMESPACE::StaticTemplateString ke_URL =
// static const ::ctemplate::StaticTemplateString ke_URL =
// STS_INIT_WITH_HASH(ke_URL, "URL", 1026025273225241985LLU);
// static const ::GOOGLE_NAMESPACE::StaticTemplateString ke_USER =
// static const ::ctemplate::StaticTemplateString ke_USER =
// STS_INIT_WITH_HASH(ke_USER, "USER", 3254611514008215315LLU);
//
// Simply concatenating both header entries will result in
@ -258,9 +258,9 @@ static vector<string> SplitIntoLines(const string &input) {
// the ke_USER variable. This function instead outputs:
//
// #include "template/template_string.h"
// static const ::GOOGLE_NAMESPACE::StaticTemplateString ke_USER =
// static const ::ctemplate::StaticTemplateString ke_USER =
// STS_INIT_WITH_HASH(ke_USER, "USER", 3254611514008215315LLU);
// static const ::GOOGLE_NAMESPACE::StaticTemplateString ke_URL =
// static const ::ctemplate::StaticTemplateString ke_URL =
// STS_INIT_WITH_HASH(ke_URL, "URL", 1026025273225241985LLU);
//
static string TextWithDuplicateLinesRemoved(const string& header_entries) {
@ -299,9 +299,9 @@ static bool WriteToDisk(bool log_info, const string& output_file,
}
int main(int argc, char **argv) {
string FLAG_template_dir(GOOGLE_NAMESPACE::kCWD); // "./"
string FLAG_header_dir(GOOGLE_NAMESPACE::kCWD);
GOOGLE_NAMESPACE::NormalizeDirectory(&FLAG_header_dir); // adds trailing slash
string FLAG_template_dir(ctemplate::kCWD); // "./"
string FLAG_header_dir(ctemplate::kCWD);
ctemplate::NormalizeDirectory(&FLAG_header_dir); // adds trailing slash
string FLAG_outputfile_suffix(".varnames.h");
string FLAG_outputfile("");
bool FLAG_header = true;
@ -378,7 +378,7 @@ int main(int argc, char **argv) {
// The last two arguments in the following call do not matter
// since they control how the template gets expanded and we never
// expand the template after loading it here
Template * tpl = Template::GetTemplate(tplname, GOOGLE_NAMESPACE::DO_NOT_STRIP);
Template * tpl = Template::GetTemplate(tplname, ctemplate::DO_NOT_STRIP);
// The call to GetTemplate (above) loads the template from disk
// and attempts to parse it. If it cannot find the file or if it
@ -443,9 +443,9 @@ int main(int argc, char **argv) {
it = template_records.begin(); it != template_records.end(); ++it) {
if ((*it)->error)
continue;
string basename = GOOGLE_NAMESPACE::Basename((*it)->name);
string basename = ctemplate::Basename((*it)->name);
string output_file =
GOOGLE_NAMESPACE::PathJoin(FLAG_header_dir,
ctemplate::PathJoin(FLAG_header_dir,
basename + FLAG_outputfile_suffix);
vector<string> template_filenames; // Contains one template filename.
template_filenames.push_back((*it)->name);

14
src/template.cc Normal file → Executable file
View File

@ -454,17 +454,17 @@ static bool FilenameValidForContext(const string& filename,
TemplateContext context) {
string stripped_filename = Basename(filename);
if (GOOGLE_NAMESPACE::ContainsFullWord(stripped_filename, "css") ||
GOOGLE_NAMESPACE::ContainsFullWord(stripped_filename, "stylesheet") ||
GOOGLE_NAMESPACE::ContainsFullWord(stripped_filename, "style")) {
if (ctemplate::ContainsFullWord(stripped_filename, "css") ||
ctemplate::ContainsFullWord(stripped_filename, "stylesheet") ||
ctemplate::ContainsFullWord(stripped_filename, "style")) {
if (context != TC_CSS) {
LOG(WARNING) << "Template filename " << filename
<< " indicates CSS but given TemplateContext"
<< " was not TC_CSS." << endl;
return false;
}
} else if (GOOGLE_NAMESPACE::ContainsFullWord(stripped_filename, "js") ||
GOOGLE_NAMESPACE::ContainsFullWord(stripped_filename, "javascript")) {
} else if (ctemplate::ContainsFullWord(stripped_filename, "js") ||
ctemplate::ContainsFullWord(stripped_filename, "javascript")) {
if (context != TC_JS) {
LOG(WARNING) << "Template filename " << filename
<< " indicates javascript but given TemplateContext"
@ -662,7 +662,7 @@ static void WriteOneHeaderEntry(
const TemplateId id = GlobalIdForSTS_INIT(TemplateString(variable));
std::ostringstream outstream;
outstream << "static const "
<< AS_STR(GOOGLE_NAMESPACE) << "::StaticTemplateString "
<< "::ctemplate::StaticTemplateString "
<< prefix << variable << " = STS_INIT_WITH_HASH("
<< prefix << variable << ", \"" << variable << "\", "
<< id << "ULL);\n";
@ -2381,7 +2381,7 @@ bool Template::StringToTemplateCache(const TemplateString& key,
// We say the insert succeeded only if it succeded for all strip values.
bool retval = true;
for (int i = 0; i < static_cast<int>(NUM_STRIPS); ++i) {
if (!GOOGLE_NAMESPACE::StringToTemplateCache(key, content, static_cast<Strip>(i)))
if (!ctemplate::StringToTemplateCache(key, content, static_cast<Strip>(i)))
retval = false;
}
return retval;

2
src/tests/htmlparser_cpp_test.cc Normal file → Executable file
View File

@ -86,7 +86,7 @@ using std::map;
using std::pair;
using std::string;
using std::vector;
using GOOGLE_NAMESPACE::PathJoin;
using ctemplate::PathJoin;
namespace ctemplate_htmlparser {

34
src/tests/template_cache_test.cc Normal file → Executable file
View File

@ -48,23 +48,23 @@
#include <ctemplate/template_string.h> // for TemplateString
#include "tests/template_test_util.h" // for AssertExpandIs(), etc
using std::string;
using GOOGLE_NAMESPACE::FLAGS_test_tmpdir;
using GOOGLE_NAMESPACE::AssertExpandIs;
using GOOGLE_NAMESPACE::CreateOrCleanTestDir;
using GOOGLE_NAMESPACE::CreateOrCleanTestDirAndSetAsTmpdir;
using GOOGLE_NAMESPACE::DO_NOT_STRIP;
using GOOGLE_NAMESPACE::PathJoin;
using GOOGLE_NAMESPACE::STRIP_BLANK_LINES;
using GOOGLE_NAMESPACE::STRIP_WHITESPACE;
using GOOGLE_NAMESPACE::StaticTemplateString;
using GOOGLE_NAMESPACE::StringToFile;
using GOOGLE_NAMESPACE::StringToTemplateCache;
using GOOGLE_NAMESPACE::StringToTemplateFile;
using GOOGLE_NAMESPACE::Template;
using GOOGLE_NAMESPACE::TemplateCache;
using GOOGLE_NAMESPACE::TemplateCachePeer;
using GOOGLE_NAMESPACE::TemplateDictionary;
using GOOGLE_NAMESPACE::kCWD;
using ctemplate::FLAGS_test_tmpdir;
using ctemplate::AssertExpandIs;
using ctemplate::CreateOrCleanTestDir;
using ctemplate::CreateOrCleanTestDirAndSetAsTmpdir;
using ctemplate::DO_NOT_STRIP;
using ctemplate::PathJoin;
using ctemplate::STRIP_BLANK_LINES;
using ctemplate::STRIP_WHITESPACE;
using ctemplate::StaticTemplateString;
using ctemplate::StringToFile;
using ctemplate::StringToTemplateCache;
using ctemplate::StringToTemplateFile;
using ctemplate::Template;
using ctemplate::TemplateCache;
using ctemplate::TemplateCachePeer;
using ctemplate::TemplateDictionary;
using ctemplate::kCWD;
#define ASSERT(cond) do { \
if (!(cond)) { \

44
src/tests/template_dictionary_unittest.cc Normal file → Executable file
View File

@ -48,16 +48,16 @@ TEST_INIT // defines RUN_ALL_TESTS
using std::string;
using std::vector;
using GOOGLE_NAMESPACE::UnsafeArena;
using GOOGLE_NAMESPACE::DO_NOT_STRIP;
using GOOGLE_NAMESPACE::ExpandEmitter;
using GOOGLE_NAMESPACE::PerExpandData;
using GOOGLE_NAMESPACE::StaticTemplateString;
using GOOGLE_NAMESPACE::StringToTemplateCache;
using GOOGLE_NAMESPACE::TemplateDictionary;
using GOOGLE_NAMESPACE::TemplateDictionaryInterface;
using GOOGLE_NAMESPACE::TemplateDictionaryPeer;
using GOOGLE_NAMESPACE::TemplateString;
using ctemplate::UnsafeArena;
using ctemplate::DO_NOT_STRIP;
using ctemplate::ExpandEmitter;
using ctemplate::PerExpandData;
using ctemplate::StaticTemplateString;
using ctemplate::StringToTemplateCache;
using ctemplate::TemplateDictionary;
using ctemplate::TemplateDictionaryInterface;
using ctemplate::TemplateDictionaryPeer;
using ctemplate::TemplateString;
#define ASSERT_STRSTR(text, substr) do { \
if (!strstr((text), (substr))) { \
@ -70,7 +70,7 @@ using GOOGLE_NAMESPACE::TemplateString;
// test escape-functor that replaces all input with "foo"
class FooEscaper : public GOOGLE_NAMESPACE::TemplateModifier {
class FooEscaper : public ctemplate::TemplateModifier {
public:
void Modify(const char* in, size_t inlen,
const PerExpandData*,
@ -81,7 +81,7 @@ class FooEscaper : public GOOGLE_NAMESPACE::TemplateModifier {
};
// test escape-functor that replaces all input with ""
class NullEscaper : public GOOGLE_NAMESPACE::TemplateModifier {
class NullEscaper : public ctemplate::TemplateModifier {
public:
void Modify(const char* in, size_t inlen,
const PerExpandData*,
@ -91,14 +91,14 @@ class NullEscaper : public GOOGLE_NAMESPACE::TemplateModifier {
};
// first does javascript-escaping, then html-escaping
class DoubleEscaper : public GOOGLE_NAMESPACE::TemplateModifier {
class DoubleEscaper : public ctemplate::TemplateModifier {
public:
void Modify(const char* in, size_t inlen,
const PerExpandData* data,
ExpandEmitter* outbuf, const string& arg) const {
assert(arg.empty()); // we don't take an argument
string tmp = GOOGLE_NAMESPACE::javascript_escape(in, inlen);
GOOGLE_NAMESPACE::html_escape.Modify(tmp.data(), tmp.size(), data, outbuf, "");
string tmp = ctemplate::javascript_escape(in, inlen);
ctemplate::html_escape.Modify(tmp.data(), tmp.size(), data, outbuf, "");
}
};
@ -236,12 +236,12 @@ TEST(TemplateDictionary, SetEscapedValue) {
dict.SetEscapedValue("hardest HTML",
"<A HREF='foo'\nid=\"bar\t\t&&\vbaz\">",
GOOGLE_NAMESPACE::html_escape);
ctemplate::html_escape);
dict.SetEscapedValue("hardest JS",
("f = 'foo';\r\n\tprint \"\\&foo = \b\", \"foo\""),
GOOGLE_NAMESPACE::javascript_escape);
ctemplate::javascript_escape);
dict.SetEscapedValue("query escape 0", "",
GOOGLE_NAMESPACE::url_query_escape);
ctemplate::url_query_escape);
EXPECT_TRUE(peer.ValueIs("hardest HTML",
"&lt;A HREF=&#39;foo&#39; id=&quot;bar &amp;&amp; "
@ -280,13 +280,13 @@ TEST(TemplateDictionary, SetEscapedFormattedValue) {
TemplateDictionary dict("test_SetEscapedFormattedValue", NULL);
TemplateDictionaryPeer peer(&dict);
dict.SetEscapedFormattedValue("HTML", GOOGLE_NAMESPACE::html_escape,
dict.SetEscapedFormattedValue("HTML", ctemplate::html_escape,
"This is <%s> #%.4f", "a & b", 1.0/3);
dict.SetEscapedFormattedValue("PRE", GOOGLE_NAMESPACE::pre_escape,
dict.SetEscapedFormattedValue("PRE", ctemplate::pre_escape,
"if %s x = %.4f;", "(a < 1 && b > 2)\n\t", 1.0/3);
dict.SetEscapedFormattedValue("URL", GOOGLE_NAMESPACE::url_query_escape,
dict.SetEscapedFormattedValue("URL", ctemplate::url_query_escape,
"pageviews-%s", "r?egex");
dict.SetEscapedFormattedValue("XML", GOOGLE_NAMESPACE::xml_escape,
dict.SetEscapedFormattedValue("XML", ctemplate::xml_escape,
"This&is%s -- ok?", "just&");
EXPECT_TRUE(peer.ValueIs("HTML",

30
src/tests/template_regtest.cc Normal file → Executable file
View File

@ -74,14 +74,14 @@ using std::vector;
using std::string;
using std::sort;
using GOOGLE_NAMESPACE::DO_NOT_STRIP;
using GOOGLE_NAMESPACE::PerExpandData;
using GOOGLE_NAMESPACE::STRIP_BLANK_LINES;
using GOOGLE_NAMESPACE::STRIP_WHITESPACE;
using GOOGLE_NAMESPACE::TC_HTML;
using GOOGLE_NAMESPACE::TC_MANUAL;
using GOOGLE_NAMESPACE::Template;
using GOOGLE_NAMESPACE::TemplateDictionary;
using ctemplate::DO_NOT_STRIP;
using ctemplate::PerExpandData;
using ctemplate::STRIP_BLANK_LINES;
using ctemplate::STRIP_WHITESPACE;
using ctemplate::TC_HTML;
using ctemplate::TC_MANUAL;
using ctemplate::Template;
using ctemplate::TemplateDictionary;
#define ASSERT(cond) do { \
if (!(cond)) { \
@ -231,7 +231,7 @@ static TemplateDictionary* MakeDict1() {
TemplateDictionary* fbt = dict->AddSectionDictionary("FOOTER_BAR_TEXT");
fbt->SetValue("BODY", "Should never be shown"); // this is part of simple
fbt->SetEscapedValue("HOME_LINK", "<b>Time to go home!</b>",
GOOGLE_NAMESPACE::html_escape);
ctemplate::html_escape);
// Note: you should never have code like this in real life! The <b>
// and </b> should be part of the template proper.
fbt->SetFormattedValue("ADVERTISE_LINK", "<b>Be advertiser #%d</b>", 2);
@ -285,7 +285,7 @@ static TemplateDictionary* MakeDict1() {
TemplateDictionary* inc2a = jfs2->AddIncludeDictionary("FAST_NEXT_JAVASCRIPT");
inc2a->SetFilename("template_unittest_test_simple.in");
inc2a->SetValue("HEAD", "include-head");
inc2a->SetEscapedFormattedValue("BODY", GOOGLE_NAMESPACE::html_escape,
inc2a->SetEscapedFormattedValue("BODY", ctemplate::html_escape,
"<b>%s</b>: %.4f", "<A HREF=/>", 1.0/3);
inc2a->SetValue("BI_NEWLINE", ""); // override the global default
TemplateDictionary* inc2b = jfs2->AddIncludeDictionary("FAST_NEXT_JAVASCRIPT");
@ -304,10 +304,10 @@ static TemplateDictionary* MakeDict1() {
foo->SetValue("BI_NEWLINE", "not gonna matter");
dict->SetEscapedValue("GOTO_MESSAGE", "print \"Go home\"",
GOOGLE_NAMESPACE::javascript_escape);
ctemplate::javascript_escape);
dict->SetEscapedValue("UPDATE", "monday & tuesday",
GOOGLE_NAMESPACE::html_escape);
ctemplate::html_escape);
dict->ShowSection("UPDATE_SECTION");
dict->SetValue("ALIGNMENT", "\"right\""); // all results sections see this
@ -318,7 +318,7 @@ static TemplateDictionary* MakeDict1() {
const char* res = "<&>\"result\" #%d'&'";
result->SetFormattedValue("RESULT", res, i);
result->SetEscapedFormattedValue("XML_RESULT",
GOOGLE_NAMESPACE::xml_escape,
ctemplate::xml_escape,
res, i);
result->SetIntValue("GOODNESS", i + 5);
}
@ -480,8 +480,8 @@ int main(int argc, char** argv) {
const char* template_rootdir = getenv("TEMPLATE_ROOTDIR");
if (template_rootdir == NULL)
template_rootdir = DEFAULT_TEMPLATE_ROOTDIR; // probably "."
string rootdir = GOOGLE_NAMESPACE::PathJoin(template_rootdir, "src");
rootdir = GOOGLE_NAMESPACE::PathJoin(rootdir, "tests");
string rootdir = ctemplate::PathJoin(template_rootdir, "src");
rootdir = ctemplate::PathJoin(rootdir, "tests");
Template::SetTemplateRootDirectory(rootdir);
vector<Testdata> testdata = ReadDataFiles(

6
src/tests/template_setglobals_unittest.cc Normal file → Executable file
View File

@ -38,15 +38,15 @@
#include "base/util.h"
TEST_INIT // defines RUN_ALL_TESTS()
using GOOGLE_NAMESPACE::Template;
using GOOGLE_NAMESPACE::TemplateDictionary;
using ctemplate::Template;
using ctemplate::TemplateDictionary;
TEST(SetGlobalValue, TemplateDictionary) {
// Test to see that the global dictionary object gets created when you
// first call the static function TemplateDictionary::SetGlobalValue().
TemplateDictionary::SetGlobalValue("TEST_GLOBAL_VAR", "test_value");
TemplateDictionary tpl("empty");
GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&tpl);
ctemplate::TemplateDictionaryPeer peer(&tpl);
EXPECT_STREQ(peer.GetSectionValue("TEST_GLOBAL_VAR"),
"test_value");

6
src/tests/template_test_util.h Normal file → Executable file
View File

@ -67,7 +67,7 @@ inline TemplateId GlobalIdForTest(const char* ptr, int len) {
// Call this to create a StaticTemplateString for testing when the ptr is
// not guaranteed to be allocated for the entire length of the test.
#define STS_INIT_FOR_TEST(ptr, len, arena) \
{ { arena->Memdup(ptr, len), len, GOOGLE_NAMESPACE::GlobalIdForTest(ptr, len) } };
{ { arena->Memdup(ptr, len), len, ctemplate::GlobalIdForTest(ptr, len) } };
extern const std::string FLAGS_test_tmpdir;
@ -119,8 +119,8 @@ class TemporaryRegisterTemplate {
explicit TemporaryRegisterTemplate(const char* name);
~TemporaryRegisterTemplate();
private:
GOOGLE_NAMESPACE::TemplateNamelist::NameListType* old_namelist_;
GOOGLE_NAMESPACE::TemplateNamelist::NameListType namelist_;
ctemplate::TemplateNamelist::NameListType* old_namelist_;
ctemplate::TemplateNamelist::NameListType namelist_;
// disallow copy constructor and assignment
TemporaryRegisterTemplate(const TemporaryRegisterTemplate&);

10
src/tests/template_test_util_test.cc Normal file → Executable file
View File

@ -44,12 +44,12 @@ TEST_INIT // defines RUN_ALL_TESTS()
using std::vector;
using std::string;
using GOOGLE_NAMESPACE::UnsafeArena;
using ctemplate::UnsafeArena;
using GOOGLE_NAMESPACE::TemplateDictionary;
using GOOGLE_NAMESPACE::TemplateDictionaryPeer;
using GOOGLE_NAMESPACE::TemplateString;
using GOOGLE_NAMESPACE::StaticTemplateString;
using ctemplate::TemplateDictionary;
using ctemplate::TemplateDictionaryPeer;
using ctemplate::TemplateString;
using ctemplate::StaticTemplateString;
namespace {

110
src/tests/template_unittest.cc Normal file → Executable file
View File

@ -62,42 +62,42 @@ TEST_INIT // defines RUN_ALL_TESTS()
using std::vector;
using std::string;
using GOOGLE_NAMESPACE::FLAGS_test_tmpdir;
using ctemplate::FLAGS_test_tmpdir;
using GOOGLE_NAMESPACE::AssertExpandIs;
using GOOGLE_NAMESPACE::AssertExpandWithDataIs;
using GOOGLE_NAMESPACE::CreateOrCleanTestDir;
using GOOGLE_NAMESPACE::CreateOrCleanTestDirAndSetAsTmpdir;
using GOOGLE_NAMESPACE::DO_NOT_STRIP;
using GOOGLE_NAMESPACE::ExpandEmitter;
using GOOGLE_NAMESPACE::IsAbspath;
using GOOGLE_NAMESPACE::Now;
using GOOGLE_NAMESPACE::PathJoin;
using GOOGLE_NAMESPACE::PerExpandData;
using GOOGLE_NAMESPACE::STRIP_BLANK_LINES;
using GOOGLE_NAMESPACE::STRIP_WHITESPACE;
using GOOGLE_NAMESPACE::StaticTemplateString;
using GOOGLE_NAMESPACE::StringToFile;
using GOOGLE_NAMESPACE::StringToTemplate;
using GOOGLE_NAMESPACE::StringToTemplateFile;
using GOOGLE_NAMESPACE::Strip;
using GOOGLE_NAMESPACE::TC_CSS;
using GOOGLE_NAMESPACE::TC_HTML;
using GOOGLE_NAMESPACE::TC_JS;
using GOOGLE_NAMESPACE::TC_JSON;
using GOOGLE_NAMESPACE::TC_MANUAL;
using GOOGLE_NAMESPACE::TC_UNUSED;
using GOOGLE_NAMESPACE::TC_XML;
using GOOGLE_NAMESPACE::Template;
using GOOGLE_NAMESPACE::TemplateContext;
using GOOGLE_NAMESPACE::TemplateDictionary;
using GOOGLE_NAMESPACE::TemplateNamelist;
using GOOGLE_NAMESPACE::TemplateString;
using GOOGLE_NAMESPACE::kRootdir;
using ctemplate::AssertExpandIs;
using ctemplate::AssertExpandWithDataIs;
using ctemplate::CreateOrCleanTestDir;
using ctemplate::CreateOrCleanTestDirAndSetAsTmpdir;
using ctemplate::DO_NOT_STRIP;
using ctemplate::ExpandEmitter;
using ctemplate::IsAbspath;
using ctemplate::Now;
using ctemplate::PathJoin;
using ctemplate::PerExpandData;
using ctemplate::STRIP_BLANK_LINES;
using ctemplate::STRIP_WHITESPACE;
using ctemplate::StaticTemplateString;
using ctemplate::StringToFile;
using ctemplate::StringToTemplate;
using ctemplate::StringToTemplateFile;
using ctemplate::Strip;
using ctemplate::TC_CSS;
using ctemplate::TC_HTML;
using ctemplate::TC_JS;
using ctemplate::TC_JSON;
using ctemplate::TC_MANUAL;
using ctemplate::TC_UNUSED;
using ctemplate::TC_XML;
using ctemplate::Template;
using ctemplate::TemplateContext;
using ctemplate::TemplateDictionary;
using ctemplate::TemplateNamelist;
using ctemplate::TemplateString;
using ctemplate::kRootdir;
using GOOGLE_NAMESPACE::ExpandTemplate;
using GOOGLE_NAMESPACE::ExpandWithData;
using GOOGLE_NAMESPACE::StringToTemplateCache;
using ctemplate::ExpandTemplate;
using ctemplate::ExpandWithData;
using ctemplate::StringToTemplateCache;
static const StaticTemplateString kHello = STS_INIT(kHello, "Hello");
static const StaticTemplateString kWorld = STS_INIT(kWorld, "World");
@ -270,7 +270,7 @@ static void AssertCorrectEscaping(TemplateContext template_type,
ASSERT_STREQ_VERBOSE(expected_out, outstring, text);
}
class DynamicModifier : public GOOGLE_NAMESPACE::TemplateModifier {
class DynamicModifier : public ctemplate::TemplateModifier {
public:
void Modify(const char* in, size_t inlen,
const PerExpandData* per_expand_data,
@ -283,7 +283,7 @@ class DynamicModifier : public GOOGLE_NAMESPACE::TemplateModifier {
}
};
class EmphasizeTemplateModifier : public GOOGLE_NAMESPACE::TemplateModifier {
class EmphasizeTemplateModifier : public ctemplate::TemplateModifier {
public:
EmphasizeTemplateModifier(const string& match)
: match_(match) {
@ -310,47 +310,47 @@ class EmphasizeTemplateModifier : public GOOGLE_NAMESPACE::TemplateModifier {
// TextTemplateAnnotator but just to test our ability to customize
// annotation, and with stateful one, it prefixes each text annotation
// with an event (call) count.
class CustomTestAnnotator : public GOOGLE_NAMESPACE::TextTemplateAnnotator {
class CustomTestAnnotator : public ctemplate::TextTemplateAnnotator {
public:
CustomTestAnnotator() : event_count_(0) { }
void Reset() { event_count_ = 0; }
virtual void EmitOpenInclude(ExpandEmitter* emitter, const string& value) {
EmitTestPrefix(emitter);
GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitOpenInclude(emitter, value);
ctemplate::TextTemplateAnnotator::EmitOpenInclude(emitter, value);
}
virtual void EmitCloseInclude(ExpandEmitter* emitter) {
EmitTestPrefix(emitter);
GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitCloseInclude(emitter);
ctemplate::TextTemplateAnnotator::EmitCloseInclude(emitter);
}
virtual void EmitOpenFile(ExpandEmitter* emitter, const string& value) {
EmitTestPrefix(emitter);
GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitOpenFile(emitter, value);
ctemplate::TextTemplateAnnotator::EmitOpenFile(emitter, value);
}
virtual void EmitCloseFile(ExpandEmitter* emitter) {
EmitTestPrefix(emitter);
GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitCloseFile(emitter);
ctemplate::TextTemplateAnnotator::EmitCloseFile(emitter);
}
virtual void EmitOpenSection(ExpandEmitter* emitter, const string& value) {
EmitTestPrefix(emitter);
GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitOpenSection(emitter, value);
ctemplate::TextTemplateAnnotator::EmitOpenSection(emitter, value);
}
virtual void EmitCloseSection(ExpandEmitter* emitter) {
EmitTestPrefix(emitter);
GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitCloseSection(emitter);
ctemplate::TextTemplateAnnotator::EmitCloseSection(emitter);
}
virtual void EmitOpenVariable(ExpandEmitter* emitter, const string& value) {
EmitTestPrefix(emitter);
GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitOpenVariable(emitter, value);
ctemplate::TextTemplateAnnotator::EmitOpenVariable(emitter, value);
}
virtual void EmitCloseVariable(ExpandEmitter* emitter) {
EmitTestPrefix(emitter);
GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitCloseVariable(emitter);
ctemplate::TextTemplateAnnotator::EmitCloseVariable(emitter);
}
virtual void EmitFileIsMissing(ExpandEmitter* emitter,
const string& value) {
EmitTestPrefix(emitter);
GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitFileIsMissing(emitter, value);
ctemplate::TextTemplateAnnotator::EmitFileIsMissing(emitter, value);
}
private:
@ -701,12 +701,12 @@ TEST(Template, VariableWithModifiers) {
AssertExpandIs(tpl, &dict, "hi yo_yo # <b>foo & bar</b> lo", true);
// Test with custom modifiers [regular or XssSafe should not matter].
ASSERT(GOOGLE_NAMESPACE::AddModifier("x-test",
&GOOGLE_NAMESPACE::html_escape));
ASSERT(GOOGLE_NAMESPACE::AddModifier("x-test-arg=",
&GOOGLE_NAMESPACE::html_escape));
ASSERT(GOOGLE_NAMESPACE::AddXssSafeModifier("x-test-arg=snippet",
&GOOGLE_NAMESPACE::snippet_escape));
ASSERT(ctemplate::AddModifier("x-test",
&ctemplate::html_escape));
ASSERT(ctemplate::AddModifier("x-test-arg=",
&ctemplate::html_escape));
ASSERT(ctemplate::AddXssSafeModifier("x-test-arg=snippet",
&ctemplate::snippet_escape));
tpl = StringToTemplate("hi {{VAR:x-test}} lo", STRIP_WHITESPACE);
AssertExpandIs(tpl, &dict, "hi yo&amp;yo lo", true);
@ -718,7 +718,7 @@ TEST(Template, VariableWithModifiers) {
// Test with a modifier taking per-expand data
DynamicModifier dynamic_modifier;
ASSERT(GOOGLE_NAMESPACE::AddModifier("x-dynamic", &dynamic_modifier));
ASSERT(ctemplate::AddModifier("x-dynamic", &dynamic_modifier));
PerExpandData per_expand_data;
tpl = StringToTemplate("hi {{VAR:x-dynamic}} lo", STRIP_WHITESPACE);
AssertExpandWithDataIs(tpl, &dict, &per_expand_data, "hi lo", true);
@ -1753,8 +1753,8 @@ TEST(Template, CorrectModifiersForAutoEscape) {
AssertCorrectModifiers(TC_JSON, text, "USER:h:j\n");
// 2i: Variables with XssSafe Custom modifiers are untouched.
ASSERT(GOOGLE_NAMESPACE::AddXssSafeModifier("x-test-cm",
&GOOGLE_NAMESPACE::html_escape));
ASSERT(ctemplate::AddXssSafeModifier("x-test-cm",
&ctemplate::html_escape));
text = "Hello {{USER:x-test-cm}}"; // Missing :h
AssertCorrectModifiers(TC_HTML, text, "USER:x-test-cm\n");
text = "Hello {{USER:x-test-cm:j}}"; // Extra :j

8
src/windows/port.cc Normal file → Executable file
View File

@ -1,10 +1,10 @@
/* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@ -102,7 +102,7 @@ void CreateOrCleanTestDir(const string& dirname) {
}
void GetNamelist(const char* testdata_dir, vector<string>* namelist) {
string glob(GOOGLE_NAMESPACE::PathJoin(testdata_dir,
string glob(ctemplate::PathJoin(testdata_dir,
"template_unittest_test*"));
WIN32_FIND_DATAA found; // that final A is for Ansi (as opposed to Unicode)
HANDLE hFind = FindFirstFileA(glob.c_str(), &found);