本文整理汇总了C++中STRING类的典型用法代码示例。如果您正苦于以下问题:C++ STRING类的具体用法?C++ STRING怎么用?C++ STRING使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了STRING类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenBoxFile
// Open the boxfile based on the given image filename.
FILE* OpenBoxFile(const STRING& fname) {
STRING filename = BoxFileName(fname);
FILE* box_file = NULL;
if (!(box_file = fopen(filename.string(), "rb"))) {
CANTOPENFILE.error("read_next_box", TESSEXIT,
"Cant open box file %s",
filename.string());
}
return box_file;
}
示例2: TEST_F
TEST_F(lv_LV_PhoneNumber, Operator) {
cxxfaker::providers::lv_LV::PhoneNumber phonenumber;
phonenumber.Seed(::testing::UnitTest::GetInstance()->random_seed());
STRING number = phonenumber;
for (STRING::const_iterator iter = number.begin(); iter != number.end(); ++iter) {
if (isdigit(*iter) || *iter == '-' || *iter == '+' || *iter == ' ')
continue;
ADD_FAILURE() << "What is this \"" << *iter << "\" doing in here..";
};
};
示例3: dump_words
void dump_words(WERD_RES_LIST &perm, inT16 score, inT16 mode, BOOL8 improved) {
WERD_RES_IT word_res_it(&perm);
static STRING initial_str;
if (debug_fix_space_level > 0) {
if (mode == 1) {
initial_str = "";
for (word_res_it.mark_cycle_pt ();
!word_res_it.cycled_list (); word_res_it.forward ()) {
if (!word_res_it.data ()->part_of_combo) {
initial_str += word_res_it.data ()->best_choice->string ();
initial_str += ' ';
}
}
}
#ifndef SECURE_NAMES
if (debug_fix_space_level > 1) {
switch (mode) {
case 1:
tprintf ("EXTRACTED (%d): \"", score);
break;
case 2:
tprintf ("TESTED (%d): \"", score);
break;
case 3:
tprintf ("RETURNED (%d): \"", score);
break;
}
for (word_res_it.mark_cycle_pt ();
!word_res_it.cycled_list (); word_res_it.forward ()) {
if (!word_res_it.data ()->part_of_combo)
tprintf("%s/%1d ",
word_res_it.data ()->best_choice->string ().
string (),
(int) word_res_it.data ()->best_choice->permuter ());
}
tprintf ("\"\n");
}
else if (improved) {
tprintf ("FIX SPACING \"%s\" => \"", initial_str.string ());
for (word_res_it.mark_cycle_pt ();
!word_res_it.cycled_list (); word_res_it.forward ()) {
if (!word_res_it.data ()->part_of_combo)
tprintf ("%s/%1d ",
word_res_it.data ()->best_choice->string ().
string (),
(int) word_res_it.data ()->best_choice->permuter ());
}
tprintf ("\"\n");
}
#endif
}
}
示例4: fopen
bool TessdataManager::CombineDataFiles(
const char *language_data_path_prefix,
const char *output_filename) {
int i;
inT64 offset_table[TESSDATA_NUM_ENTRIES];
for (i = 0; i < TESSDATA_NUM_ENTRIES; ++i) offset_table[i] = -1;
FILE *output_file = fopen(output_filename, "wb");
if (output_file == NULL) {
tprintf("Error opening %s for writing\n", output_filename);
return false;
}
// Leave some space for recording the offset_table.
if (fseek(output_file,
sizeof(inT32) + sizeof(inT64) * TESSDATA_NUM_ENTRIES, SEEK_SET)) {
tprintf("Error seeking %s\n", output_filename);
fclose(output_file);
return false;
}
TessdataType type = TESSDATA_NUM_ENTRIES;
bool text_file = false;
FILE *file_ptr[TESSDATA_NUM_ENTRIES];
// Load individual tessdata components from files.
for (i = 0; i < TESSDATA_NUM_ENTRIES; ++i) {
ASSERT_HOST(TessdataTypeFromFileSuffix(
kTessdataFileSuffixes[i], &type, &text_file));
STRING filename = language_data_path_prefix;
filename += kTessdataFileSuffixes[i];
file_ptr[i] = fopen(filename.string(), "rb");
if (file_ptr[i] != NULL) {
offset_table[type] = ftell(output_file);
CopyFile(file_ptr[i], output_file, text_file, -1);
fclose(file_ptr[i]);
}
}
// Make sure that the required components are present.
if (file_ptr[TESSDATA_UNICHARSET] == NULL) {
tprintf("Error opening %sunicharset file\n", language_data_path_prefix);
fclose(output_file);
return false;
}
if (file_ptr[TESSDATA_INTTEMP] != NULL &&
(file_ptr[TESSDATA_PFFMTABLE] == NULL ||
file_ptr[TESSDATA_NORMPROTO] == NULL)) {
tprintf("Error opening %spffmtable and/or %snormproto files"
" while %sinttemp file was present\n", language_data_path_prefix,
language_data_path_prefix, language_data_path_prefix);
fclose(output_file);
return false;
}
return WriteMetadata(offset_table, language_data_path_prefix, output_file);
}
示例5: SendGetInet
void HttpSocket::SendGetInet(const STRING &url, const STRING &host, const int &port, std::vector<char> *data)
{
char d[4096];
DWORD len;
stringstream lss;
INTERNET_BUFFERS BufferIn = {0};
BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS );
HINTERNET hNet = InternetOpen(_T("peelClient"), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, NULL);
if(!hNet)
throw SocketException(_T("Could not open internet"), GetError());
HINTERNET hCon = InternetConnect(hNet, host.c_str(), port , 0, 0, INTERNET_SERVICE_HTTP, 0, 0);
if(!hCon)
{
InternetCloseHandle(hNet);
throw SocketException(_T("Could not connect to server"), GetError());
}
HINTERNET hReq = HttpOpenRequest(hCon, _T("GET"), url.c_str(), 0, 0, 0, INTERNET_FLAG_RELOAD, 0);
if(!hReq)
{
InternetCloseHandle(hNet);
InternetCloseHandle(hCon);
throw SocketException(_T("Could not open request to server"), GetError());
}
if(!HttpSendRequest(hReq, NULL, NULL, NULL, NULL))
{
InternetCloseHandle(hNet);
InternetCloseHandle(hCon);
throw SocketException(_T("Could not send request to server"), GetError());
}
if(data != NULL)
{
lss.str("");
while(1)
{
if(!InternetReadFile(hReq, d, 4095, &len))
break;
if(len==0) break;
d[len]='\0';
std::copy( d, d+len, (*data).begin());
}
}
InternetCloseHandle(hNet);
InternetCloseHandle(hCon);
}
示例6: FixHeader
BOOL8 STRING::operator!=(const STRING& str) const {
FixHeader();
str.FixHeader();
const STRING_HEADER* str_header = str.GetHeader();
const STRING_HEADER* this_header = GetHeader();
int this_used = this_header->used_;
int str_used = str_header->used_;
return (this_used != str_used)
|| (memcmp(GetCStr(), str.GetCStr(), this_used) != 0);
}
示例7: NotImplemented
void JustRenderIt::NotImplemented(bool halt, STRING msg)
{
STRING str = msg + " Not implemented!";
if(!halt)
LOG_WARNING1(str.c_str());
else
{
LOG_FATAL1(str.c_str());
}
}
示例8: TRACE_MESSAGE
bool Ini_UpdaterLists::saveRollbackInfo(const FileVector &rollbackList)
{
STRING section_name = SS_KEY_RollbackTree;
long k = 0;
STRING rollbackFileAndPath;
if(!getProductFolder(m_useCurrentFolder, rollbackFileAndPath, pLog))
{
TRACE_MESSAGE("Unable to save rollback information, because failed to get product folder");
return false;
}
rollbackFileAndPath += UPDATER_LISTS_FILENEME;
TRACE_MESSAGE2("Saving rollback list to '%s'", rollbackFileAndPath.to_string().c_str());
removeRollbackSection();
// for output saved entries in rows and save space in trace file
std::string savedEntries;
unsigned long logLineSplitIndex = 0;
for(FileVector::const_iterator iter = rollbackList.begin(); iter != rollbackList.end(); ++iter)
{
if(iter->m_rollbackChange == STRING(SS_KEY_RecentStatusAdded)
|| iter->m_rollbackChange == STRING(SS_KEY_RecentStatusModified)
|| iter->m_rollbackChange == STRING(SS_KEY_RecentStatusDeleted))
{
STRING newSectionName;
const long order_number = k++;
makeNewSectionName(order_number, iter->m_filename, newSectionName);
if(!saveRollbackListEntry(rollbackFileAndPath.c_str(), section_name.c_str(), order_number, newSectionName, *iter))
{
TRACE_MESSAGE2("Unable to save rollback information for file entry '%s'", (iter->m_localPath + iter->m_filename).to_string().c_str());
return false;
}
// append comma before all items, but the very first one
if(logLineSplitIndex++)
savedEntries += ", ";
// split line each 3 elements, but not before last element
if(iter + 1 != rollbackList.end())
{
if(!(logLineSplitIndex % 3))
savedEntries += "\n\t";
}
savedEntries += (iter->m_localPath + iter->m_filename).to_string();
}
}
TRACE_MESSAGE3("Rollback information saved successfully to %s, entries: %s", rollbackFileAndPath.to_string().c_str(), savedEntries.c_str());
return true;
}
示例9: GetBasePath
// clears the tile cache for the given map
void MgdTileCache::Clear(MgMapBase* map)
{
if (map != NULL)
{
STRING basePath = GetBasePath(map);
// delete main map directory
if (!basePath.empty())
MgFileUtil::DeleteDirectory(basePath, true, false);
}
}
示例10: LoadLevel
// Load level information
int Level::LoadLevel(const STRING & path)
{
STRING file;
file.assign(path.c_str());
STRING name = Port::FileName(file);
file.append(Port::ReplacePath(STR("\\level.dat")));
NBT_Reader read = NBT_Reader();
read.Load(file);
bool valid = false;
NBTTag tag = read.ReadData(); // Read first compound
while ((tag = read.ReadData()) != TAG_Unknown)
{
const NBTData * data = read.GetData();
if (!data)
continue;
if (!valid)
{
if (data->tag != TAG_Compound)
continue;
if (!data->name)
continue;
if (!StringCheck(data->name, "Data"))
continue;
valid = true;
}
switch (data->tag)
{
case TAG_Int:
if (StringCheck(data->name, "version"))
{
info.version = data->i;
}
break;
case TAG_Long:
if (StringCheck(data->name, "RandomSeed"))
{
info.seed = data->l;
}
break;
case TAG_String:
if (StringCheck(data->name, "LevelName"))
{
info.name.assign((char *)data->bas, (char *)data->bas+data->size);
}
break;
}
}
// Alpha
if (info.name.empty())
info.name = name;
return valid;
}
示例11: DebugWeights
// Sets up the network for training using the given weight_range.
void LSTM::DebugWeights() {
for (int w = 0; w < WT_COUNT; ++w) {
if (w == GFS && !Is2D()) continue;
STRING msg = name_;
msg.add_str_int(" Gate weights ", w);
gate_weights_[w].Debug2D(msg.string());
}
if (softmax_ != NULL) {
softmax_->DebugWeights();
}
}
示例12: getArg
bool XmlTagEntity::getArg(STRING name, int &ivalue)
{
STRING tmp;
if(!getArg(name, tmp)) return false;
#ifdef _WIN32
ivalue = _tstoi(tmp.c_str());
#else
ivalue = atoi(tmp.c_str());
#endif
return true;
}
示例13: KLAssert
//从文件中读取变量
VOID CVariableSystem::LoadVariable(LPCTSTR szFileName, VARIABLE_MAP& mapBuf)
{
KLAssert(szFileName);
// mapBuf.clear();
//-----------------------------------------------------------
//取得配置文件的大小
HANDLE hFile = CreateFile(szFileName,
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(INVALID_HANDLE_VALUE == hFile) return;
DWORD dwHigh;
DWORD dwFileSize = GetFileSize(hFile, &dwHigh);
CloseHandle(hFile); hFile = NULL;
if(0==dwFileSize) return;
//-----------------------------------------------------------
//分配足够的内存
CHAR* pTempBuf = new CHAR[dwFileSize+32];
if(!pTempBuf) return;
//-----------------------------------------------------------
//从配置文件中读取"Variable"节
::GetPrivateProfileSection("Variable", pTempBuf, dwFileSize, szFileName);
//分解
std::vector< STRING > vRet;
ConvertSectionInVector(pTempBuf, dwFileSize, vRet);
delete[] pTempBuf; pTempBuf=NULL;
//加入变量定义
for(INT i=0; i<(INT)vRet.size(); i++)
{
STRING& strLine = vRet[i];
STRING::size_type tEqu = strLine.find_first_of("= \t");
if(tEqu == STRING::npos) continue;
STRING strName = strLine.substr(0, tEqu);
CHAR szTemp[1024];
::GetPrivateProfileString("Variable", strName.c_str(), "", szTemp, 1024, szFileName);
SetVariable(strName.c_str(), szTemp, FALSE);
}
}
示例14: calcToScalar
void calcToScalar(ObjectHandler::property_t &ret, const ANY &value) {
STRING t = value.getValueTypeName();
//std::cout << "calcToScalar ANY to property_t called" << std::endl;
if (t.equalsIgnoreAsciiCase(STRFROMANSI("VOID"))) {
//std::cout << "ANY value type VOID" << std::endl;
ret = ObjectHandler::property_t();
} else if (t.equalsIgnoreAsciiCase(STRFROMANSI("LONG"))) {
//std::cout << "ANY value type LONG" << std::endl;
long temp;
value >>= temp;
ret = ObjectHandler::property_t(temp);
} else if (t.equalsIgnoreAsciiCase(STRFROMANSI("DOUBLE"))) {
示例15: WriteNormProtos
/*----------------------------------------------------------------------------*/
void WriteNormProtos (
const char *Directory,
LIST LabeledProtoList,
CLUSTERER *Clusterer)
/*
** Parameters:
** Directory directory to place sample files into
** Operation:
** This routine writes the specified samples into files which
** are organized according to the font name and character name
** of the samples.
** Return: none
** Exceptions: none
** History: Fri Aug 18 16:17:06 1989, DSJ, Created.
*/
{
FILE *File;
STRING Filename;
LABELEDLIST LabeledProto;
int N;
Filename = "";
if (Directory != NULL && Directory[0] != '\0')
{
Filename += Directory;
Filename += "/";
}
Filename += "normproto";
printf ("\nWriting %s ...", Filename.string());
File = Efopen (Filename.string(), "wb");
fprintf(File,"%0d\n",Clusterer->SampleSize);
WriteParamDesc(File,Clusterer->SampleSize,Clusterer->ParamDesc);
iterate(LabeledProtoList)
{
LabeledProto = (LABELEDLIST) first_node (LabeledProtoList);
N = NumberOfProtos(LabeledProto->List, true, false);
if (N < 1) {
printf ("\nError! Not enough protos for %s: %d protos"
" (%d significant protos"
", %d insignificant protos)\n",
LabeledProto->Label, N,
NumberOfProtos(LabeledProto->List, 1, 0),
NumberOfProtos(LabeledProto->List, 0, 1));
exit(1);
}
fprintf(File, "\n%s %d\n", LabeledProto->Label, N);
WriteProtos(File, Clusterer->SampleSize, LabeledProto->List, true, false);
}
fclose (File);
} // WriteNormProtos