20 #include <boost/function.hpp>
21 #include <vlutil/vlStringUtil.h>
31 typedef boost::function<std::string (const char* module, const char* stringToTranslate)>
TranslationFunction;
68 virtual void printTo(DtOutputStream&)
const;
70 virtual void addTranslatableString(
const DtString&,
const DtString& module =
"DtRwTranslatableStringObject",
71 const DtString& originalString =
"");
72 virtual void addArgument(
const DtString&);
76 virtual std::string toFormattedString(
bool finalCR =
true)
const;
84 virtual std::vector<int> typesFrom(
const std::string& fmt, std::string& reformatted)
const;
93 unsigned int argsTranslated = 0;
97 std::vector<std::string> results;
104 if (results[0] ==
"translate")
107 std::string toTranslate = (*iterator.
current()).c_str();
108 if (results.size() >= 2)
112 if (results.size() == 3)
114 toTranslate = results[2];
122 std::string translated = (theTranslatorFunction)(module.c_str(), toTranslate.c_str()).c_str();
124 if (translated == toTranslate.c_str())
126 translated = (*iterator.
current()).c_str();
129 result += translated;
131 else if (results[0] ==
"argument")
135 const unsigned MaxStrSize = 511;
136 const unsigned MaxTruncated = 508;
137 if (result.length() > MaxStrSize)
139 result =
DtString(result.c_str(), MaxTruncated) +
"...";
141 else if (result.length() + iterator.
current()->length() > MaxStrSize)
143 unsigned maxSize = MaxTruncated - result.length();
145 result = DtReplaceSubstring(result,
"%1", truncated);
150 result = DtReplaceSubstring(result,
"%1", iterator.
current()->c_str());
155 result = DtReplaceSubstring(result,
"%" +
DtString(argsTranslated + 1),
"%1");
166 if (finalCR && (!result.length() || result[result.length() - 1] !=
'\n'))
177 static std::string defaultTranslationFunction(
const char* module,
const char* toTranslate) {
return toTranslate; };
bool operator==(const DtReaderWriter &) const
Equivalence operator.
virtual const char * readerWriterType() const
Used to supply a string type that this reader writer type is.
static void setTranslationFunction(TranslationFunction f)
Definition: rwTranslatableStringObject.h:174
virtual T * current()
Definition: iteratorBase.h:330
Definition: readerWriter.h:85
Definition: readerWriterRegistry.h:39
boost::function< std::string(const char *module, const char *stringToTranslate)> TranslationFunction
Definition: rwTranslatableStringObject.h:31
DtString translate(bool finalCR=true) const
Definition: rwTranslatableStringObject.h:89
virtual const char * xmlType() const
Definition: rwTranslatableStringObject.h:62
static TranslationFunction theTranslatorFunction
Definition: rwTranslatableStringObject.h:181
Description: DtIteratorBase is the base class for iterators used to iterate over a DtList...
Definition: iteratorBase.h:32
TranslationFunction translationFunction() const
Definition: rwTranslatableStringObject.h:175
const char * source
Definition: lz4.h:442
const char * c_str() const
DtRwTranslatableStringObject is a simple class that will keep track of strings that can be translated...
Definition: rwTranslatableStringObject.h:28
#define DT_DLL_vrfutil
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfutilDefines.h:34
const DtReaderWriter & operator=(const DtReaderWriter &orig)
assignment operator
static const char * theXmlType()
The type that is used when archiving to an XML stream.
bool operator!=(const DtReaderWriter &rhs)
Definition: readerWriter.h:121
virtual DtSymbolString name() const
Accessor for name of this readable/writable object.