本文整理汇总了C++中TString::append方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::append方法的具体用法?C++ TString::append怎么用?C++ TString::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visitAggregate
bool TConstTraverser::visitAggregate(Visit visit, TIntermAggregate* node)
{
if (!node->isConstructor() && node->getOp() != EOpComma) {
TString buf;
buf.append("'constructor' : assigning non-constant to ");
buf.append(type.getCompleteString());
infoSink.info.message(EPrefixError, node->getLine(), buf.c_str());
error = true;
return false;
}
if (node->getSequence().size() == 0) {
error = true;
return false;
}
bool flag = node->getSequence().size() == 1 && node->getSequence()[0]->getAsTyped()->getAsConstantUnion();
if (flag)
{
singleConstantParam = true;
constructorType = node->getOp();
size = node->getType().getObjectSize();
if (node->getType().isMatrix()) {
isMatrix = true;
matrixSize = node->getType().getNominalSize();
}
}
for (TIntermSequence::iterator p = node->getSequence().begin();
p != node->getSequence().end(); p++) {
if (node->getOp() == EOpComma)
index = 0;
(*p)->traverse(this);
}
if (flag)
{
singleConstantParam = false;
constructorType = EOpNull;
size = 0;
isMatrix = false;
matrixSize = 0;
}
return false;
}
示例2: visitBinary
bool TConstTraverser::visitBinary(Visit visit, TIntermBinary* node)
{
TQualifier qualifier = node->getType().getQualifier();
if (qualifier != EvqConst) {
TString buf;
buf.append("'constructor' : assigning non-constant to ");
buf.append(type.getCompleteString());
infoSink.info.message(EPrefixError, node->getLine(), buf.c_str());
error = true;
return false;
}
infoSink.info.message(EPrefixInternalError, node->getLine(), "Binary Node found in constant constructor");
return false;
}
示例3: DefaultPrecisionFragment
//============================================================================
//
// Default precision for fragment shaders.
//
//============================================================================
static TString DefaultPrecisionFragment()
{
TString s;
s.append(TString("precision mediump int;"));
// No default precision for float in fragment shaders
return s;
}
示例4: GetString
//Return the complete callstack in a continuous string
TString Stackage::GetString()
{
vector<TCHAR*>::iterator it;
TString stack;
TString separator = TEXT(" -> ");
//Build Stack String
for(it=vStack.begin(); it!=vStack.end(); ++it)
{
stack.append(*it);
stack.append(separator);
}
//Remove last separator
if(stack.length() >= separator.length())
stack.erase(stack.end() - separator.length(), stack.end());
return stack;
}
示例5: BuiltInFunctionsVertex
//============================================================================
//
// Prototypes for built-in functions seen by vertex shaders only.
//
//============================================================================
static TString BuiltInFunctionsVertex(const ShBuiltInResources& resources)
{
TString s;
//
// Geometric Functions.
//
//s.append(TString("vec4 ftransform();"));
//
// Texture Functions.
//
if (resources.MaxVertexTextureImageUnits > 0) {
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);"));
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);"));
s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));
s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));
}
return s;
}
示例6: SaveCacheFile
void CEnumStrGenerator::SaveCacheFile(const TCHAR* pszCacheFileName)
{
CSerializer serializer;
serializer << m_enumStrPool.size();
std::map<TString, SEnumScanData*>::iterator iter = m_enumStrPool.begin();
for (; iter != m_enumStrPool.end(); ++iter)
{
serializer << iter->first;
serializer << iter->second->m_enumFilePath;
serializer << iter->second->m_enumValue.size();
for (uint32_t i = 0; i < iter->second->m_enumValue.size(); ++i)
{
serializer << iter->second->m_enumValue[i]->m_str;
serializer << iter->second->m_enumValue[i]->m_value;
}
}
TString fullPathStr = CFilePathTool::GetInstance()->ParentPath(CUtilityManager::GetInstance()->GetModuleFileName().c_str());
fullPathStr.append(_T("/")).append(pszCacheFileName);
serializer.Deserialize(fullPathStr.c_str());
}
示例7: StandardUniforms
//============================================================================
//
// Standard uniforms.
//
//============================================================================
static TString StandardUniforms()
{
TString s;
//
// Depth range in window coordinates
//
s.append(TString("struct gl_DepthRangeParameters {"));
s.append(TString(" highp float near;")); // n
s.append(TString(" highp float far;")); // f
s.append(TString(" highp float diff;")); // f - n
s.append(TString("};"));
s.append(TString("uniform gl_DepthRangeParameters gl_DepthRange;"));
return s;
}
示例8: SaveLanguageListToFile
void CLanguageManager::SaveLanguageListToFile()
{
std::map<TString, std::map<ELanguageType, TString> >& languageMap = CLanguageManager::GetInstance()->GetLanguageMap();
rapidxml::xml_document<> doc;
rapidxml::xml_node<>* pLanguageRootNode = doc.allocate_node(rapidxml::node_element, "Language");
doc.append_node(pLanguageRootNode);
TCHAR szBuffer[256];
_stprintf(szBuffer, "%d", languageMap.size());
pLanguageRootNode->append_attribute(doc.allocate_attribute("Count", doc.allocate_string(szBuffer)));
for (auto iter = languageMap.begin(); iter != languageMap.end(); ++iter)
{
rapidxml::xml_node<>* pLanguageNode = doc.allocate_node(rapidxml::node_element, "LanguageNode");
pLanguageNode->append_attribute(doc.allocate_attribute("Enum", doc.allocate_string(iter->first.c_str())));
TString strTagValue;
if (m_languageTagMap.find(iter->first) != m_languageTagMap.end())
{
strTagValue = m_languageTagMap[iter->first];
}
pLanguageNode->append_attribute(doc.allocate_attribute("Tag", doc.allocate_string(strTagValue.c_str())));
for (int nCounter = 0; nCounter < eLT_Count; ++nCounter)
{
auto subIter = iter->second.find((ELanguageType)nCounter);
if (subIter != iter->second.end() && subIter->second.length() > 0)
{
rapidxml::xml_node<>* pLanguageTypeNode = doc.allocate_node(rapidxml::node_element, pszLanguageTypeString[nCounter]);
pLanguageTypeNode->append_attribute(doc.allocate_attribute("Value", doc.allocate_string(subIter != iter->second.end() ? subIter->second.c_str() : "")));
pLanguageNode->append_node(pLanguageTypeNode);
}
}
pLanguageRootNode->append_node(pLanguageNode);
}
TString filePath = CResourceManager::GetInstance()->GetResourcePath(eRT_Resource);
filePath.append(_T("/LanguageConfig.xml"));
TString strOut;
rapidxml::print(std::back_inserter(strOut), doc, 0);
std::ofstream out(filePath.c_str());
out << strOut;
out.close();
}
示例9: UpdateDirectoryCache
void CSpyUserPanel::UpdateDirectoryCache(const SDirectory* pDirectory)
{
BEATS_ASSERT(m_pRootDirectoryCache, _T("The cache mustn't be NULL!"));
std::vector<TString> result;
CStringHelper::GetInstance()->SplitString(pDirectory->m_szPath.c_str(), _T("/"), result, false);
SDirectory* pCurCache = m_pRootDirectoryCache;
TString strCurPath;
for (uint32_t i = 0; i < result.size(); ++i)
{
strCurPath.append(result[i]).append(_T("/"));
SDirectory* pChildDirectory = pCurCache->GetChild(strCurPath);
if (pChildDirectory == NULL)
{
// Add a place holder directory to build the path.
pChildDirectory = new SDirectory(NULL, strCurPath.c_str());
pCurCache->m_pDirectories->push_back(pChildDirectory);
}
// if the cache is a place holder, reset the parent to indicate that it is updated.
if (i == result.size() - 1 && pChildDirectory->m_pParent == NULL)
{
pChildDirectory->m_pParent = pCurCache;
}
pCurCache = pChildDirectory;
}
//1. Sync the child directories data.
BEATS_ASSERT(pDirectory->m_szPath == pCurCache->m_szPath, _T("The cache path must be the same with it!"));
for (uint32_t i = 0; i < pDirectory->m_pDirectories->size(); ++i)
{
SDirectory* pChildDirectory = pDirectory->m_pDirectories->at(i);
SDirectory* pCacheChildDirectory = pCurCache->GetChild(pChildDirectory->m_szPath);
if (pCacheChildDirectory == NULL)
{
// Add new child of the cache, which are also place holders.
pCacheChildDirectory = new SDirectory(NULL, pChildDirectory->m_szPath.c_str());
pCurCache->m_pDirectories->push_back(pCacheChildDirectory);
}
memcpy(&pCacheChildDirectory->m_data, &pChildDirectory->m_data, sizeof(WIN32_FIND_DATA));
}
// Delete the redundant child of the cache.
if (pCurCache->m_pDirectories->size() > pDirectory->m_pDirectories->size())
{
for (std::vector<SDirectory*>::iterator iter = pCurCache->m_pDirectories->begin(); iter != pCurCache->m_pDirectories->end(); )
{
SDirectory* pChild = pDirectory->GetChild((*iter)->m_szPath);
if (pChild == NULL)
{
BEATS_SAFE_DELETE(*iter);
iter = pCurCache->m_pDirectories->erase(iter);
}
else
{
++iter;
}
}
}
// 2. Sync the files data.
int iSizeDelta = pCurCache->m_pFileList->size() - pDirectory->m_pFileList->size();
for (int i = 0; i < iSizeDelta; ++i)
{
WIN32_FIND_DATA* pData = pCurCache->m_pFileList->back();
BEATS_SAFE_DELETE(pData);
pCurCache->m_pFileList->pop_back();
}
for (int i = 0; i < -iSizeDelta; ++i)
{
WIN32_FIND_DATA* pData = new WIN32_FIND_DATA;
pCurCache->m_pFileList->push_back(pData);
}
BEATS_ASSERT(pCurCache->m_pFileList->size() == pDirectory->m_pFileList->size(), _T("The data size must be the same now!"));
for (uint32_t i = 0; i < pCurCache->m_pFileList->size(); ++i)
{
memcpy(pCurCache->m_pFileList->at(i), pDirectory->m_pFileList->at(i), sizeof(WIN32_FIND_DATA));
}
}
示例10: OnSpySelectFileCtrlMenu
void CSpyUserPanel::OnSpySelectFileCtrlMenu(wxMenuEvent& event)
{
switch (event.GetId())
{
case eSUPUIID_DownloadMenu:
{
TString strStorePath;
if (CUtilityManager::GetInstance()->AcquireDirectory(this->GetHWND(), strStorePath, _T("选择保存的位置")))
{
typedef bool (*TDownloadFileFunc)(SOCKET sock, const std::vector<TString>& files, const TString& strStorePath, CFileFilter* pFilter);
static TDownloadFileFunc pDownloadFunc = TDownloadFileFunc(GetProcAddress(m_hSpyDllHandle, "Spy_DownloadFiles"));
BEATS_ASSERT(pDownloadFunc != NULL, _T("Get function address %s failed!"), _T("Spy_DownloadFiles"));
if (pDownloadFunc != NULL)
{
std::vector<TString> files;
uint32_t uSelectedCount = m_pRemoteFileCtrl->GetSelectedItemCount();
if (uSelectedCount == 0)
{
const TString& curPath = m_pRemoteFileCtrl->GetCurrentDirectoryPath();
if (curPath.length() > 0)
{
files.push_back(curPath);
}
}
else
{
uint32_t uCounter = 0;
long item = m_pRemoteFileCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
while ( item != -1 && uCounter++ < uSelectedCount )
{
TString curPath = m_pRemoteFileCtrl->GetCurrentDirectoryPath();
files.push_back(curPath.append(m_pRemoteFileCtrl->GetItemText(item)));
item = m_pRemoteFileCtrl->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
}
}
BEATS_ASSERT(files.size() > 0, _T("Can't start download with nothing!"));
if (files.size() > 0 && strStorePath.length() > 0)
{
pDownloadFunc(m_pSocketInfo->m_socket, files, strStorePath, NULL);
}
}
}
}
break;
case eSUPUIID_UploadMenu:
{
std::vector<TString> strPath;
bool bGetUploadFiles = CUtilityManager::GetInstance()->AcquireMuiltyFilePath(true, this->GetHWND(), strPath, _T("选择上传的文件"), NULL, NULL);
if (bGetUploadFiles)
{
typedef bool (*TUploadFileFunc)(SOCKET sock, const std::vector<TString>& files, const TString& strStorePath, CFileFilter* pFilter);
static TUploadFileFunc pUploadFunc = TUploadFileFunc(GetProcAddress(m_hSpyDllHandle, "Spy_UploadFiles"));
BEATS_ASSERT(pUploadFunc != NULL, _T("Get function address %s failed!"), _T("Spy_DownloadFiles"));
if (pUploadFunc != NULL)
{
TString curPath = m_pRemoteFileCtrl->GetCurrentDirectoryPath();
BEATS_ASSERT(curPath.length() > 0 && strPath.size() > 0, _T("Upload failed! upload files size: %d store path: %s"), strPath.size(), curPath.c_str());
if (curPath.length() > 0 && strPath.size() > 0)
{
pUploadFunc(m_pSocketInfo->m_socket, strPath, curPath, NULL);
}
else
{
MessageBox(this->GetHWND(), _T("Current path is not valid!"), NULL, MB_OK);
}
}
}
}
break;
default:
BEATS_ASSERT(false, _T("Never Reach Here!"));
break;
}
}
示例11: BuiltInFunctionsFragment
//============================================================================
//
// Prototypes for built-in functions seen by fragment shaders only.
//
//============================================================================
static TString BuiltInFunctionsFragment(const ShBuiltInResources& resources)
{
TString s;
//
// Texture Functions.
//
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord, float bias);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);"));
s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);"));
s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);"));
if (resources.OES_standard_derivatives) {
s.append(TString("float dFdx(float p);"));
s.append(TString("vec2 dFdx(vec2 p);"));
s.append(TString("vec3 dFdx(vec3 p);"));
s.append(TString("vec4 dFdx(vec4 p);"));
s.append(TString("float dFdy(float p);"));
s.append(TString("vec2 dFdy(vec2 p);"));
s.append(TString("vec3 dFdy(vec3 p);"));
s.append(TString("vec4 dFdy(vec4 p);"));
s.append(TString("float fwidth(float p);"));
s.append(TString("vec2 fwidth(vec2 p);"));
s.append(TString("vec3 fwidth(vec3 p);"));
s.append(TString("vec4 fwidth(vec4 p);"));
}
return s;
}
示例12: BuiltInFunctionsCommon
//============================================================================
//
// Prototypes for built-in functions seen by both vertex and fragment shaders.
//
//============================================================================
static TString BuiltInFunctionsCommon()
{
TString s;
//
// Angle and Trigonometric Functions.
//
s.append(TString("float radians(float degrees);"));
s.append(TString("vec2 radians(vec2 degrees);"));
s.append(TString("vec3 radians(vec3 degrees);"));
s.append(TString("vec4 radians(vec4 degrees);"));
s.append(TString("float degrees(float radians);"));
s.append(TString("vec2 degrees(vec2 radians);"));
s.append(TString("vec3 degrees(vec3 radians);"));
s.append(TString("vec4 degrees(vec4 radians);"));
s.append(TString("float sin(float angle);"));
s.append(TString("vec2 sin(vec2 angle);"));
s.append(TString("vec3 sin(vec3 angle);"));
s.append(TString("vec4 sin(vec4 angle);"));
s.append(TString("float cos(float angle);"));
s.append(TString("vec2 cos(vec2 angle);"));
s.append(TString("vec3 cos(vec3 angle);"));
s.append(TString("vec4 cos(vec4 angle);"));
s.append(TString("float tan(float angle);"));
s.append(TString("vec2 tan(vec2 angle);"));
s.append(TString("vec3 tan(vec3 angle);"));
s.append(TString("vec4 tan(vec4 angle);"));
s.append(TString("float asin(float x);"));
s.append(TString("vec2 asin(vec2 x);"));
s.append(TString("vec3 asin(vec3 x);"));
s.append(TString("vec4 asin(vec4 x);"));
s.append(TString("float acos(float x);"));
s.append(TString("vec2 acos(vec2 x);"));
s.append(TString("vec3 acos(vec3 x);"));
s.append(TString("vec4 acos(vec4 x);"));
s.append(TString("float atan(float y, float x);"));
s.append(TString("vec2 atan(vec2 y, vec2 x);"));
s.append(TString("vec3 atan(vec3 y, vec3 x);"));
s.append(TString("vec4 atan(vec4 y, vec4 x);"));
s.append(TString("float atan(float y_over_x);"));
s.append(TString("vec2 atan(vec2 y_over_x);"));
s.append(TString("vec3 atan(vec3 y_over_x);"));
s.append(TString("vec4 atan(vec4 y_over_x);"));
//
// Exponential Functions.
//
s.append(TString("float pow(float x, float y);"));
s.append(TString("vec2 pow(vec2 x, vec2 y);"));
s.append(TString("vec3 pow(vec3 x, vec3 y);"));
s.append(TString("vec4 pow(vec4 x, vec4 y);"));
s.append(TString("float exp(float x);"));
s.append(TString("vec2 exp(vec2 x);"));
s.append(TString("vec3 exp(vec3 x);"));
s.append(TString("vec4 exp(vec4 x);"));
s.append(TString("float log(float x);"));
s.append(TString("vec2 log(vec2 x);"));
s.append(TString("vec3 log(vec3 x);"));
s.append(TString("vec4 log(vec4 x);"));
s.append(TString("float exp2(float x);"));
s.append(TString("vec2 exp2(vec2 x);"));
s.append(TString("vec3 exp2(vec3 x);"));
s.append(TString("vec4 exp2(vec4 x);"));
s.append(TString("float log2(float x);"));
s.append(TString("vec2 log2(vec2 x);"));
s.append(TString("vec3 log2(vec3 x);"));
s.append(TString("vec4 log2(vec4 x);"));
s.append(TString("float sqrt(float x);"));
s.append(TString("vec2 sqrt(vec2 x);"));
s.append(TString("vec3 sqrt(vec3 x);"));
s.append(TString("vec4 sqrt(vec4 x);"));
s.append(TString("float inversesqrt(float x);"));
s.append(TString("vec2 inversesqrt(vec2 x);"));
s.append(TString("vec3 inversesqrt(vec3 x);"));
s.append(TString("vec4 inversesqrt(vec4 x);"));
//
// Common Functions.
//
s.append(TString("float abs(float x);"));
s.append(TString("vec2 abs(vec2 x);"));
//.........这里部分代码省略.........
示例13: main
// note - you may need to change the definition of the main function to
// be consistent with what your C++ compiler expects.
int main()
{
ofstream outfile (pOutfileName, ios::out);
if( !outfile.is_open() )
{
cout << "Error - unable to open output file: " << pOutfileName << endl;
return 1;
}
//cout << "Writing output to " << pOutfileName << "... please wait" << endl;
//ostream& outstream = outfile; // uncomment to write to file
ostream& outstream = cout; // uncomment to write directly to cout
const char *mp = 0;
int step = 0;
outstream << "----- simple String class test ----- (09/16/2010)" << endl << endl;
// const checks (compile tests)
// If there are compile errors in this section, then there are probably const specifiers missing from your
// class definition, e.g. the length() member function should be defined as a const member function so
// it can be invoked on a const TString object, as should all other member functions that don't change the
// state of 'this'.
{
if (0 != 0) // only a compilation check for these methods at this point (for const). Tested further below.
{
const TString s0(pHello); // create a const TString object
int n = s0.length();
bool f = s0.equalsIgnoreCase(pHello);
f = s0.equals(pHello);
const char *p = s0.asChar();
n = s0.indexOf('h');
const TString s1(s0); // const String object parameter
TString s2;
s2.assign(s0); // const String object parameter
s2.append(s0); // const String object parameter
}
}
// Default ctor
outstream << "\n----- Step " << ++step << " - default ctor -----" << endl;
{
TString s0; // default arg value
outstream << "s0 using default ctor with default arg = \"" << s0.asChar() << "\" (length = " << s0.length() << ")" << endl;
mp = (0 == s0.length()) ? "OK: " : "ERROR: ";
outstream << mp << "length = " << s0.length() << endl;
mp = (0 != s0.asChar()) ? "OK: " : "ERROR: ";
outstream << mp << "asChar() return value " << hex << "0x" << reinterpret_cast<const int *>(s0.asChar()) << dec << endl;
mp = ('\0' == *(s0.asChar())) ? "OK: null byte " : "ERROR: null byte not ";
outstream << mp << "at position 0" << endl;
}
{
TString s0(copyToTemp(pHello)); // char * parameter
clearTemp();
outstream << endl << "s0 using default ctor with char* parameter = \"" << s0.asChar() << "\" (length = " << s0.length() << ")" << endl;
mp = (s0.length() == strlen(pHello)) ? "OK: " : "ERROR: ";
outstream << mp << "length = " << s0.length() << endl;
mp = (0 == strcmp(s0.asChar(), pHello)) ? "OK: " : "ERROR: ";
outstream << mp << "value is \"" << s0.asChar() << "\"" << endl;
mp = (s0.asChar() != pHello) ? "OK: different " : "ERROR: same ";
outstream << mp << "pointer value returned from asChar()" << endl;
mp = (s0.asChar() == s0.asChar()) ? "OK: same " : "ERROR: different ";
outstream << mp << "pointer value returned for successive calls of asChar()" << endl;
}
// Copy ctor
outstream << "\n----- Step " << ++step << " - copy ctor -----" << endl;
{
TString s0(copyToTemp(pHiMom));
clearTemp();
TString s1(s0); // copy ctor
outstream << "s1 using copy ctor = \"" << s1.asChar() << "\" (length = " << s1.length() << ")" << endl;
mp = (s1.length() == s0.length() && s1.length() == strlen(pHiMom)) ? "OK: " : "ERROR: ";
outstream << mp << "length = " << s1.length() << endl;
mp = (s1.asChar() != s0.asChar()) ? "OK: different " : "ERROR: same ";
outstream << mp << "pointer value returned from asChar()" << endl;
mp = (0 == strcmp(s1.asChar(), pHiMom)) ? "OK: " : "ERROR: ";
outstream << mp << "value is \"" << s1.asChar() << "\"" << endl;
}
{
// Check copy of empty string
TString s0;
TString s1(s0);
outstream << "s1 using copy ctor = \"" << s1.asChar() << "\" (length = " << s1.length() << ")" << endl;
mp = (0 == s1.length()) ? "OK: " : "ERROR: ";
outstream << mp << "length = " << s1.length() << endl;
mp = (0 != s1.asChar()) ? "OK: " : "ERROR: ";
outstream << mp << "asChar() return value " << hex << "0x" << reinterpret_cast<const int *>(s1.asChar()) << dec << endl;
mp = (s1.asChar() != s0.asChar()) ? "OK: different " : "ERROR: same ";
outstream << mp << "pointer value returned from asChar()" << endl;
mp = ('\0' == *(s0.asChar())) ? "OK: null byte " : "ERROR: null byte not ";
outstream << mp << "at position 0" << endl;
}
// append
outstream << "\n----- Step " << ++step << " - append -----" << endl;
//.........这里部分代码省略.........
示例14: ExportLanguage
void ExportLanguage()
{
std::map<uint32_t, std::map<ELanguageType, TString> > languageServerErrCodeMap;
ReadServerErrCodeFile(languageServerErrCodeMap);
std::map<TString, std::map<ELanguageType, TString> >& languageMap = CLanguageManager::GetInstance()->GetLanguageMap();
// 1. Export Bin File.
CSerializer fileData;
for (int i = 0; i < eLT_Count; ++i)
{
fileData << languageMap.size();
for (auto iter = languageMap.begin(); iter != languageMap.end(); ++iter)
{
auto subIter = iter->second.find((ELanguageType)i);
if (subIter != iter->second.end())
{
fileData << subIter->second;
}
else
{
fileData << iter->first;
}
}
bool bRet = false;
for (auto iter : languageServerErrCodeMap)
{
auto subIter = iter.second.find((ELanguageType)i);
if (subIter != iter.second.end())
{
if (!bRet)
{
fileData << languageServerErrCodeMap.size();
bRet = true;
}
fileData << iter.first;
fileData << iter.second[(ELanguageType)i];
}
}
TString strFilePath = CResourceManager::GetInstance()->GetResourcePath(eRT_Language);
strFilePath.append(_T("/")).append(pszLanguageTypeString[i]).append(_T(".bin"));
fileData.Deserialize(strFilePath.c_str(), _T("wb+"));
fileData.Reset();
}
//2. Export enum file.
std::string content;
content.append("#ifndef BEYONDENGINEEDITOR_LANGUAGEENUM_H__INCLUDE\n#define BEYONDENGINEEDITOR_LANGUAGEENUM_H__INCLUDE\n").append("\nenum ELanguageTextType\n{\n");
for (auto iter = languageMap.begin(); iter != languageMap.end(); iter++)
{
content.append(" ").append(iter->first.c_str()).append(",\n");
}
content.append("\n eL_Count,\n").append(" eL_Force32Bit = 0xFFFFFFFF\n};\n");
content.append("#define LUA_LANGUAGE_MAP(LM)\\\n");
int32_t nCounter = 0;
for (auto iter = languageMap.begin(); iter != languageMap.end(); ++iter)
{
TCHAR szValueBuffer[32];
_stprintf(szValueBuffer, "%d", nCounter++);
content.append(" ").append("LM(").append(iter->first.c_str()).append(",").append(szValueBuffer).append(")\\\n");
}
content.append("\n#endif");
fileData.Reset();
fileData << content;
fileData.SetWritePos(fileData.GetWritePos() - 1);// back scape the 0 in the string end.
bool bFileTheSame = false;
const TString strHeaderFilePath = CResourceManager::GetInstance()->GetResourcePath(eRT_SourceCode) + _T("/Language/Language.h");
if (CFilePathTool::GetInstance()->Exists(strHeaderFilePath.c_str()))
{
CSerializer tmpData(strHeaderFilePath.c_str(), "rb");
if (tmpData.GetWritePos() == fileData.GetWritePos())
{
CMD5 tmpMD5(tmpData.GetBuffer(), tmpData.GetWritePos());
CMD5 currentMD5(fileData.GetBuffer(), fileData.GetWritePos());
bFileTheSame = tmpMD5 == currentMD5;
}
}
if (!bFileTheSame)
{
fileData.Deserialize(strHeaderFilePath.c_str(), _T("wb+"));
}
//3. Export txt file.
for (int i = 0; i < eLT_Count; ++i)
{
bool bHasData = false;
fileData.Reset();
for (auto iter = languageMap.begin(); iter != languageMap.end(); ++iter)
{
auto subIter = iter->second.find((ELanguageType)i);
if (subIter != iter->second.end())
{
TString strData = (TString)(wxString::FromUTF8(subIter->second.c_str()));
if (!bHasData && !strData.empty())
{
bHasData = true;
}
fileData << strData;
fileData.SetWritePos(fileData.GetWritePos() - 1);
}
fileData << "\n";
fileData.SetWritePos(fileData.GetWritePos() - 1);
}
//.........这里部分代码省略.........
示例15: LoadFromFile
void CLanguageManager::LoadFromFile(ELanguageType language)
{
#ifdef EDITOR_MODE
BEYONDENGINE_UNUSED_PARAM(language);
m_languageMap.clear();
TString filePath = CResourceManager::GetInstance()->GetResourcePath(eRT_Resource);
filePath.append(_T("/LanguageConfig.xml"));
if (CFilePathTool::GetInstance()->Exists(filePath.c_str()))
{
rapidxml::file<> fdoc(filePath.c_str());
rapidxml::xml_document<> doc;
try
{
doc.parse<rapidxml::parse_default>(fdoc.data());
doc.m_pszFilePath = filePath.c_str();
}
catch (rapidxml::parse_error &e)
{
TCHAR info[MAX_PATH];
_stprintf(info, _T("Load file :%s Failed! error :%s"), filePath.c_str(), e.what());
MessageBox(BEYONDENGINE_HWND, info, _T("Load File Failed"), MB_OK | MB_ICONERROR);
}
uint32_t uCounter = 0;
rapidxml::xml_node<>* pRootNode = doc.first_node("Language");
rapidxml::xml_node<>* pLanguageNode = pRootNode->first_node("LanguageNode");
while (pLanguageNode != nullptr)
{
uCounter++;
TString strEnum = pLanguageNode->first_attribute("Enum")->value();
BEATS_ASSERT(!strEnum.empty());
if (pLanguageNode->first_attribute("Tag"))
{
TString strTag = pLanguageNode->first_attribute("Tag")->value();
m_languageTagMap[strEnum] = strTag;
}
BEATS_ASSERT(m_languageMap.find(strEnum) == m_languageMap.end());
std::map<ELanguageType, TString>& curMap = m_languageMap[strEnum];
rapidxml::xml_node<>* pLanguageValueNode = pLanguageNode->first_node();
while (pLanguageValueNode != nullptr)
{
TString languageTypeStr = pLanguageValueNode->name();
ELanguageType languageType = eLT_Count;
for (int j = 0; j < eLT_Count; ++j)
{
if (pszLanguageTypeString[j] == languageTypeStr)
{
languageType = (ELanguageType)j;
break;
}
}
BEATS_ASSERT(curMap.find(languageType) == curMap.end());
const TCHAR* pszValue = pLanguageValueNode->first_attribute("Value")->value();
BEATS_ASSERT(_tcslen(pszValue) > 0);
curMap[languageType] = pszValue;
pLanguageValueNode = pLanguageValueNode->next_sibling();
}
pLanguageNode = pLanguageNode->next_sibling();
}
BEATS_ASSERT((uint32_t)_ttoi(pRootNode->first_attribute("Count")->value()) == uCounter);
}
#else
TString filePath = CResourceManager::GetInstance()->GetResourcePath(eRT_Language);
filePath.append(_T("/")).append(pszLanguageTypeString[language]).append(_T(".bin"));
bool bFindLanguageFile = CFilePathTool::GetInstance()->Exists(filePath.c_str());
BEATS_ASSERT(bFindLanguageFile, "Can't Find language file %s", filePath.c_str());
if (bFindLanguageFile)
{
int count = 0;
CSerializer tmp(filePath.c_str());
tmp >> count;
m_texts.clear();
for (int i = 0; i < count; ++i)
{
ELanguageTextType textId = (ELanguageTextType)i;
std::string strValue;
tmp >> strValue;
m_texts.emplace(textId, strValue);
}
tmp >> count;
for (int i = 0; i < count; ++i)
{
uint32_t key;
tmp >> key;
BEATS_ASSERT(m_texts.find((ELanguageTextType)key) == m_texts.end());
tmp >> m_texts[(ELanguageTextType)key];
}
}
#endif
}