1
0
mirror of https://github.com/OlafvdSpek/ctemplate.git synced 2025-09-28 19:05:49 +08:00

Refactor TemplateDictionary

This commit is contained in:
olafvdspek@gmail.com 2012-03-13 14:18:31 +00:00
parent 9bfe775524
commit 13219be215
3 changed files with 10 additions and 10 deletions

View File

@ -157,6 +157,9 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION

View File

@ -226,7 +226,7 @@ class @ac_windows_dllexport@ TemplateString {
// This returns true if s is in the .text segment of the binary.
// (Note this only checks .text of the main executable, not of
// shared libraries. So it may not be all that useful.)
// shared libraries. So it may not be all that useful.)
// This requires the gnu linker (and probably elf), to define
// _start and data_start.
static bool InTextSegment(const char* s) {

View File

@ -59,8 +59,6 @@ using std::map;
using std::pair;
using std::make_pair;
typedef long int64; // used with SetIntValue
_START_GOOGLE_NAMESPACE_
// Guards the initialization of the global dictionary.
@ -438,7 +436,7 @@ void TemplateDictionary::SetValueWithoutCopy(const TemplateString variable,
}
void TemplateDictionary::SetIntValue(const TemplateString variable,
int64 value) {
long value) {
char buffer[64]; // big enough for any int
int valuelen = snprintf(buffer, sizeof(buffer), "%ld", value);
LazilyCreateDict(&variable_dict_);
@ -447,9 +445,9 @@ void TemplateDictionary::SetIntValue(const TemplateString variable,
void TemplateDictionary::SetFormattedValue(const TemplateString variable,
const char* format, ...) {
char *scratch, *buffer;
char* buffer;
scratch = arena_->Alloc(1024); // StringAppendV requires >=1024 bytes
char* scratch = arena_->Alloc(1024); // StringAppendV requires >=1024 bytes
va_list ap;
va_start(ap, format);
const int buflen = StringAppendV(scratch, &buffer, format, ap);
@ -471,16 +469,15 @@ void TemplateDictionary::SetFormattedValue(const TemplateString variable,
void TemplateDictionary::SetEscapedValue(TemplateString variable,
TemplateString value,
const TemplateModifier& escfn) {
string escaped_string(escfn(value.ptr_, value.length_));
SetValue(variable, escaped_string);
SetValue(variable, string(escfn(value.data(), value.size())));
}
void TemplateDictionary::SetEscapedFormattedValue(TemplateString variable,
const TemplateModifier& escfn,
const char* format, ...) {
char *scratch, *buffer;
char* buffer;
scratch = arena_->Alloc(1024); // StringAppendV requires >=1024 bytes
char* scratch = arena_->Alloc(1024); // StringAppendV requires >=1024 bytes
va_list ap;
va_start(ap, format);
const int buflen = StringAppendV(scratch, &buffer, format, ap);