本文整理汇总了C++中STRING类的典型用法代码示例。如果您正苦于以下问题:C++ STRING类的具体用法?C++ STRING怎么用?C++ STRING使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了STRING类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:0ximDigital,项目名称:appsScanner,代码行数:11,代码来源:boxread.cpp
示例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..";
};
};
开发者ID:schoentoon,项目名称:cxxfaker,代码行数:10,代码来源:PhoneNumber_test.cpp
示例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
}
}
开发者ID:90b56587,项目名称:Tesseract-iPhone-Demo,代码行数:55,代码来源:fixspace.cpp
示例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);
}
开发者ID:MaTriXy,项目名称:tess-two,代码行数:55,代码来源:tessdatamanager.cpp
示例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);
}
开发者ID:mocap-ca,项目名称:peellib,代码行数:55,代码来源:HttpSocket.cpp
示例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);
}
开发者ID:0xkasun,项目名称:tesseract,代码行数:11,代码来源:strngs.cpp
示例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());
}
}
开发者ID:ranjiao,项目名称:JustRenderIt,代码行数:11,代码来源:Util.cpp
示例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;
}
开发者ID:hackshields,项目名称:antivirus,代码行数:54,代码来源:ini_updater_lists.cpp
示例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);
}
}
开发者ID:asir6,项目名称:Colt,代码行数:12,代码来源:TileCache.cpp
示例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;
}
开发者ID:McTwist,项目名称:PixelMap,代码行数:55,代码来源:Level.cpp
示例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();
}
}
开发者ID:Using1174,项目名称:tesseract,代码行数:12,代码来源:lstm.cpp
示例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;
}
开发者ID:mocap-ca,项目名称:peellib,代码行数:11,代码来源:XmlTagGet.cpp
示例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);
}
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:54,代码来源:GMVariable.cpp
示例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"))) {
开发者ID:AAthresh,项目名称:quantlib,代码行数:12,代码来源:conversions.cpp
示例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
开发者ID:0ximDigital,项目名称:appsScanner,代码行数:54,代码来源:cntraining.cpp
示例16: testEmptyConst
void testEmptyConst()
{
char desc[] = "Empty Constructor";
printTestHeader(desc);
STRING s;
cout << "STRING contains '"; STRdisplay(s); cout << "'.\n"
<< "STRING length is " << s.length() << ".\n"
<< "isEmpty returns " << (s.isEmpty() ? "True" : "False") << ".\n";
printTestFooter(desc);
}
开发者ID:dzackgarza,项目名称:STR_class,代码行数:12,代码来源:TestMain.cpp
示例17: QuotedContext
SNORTRULEHDR void CRuleOption::FormatPattern(CDllString &out)
{
m_nFlags = CRuleOption::NOFLAG;
STRING str = out.Data();
STRING_ITER iBeg = str.begin(), iEnd = str.end();
if (*std::find_if_not(iBeg, iEnd, ISSPACE()) == '!')
{
m_nFlags |= CRuleOption::HASNOT;
}
QuotedContext(iBeg, iEnd);
out.Assign(STRING(iBeg, iEnd).c_str());
}
开发者ID:devymex,项目名称:SnortCompiler,代码行数:12,代码来源:ruleoption.cpp
示例18: while
VOID CStringFilter::ReplaceToSign_Normal(const STRING& strIn, STRING& strOut)
{
static STRING strSign = "?";
static BYTE byANSIBegin = 0X20;
static BYTE byANSIEnd = 0X80;
strOut = strIn;
STRING::size_type allsize = m_vIncluce.size();
//包含替换
for(STRING::size_type i = 0; i < m_vIncluce.size(); ++i)
{
STRING::size_type pos = strIn.find(m_vIncluce[i]);
while(STRING::npos != pos)
{
STRING strReplace = "";
STRING::size_type len = m_vIncluce[i].size();
//如果包含替换的是1个字节的ANSI字节,替换前,
//需要确认前一个字节一定不是双字节字符集的前一个字节
BOOL bSkip = FALSE;
if(1 == len && pos > 0)
{
BYTE byChar = strIn[pos-1];
#if 0
char dbgmsg[256];
_snprintf(dbgmsg, 255, "strIn[pos-1]:0x%X(0x%X)\n", strIn[pos-1],byChar);
::OutputDebugString(dbgmsg);
#endif
//不是标准ANSI英文字符
if(!(byChar >= byANSIBegin && byChar <= byANSIEnd || byChar == '\r' || byChar == '\n' || byChar == '\t'))
{
bSkip = TRUE;
}
}
if(!bSkip)
{
for(STRING::size_type k = 0; k < len; ++k, strReplace += strSign);
strOut.replace(pos, len, strReplace);
}
pos = strIn.find(m_vIncluce[i], pos+len);
}
}
//完全匹配替换
if(IsFullCmp(strIn))
{
STRING::size_type len = strIn.size();
strOut.clear();
for(STRING::size_type i = 0; i < len; ++i, strOut += strSign);
}
}
开发者ID:jjiezheng,项目名称:pap_full,代码行数:53,代码来源:UIString_Filter.cpp
示例19: okBase
static inline int okBase( const STRING& aField )
{
int offset = int( aField.find_first_of( ":/" ) );
if( offset != -1 )
return offset;
// cannot be empty
if( !aField.size() )
return 0;
return offset; // ie. -1
}
开发者ID:AlexanderBrevig,项目名称:kicad-source-mirror,代码行数:12,代码来源:sch_lpid.cpp
示例20: removePath
/*
* Remove the path from a file name, perserving folders.
* preserveFrom should carry a trailing \.
*/
STRING removePath(const STRING str, const STRING preserveFrom)
{
const int pos = str.find(preserveFrom);
if (pos != str.npos)
{
return str.substr(pos + preserveFrom.length());
}
// Return the path unaltered, since it didn't contain the
// default folder and any other folders should be subfolders
// (although a different default folder may be present).
return str;
}
开发者ID:LameAss-Studio,项目名称:trans3,代码行数:16,代码来源:paths.cpp
注:本文中的STRING类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论