• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cString类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cString的典型用法代码示例。如果您正苦于以下问题:C++ cString类的具体用法?C++ cString怎么用?C++ cString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了cString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CalculateHash

// ****************************************************************************
unsigned long cHashedString::CalculateHash(const cString & strIdent)
{
	if(strIdent.IsEmpty())
	{
		return 0;
	}
	// largest prime smaller than 65536
	unsigned long lBASE = 65521L;
	
	// lMAX is the largest n such that // 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
	unsigned int lMAX = 5522;

	unsigned int s1 = 0;
	unsigned int s2 = 0;

	int i = 0;
	unsigned int length = strIdent.GetLength();
	while(length > 0)
	{
		int k = length < lMAX ? length : lMAX;
		length -= k;
		while(--k >= 0)
		{
			s1 += (unsigned int)(tolower(strIdent[i++]) & 0XFF);
			s2 += s1;
		}
		s1 %= lBASE;
		s2 %= lBASE;
	}
	return ((s2 << 16) | s1);
}
开发者ID:AnkurSheel,项目名称:Engine,代码行数:32,代码来源:HashedString.cpp


示例2: SetTimeZone

bool cTimeAndDate::SetTimeZone(cString tz, bool isUTC, bool tostdout, cString external_exec) {
	cTimeAndDate *now;
	cExec exec;
	if(geteuid()==0) {
		now=new cTimeAndDate;
		now->SetUTC(isUTC);
		now->SetTimezone(tz);
		ofstream fout;
		if(tostdout) {
			if(!now->ApplyTimeZone(cout)) return false;
		} else {
			if(!cExec::CopyFile("/usr/share/zoneinfo/"+tz,"/etc/localtime")) {
				return false;
			}
			fout.open("/etc/sysconfig/clock");
			if(!now->ApplyTimeZone(fout)) {
				return false;
			}
			fout.close();
		}
		delete now;
	} else if(external_exec!="") {
		if(!external_exec.Contains(tz)) external_exec+=" -timezone "+tz;
		if(isUTC || external_exec.Contains("isUTC")) external_exec+=" -isUTC";
		if(!exec.ForkExecFG(external_exec)) {
			cerr<<"failed to exec: "<<external_exec<<endl;
			return false;
		}
	} else {
		cerr<<"not root, but no external_exec defined either"<<endl;
		return false;
	}
	return true;
}
开发者ID:cmd184psu,项目名称:fs-tools,代码行数:34,代码来源:timeanddate.cpp


示例3: FromFile

// ********** File IO **************** //
bool cStringList::FromFile(const cString & fname) {
	if(fname.Contains('*')) return false;
	#ifndef WIN32
	if(!FileExists(fname)) return false;
	struct stat buf;
	stat(fname,&buf);
	ifstream infile(fname);
	
	if(fname.Contains("/proc") || buf.st_size==0) {
		if(!FromFile(infile)) { infile.close(); return false; }
	} else {
		if(!FromFile(infile,buf.st_size)) { infile.close(); return false; }
	}
	infile.close();
	
	
	if((*this)[-1]=="" && Length()!=0) used--;
	#else
	FILE* fptr=fopen(fname,"r");
	FromFile(fptr);
	fclose(fptr);
	#endif
	
	return true;
}
开发者ID:cmd184psu,项目名称:fs-tools,代码行数:26,代码来源:stringlist.cpp


示例4: DoesDirectoryExist

// Verifies that directory exists.
// Returns success if the directory exists and is readable (failure may mean
// it's busy or permissions denied on win32)
//-----------------------------------------------------------------------------
CPUTResult CPUTFileSystem::DoesDirectoryExist(const cString &path)
{
#ifdef CPUT_OS_ANDROID
    // On Android, all files are in the APK and are compressed.
    // We do not have access to the standard file system, so
    // all files need streaming from memory through the android asset manager
    AAssetManager* assetManager = CPUTWindowAndroid::GetAppState()->activity->assetManager;
    
    AAssetDir* AssetDir = AAssetManager_openDir(assetManager, path.c_str());
    if (AssetDir)
        return CPUT_SUCCESS;
#else
    struct stat fileAttributes;
    
    int result = stat(path.c_str(), &fileAttributes);
    if (result == -1) {
        DEBUG_ERROR(strerror(errno));
        result = CPUT_ERROR; 
    }
	
    if (S_ISDIR(fileAttributes.st_mode)) {
        return CPUT_SUCCESS;
    }
#endif
    return CPUT_ERROR;
}
开发者ID:Cristianohh,项目名称:InstancingAndroid,代码行数:30,代码来源:CPUTOSServicesLinux.cpp


示例5: AssignStr

static void AssignStr(cString &dest, const char *start, const char *end, _locale_t locale)
{
	dest.clear();
	if (end <= start)
    {
		return;
    }

	static const int NBUF = 64;
	wchar_t buf[NBUF];
	int nb = 0;

	size_t len = end - start;
	size_t initial = len + 1; // assume most characters are 1-byte
	dest.reserve(initial);

	const char *p = start;
	while (p < end)
	{
		int len = _mbtowc_l(&buf[nb++], p, end - p, locale);
		if (len < 1)
        {
			break;
        }

		p += len;
		if (p >= end || nb >= NBUF)
		{
			dest.append(buf, nb);
			nb = 0;
		}
	}
}
开发者ID:Clever-Boy,项目名称:CloudsGPUPro6,代码行数:33,代码来源:CPUTConfigBlock.cpp


示例6: iCPUTifstream

CPUTFileSystem::CPUTandroidifstream::CPUTandroidifstream(const cString &fileName, std::ios_base::openmode mode) : iCPUTifstream(fileName, mode)
{
    mpAsset = NULL;
    mpAssetDir = NULL;
    mbEOF = true;
    
    // Extract the file and dir
    int length = fileName.length();
    int index = fileName.find_last_of("\\/");
    cString file = fileName.substr(index + 1, (length - 1 - index));
    cString dir  = fileName.substr(0, index);
    
    // On Android, all files are in the APK and are compressed.
    // We do not have access to the standard file system, so
    // all files need streaming from memory through the android asset manager
    AAssetManager* assetManager = CPUTWindowAndroid::GetAppState()->activity->assetManager;
    
    mpAssetDir = AAssetManager_openDir(assetManager, dir.c_str());
    if (!mpAssetDir)
        DEBUG_PRINT("Failed to load asset Dir");
    
    const char* assetFileName = NULL;
    while ((assetFileName = AAssetDir_getNextFileName(mpAssetDir)) != NULL) 
    {
        if (strcmp(file.c_str(), assetFileName) == 0)
        {
            // For some reason we need to pass in the fully pathed filename here, rather than the relative filename
            // that we have just been given. This feels like a bug in Android!
            mpAsset = AAssetManager_open(assetManager, fileName.c_str()/*assetFileName*/, AASSET_MODE_STREAMING);
            if (mpAsset)
                mbEOF = false;
            return;
        }
    }
}
开发者ID:Cristianohh,项目名称:InstancingAndroid,代码行数:35,代码来源:CPUTOSServicesLinux.cpp


示例7: FileList_R

void FileList_R(cStringList &mylist, cString fullpath, bool usedirs) {
	cStringList split;
//	cerr<<"fullpath="<<fullpath<<endl;
	if(fullpath.Contains('*')) 
		split.FromString(fullpath,"*.");
	else
		split.FromString(fullpath,".");
	FileList_R(mylist,fullpath.ChopRt('/'),fullpath.ChopAllLf('/'),usedirs);
}
开发者ID:cmd184psu,项目名称:fs-tools,代码行数:9,代码来源:changeend.cpp


示例8: FileList_1

void FileList_1(cStringList &mylist, cString fullpath, bool usedirs) {
	cStringList split;
	if(fullpath.Contains('*')) 
		split.FromString(fullpath,"*.");
	else
		split.FromString(fullpath,".");
		
	FileList_1(mylist,fullpath.ChopRt('/'),fullpath.ChopAllLf('/'),usedirs);
}
开发者ID:cmd184psu,项目名称:fs-tools,代码行数:9,代码来源:changeend.cpp


示例9: pad

cString cString::pad(const cString& object,
                     uint number,
                     character padding)
{
    if (object.length() >= number)
        return object;

    return object + dup(" ", number - object.length());
}
开发者ID:eladraz,项目名称:xStl,代码行数:9,代码来源:string.cpp


示例10: MapKey

CPUTKey MapKey(cString strKey)
{
    for(int i = 0; i < KEY_NUM_KEYS; i++)
    {
        if( 0 == strKey.compare(CPUTKeyMap[i].name))
            return CPUTKeyMap[i].value;
    }
    DEBUG_PRINT(_L("Unknown Key: %s"), strKey.c_str());
    return KEY_NUM_KEYS;
}
开发者ID:swq0553,项目名称:ClusteredShadingAndroid,代码行数:10,代码来源:CPUTGUIElement.cpp


示例11:

//Converts a string day into it's number
int cTimeAndDate::Day2Number(cString day,int st) {
	day=day.ToUpper();
	if(day.Contains("SUN")) return ((0-st)+7)%7;
	if(day.Contains("MON")) return ((1-st)+7)%7;
	if(day.Contains("TUE")) return ((2-st)+7)%7;
	if(day.Contains("WED")) return ((3-st)+7)%7;
	if(day.Contains("THU")) return ((4-st)+7)%7;
	if(day.Contains("FRI")) return ((5-st)+7)%7;
	if(day.Contains("SAT")) return ((6-st)+7)%7;
	return -1;
}
开发者ID:cmd184psu,项目名称:fs-tools,代码行数:12,代码来源:timeanddate.cpp


示例12: CleanConfigurationOptions

//
// This function parses configuration options from a text string. Removes any previous
// options stored in the configuration list.
//
void CommandParser::ParseConfigurationOptions(cString arguments, cString delimiter)
{
	CleanConfigurationOptions();

	std::vector<cString> argumentList;

	size_t pos;
	size_t nextPos = arguments.find_first_of(delimiter, 0);

	//
	// Break out parameters from command line
	//
	while (nextPos != std::string::npos) {
		pos = nextPos + 1;
		nextPos = arguments.find_first_of(delimiter, pos);
		argumentList.push_back(arguments.substr(pos, nextPos - pos));
	}

	//
	// Remove leading spaces from arguments.
	//
	for (std::vector<cString>::iterator it = argumentList.begin(); it != argumentList.end(); it++) {
		std::string::size_type pos = it->find_first_not_of(' ');
		if (pos != std::string::npos) {
			it->erase(0, pos);
		}
	}

	//
	// Remove trailing spaces from arguments
	//
	for (std::vector<cString>::iterator it = argumentList.begin(); it != argumentList.end(); it++) {
		std::string::size_type pos = it->find_last_not_of(' ');
		if (pos != std::string::npos) {
			it->erase(pos + 1);
		}
	}

	//
	// Split the values from the parameter name
	//
	cString arg;
	for (std::vector<cString>::iterator it = argumentList.begin(); it != argumentList.end(); it++) {
		arg = *it;
		pos = arg.find_first_of(_L(":"), 0);
		if (pos != cString::npos) {
			m_ArgumentMap.insert(std::make_pair(arg.substr(0, pos), arg.substr(pos + 1, std::string::npos)));
		} else {
			m_ArgumentMap.insert(std::make_pair(arg.substr(0, pos), _L("")));
		}
	}

	return;
}
开发者ID:Cristianohh,项目名称:InstancingAndroid,代码行数:58,代码来源:CPUTParser.cpp


示例13: rfind

uint cString::rfind(const cString& string,
                    uint startIndex) const
{
    uint i  = startIndex;
    uint ln = length();
    uint on = string.length();

    // Incase of empty string. Always match
    if (on == 0)
    {
        return startIndex;
    }

    // If the current string is empty, search failed.
    if (ln == 0)
        return 0;

    // If this string doesn't have at least the number of characters 'string'
    // has, the search will probably failed. Returns the length of this string.
    if (ln < on)
        return ln;

    // Set the postion to the end of the string
    if (i >= ln - on)
        i = ln - on;

    bool shouldExit = false;
    do
    {
        /* Try to find a match */
        if (m_buffer->getBuffer()[i] == string.m_buffer->getBuffer()[0])
        {
            /* Scan the reset of the string */
            uint j;
            for (j = i + 1;
                 ((j < ln) && (j < i + on) && (string.m_buffer->getBuffer()[j - i] == m_buffer->getBuffer()[j]));
                 j++)
            {
                /* Match is ok */
            }
            if (j == i + string.length())
                return i;
        }
        // Since i is uint...
        if (i == 0)
            shouldExit = true;
        else
            i--;
    } while (!shouldExit);

    return ln;
}
开发者ID:eladraz,项目名称:xStl,代码行数:52,代码来源:string.cpp


示例14: Resize

/*int cStringList::FromMem(struct memfile &f) {
	int len;
	int bytes=0;
	bytes+=memread(f,&len,sizeof(int));
	cString temp="";
	char * tempchar=NULL;
	for(int i=0; i<len; i++) {
		tempchar=(char*)f.start;
		tempchar+=f.offset;
		temp=tempchar;
		
		bytes+=temp.Length()+1;
		f.offset+=temp.Length()+1;
		(*this)+=temp;
		temp="";
	}
	if((*this)[-1]=="" && Length()!=0) used--;
	return bytes;
}
*/
void cStringList::FromString(const cString &strng, cString delim) {
	if(delim.Length()==1) return FromString(strng,delim[0]);
	delete [] Array;
	Array=NULL;
	allocated=0;
	used=0;	
	Resize(500);
		
	cString substrng=delim;
	cString temp;
	used=1;
	for(int i=0; i<strng.Length(); ) FromString_innerloop(strng,delim,substrng, i);
}
开发者ID:cmd184psu,项目名称:fs-tools,代码行数:33,代码来源:stringlist.cpp


示例15: FromString_innerloop

void cStringList::FromString_innerloop(const cString & strng, cString delim, cString &substrng, int & i) {
	int s=strng.Length();
	for(int j=0; j<delim.Length() && i+j<strng.Length(); j++) substrng[j]=strng[i+j];
	if(substrng!=delim && i<s) {
		if(used+1>allocated) {
			Resize(allocated+500);
		}
		Array[used-1]+=strng[i];
		i++;
	} else {
		used++;
		i+=substrng.Length();
	}
}
开发者ID:cmd184psu,项目名称:fs-tools,代码行数:14,代码来源:stringlist.cpp


示例16: if

tVoid DriverFilter::getManeuverFromString(const cString &name, Maneuver &maneuver)
{
	if (name.Compare("left") == 0)
	{
		maneuver = MANEUVER_LEFT;
	}
	else if (name.Compare("right") == 0)
	{
		maneuver = MANEUVER_RIGHT;
	}
	else if (name.Compare("straight") == 0)
	{
		maneuver = MANEUVER_STRAIGHT;
	}
	else if (name.Compare("parallel_parking") == 0)
	{
		maneuver = MANEUVER_PARALLEL_PARKING;
	}
	else if (name.Compare("cross_parking") == 0)
	{
		maneuver = MANEUVER_CROSS_PARKING;
	}
	else if (name.Compare("pull_out_right") == 0)
	{
		maneuver = MANEUVER_PULL_OUT_RIGHT;
	}
	else if (name.Compare("pull_out_left") == 0)
	{
		maneuver = MANEUVER_PULL_OUT_LEFT;
	}
	else
	{
		LOG_INFO(cString::Format("Unbekannter Befehl: %s", name.GetPtr()));
	}
}
开发者ID:ZickZakk,项目名称:HTWK_SmartDriving_2015,代码行数:35,代码来源:DriverFilter.cpp


示例17: isFileExist

bool cFile::isFileExist(const cString& filename)
{
    WIN32_FIND_DATA findData;
    HANDLE hFind = FindFirstFile(OS_CSTRING(filename.getBuffer()), &findData);
    if (hFind == INVALID_HANDLE_VALUE)
        return false;
    FindClose(hFind);

    // If filename contains * or ? character this prevent any problems.
    if ((filename.find("*") == filename.length()) &&
        (filename.find("?") == filename.length()))
        return true;
    return false;
}
开发者ID:eladraz,项目名称:xStl,代码行数:14,代码来源:winFile.cpp


示例18: SetText

void CPUTGUIElement::SetText(cString string)
{
    DEBUG_PRINT(_L("GUIElement SetText: %s"), string.c_str());
    mText = string;
    if(mpFont && mpTextMaterial)
    {
        DEBUG_PRINT(_L("\t have font and material"));
        if(!mpTextMesh)
        {
#ifdef CPUT_FOR_DX11
            mpTextMesh = new CPUTMeshDX11();
#else
            mpTextMesh = new CPUTMeshOGL();
#endif
        }
        unsigned int numCharacters = (unsigned int) string.size();
        unsigned int numVertices = numCharacters * 6;
        CPUTGUIVertex* pVB = new CPUTGUIVertex[numVertices];

        CPUTBufferElementInfo pGUIVertex[3] = {
            { "POSITION", 0, 0, CPUT_F32, 3, 3*sizeof(float), 0 },            
            { "TEXCOORD", 0, 1, CPUT_F32, 2, 2*sizeof(float), 3*sizeof(float)},
            { "COLOR",    0, 2, CPUT_F32, 4, 4*sizeof(float), 5*sizeof(float)},
        };
        mpFont->LayoutText(NULL, &mTextWidth, &mTextHeight, mText, 0, 0);
        mTextX = (mWidth-mTextWidth)/2;
        mTextY = (mHeight-mTextHeight)/2;
        mpFont->LayoutText(pVB, &mTextWidth, &mTextHeight, mText, 0, 0);
        mpTextMesh->CreateNativeResources(NULL, 1, 3, pGUIVertex, numVertices, pVB, NULL, 0, NULL);
        
#ifdef CPUT_FOR_DX11
        mpTextMesh->SetMeshTopology(CPUT_TOPOLOGY_INDEXED_TRIANGLE_LIST);
        
        D3D11_INPUT_ELEMENT_DESC layout[] =
        {
            { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },            
            { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
            { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 },
        };
        UINT numElements = ARRAYSIZE( layout );
        ID3DBlob* pBlob = ((CPUTMaterialEffectDX11*)mpTextMaterial->GetMaterialEffects()[0])->GetVertexShader()->GetBlob();
        
        CPUT_DX11::GetDevice()->CreateInputLayout( layout, numElements, pBlob->GetBufferPointer(), pBlob->GetBufferSize(), &mpVertexLayout );
        CPUTSetDebugName( mpVertexLayout, "CPUT GUI InputLayout object");
#else
#endif
        SAFE_DELETE_ARRAY(pVB);
    }
}
开发者ID:swq0553,项目名称:ClusteredShadingAndroid,代码行数:49,代码来源:CPUTGUIElement.cpp


示例19: ReadFileContents

// Read the entire contents of a file and return a pointer/size to it
//-----------------------------------------------------------------------------
CPUTResult CPUTFileSystem::ReadFileContents(const cString &fileName, UINT *pSizeInBytes, void **ppData, bool bAddTerminator, bool bLoadAsBinary)
{
    FILE *pFile = NULL;

    errno_t err;
    if (bLoadAsBinary) {
#if defined (UNICODE) || defined(_UNICODE)
        err = _wfopen_s(&pFile, fileName.c_str(), _L("rb"));
#else
        err = fopen_s(&pFile, fileName.c_str(), "rb");
#endif
    } else {
#if defined (UNICODE) || defined(_UNICODE)
        err = _wfopen_s(&pFile, fileName.c_str(), _L("r"));
#else
        err = fopen_s(&pFile, fileName.c_str(), "r");
#endif
    }

    if(0 == err)
    {
        // get file size
        fseek(pFile, 0, SEEK_END);
        *pSizeInBytes = ftell(pFile);
        fseek (pFile, 0, SEEK_SET);

        // allocate buffer
        *ppData = (void*) new char[*pSizeInBytes];
        ASSERT( *ppData, _L("Out of memory") );

        // read it all in
        UINT numBytesRead = (UINT) fread(*ppData, sizeof(char), *pSizeInBytes, pFile);
        if (bAddTerminator)
        {
            ((char *)(*ppData))[numBytesRead++] = '\0';
            (*pSizeInBytes)++;
        }
        //fixme - this isn't doing what it appears to be doing. counts off for Windows...
        //ASSERT( numBytesRead == *pSizeInBytes, _L("File read byte count mismatch.") );
        UNREFERENCED_PARAMETER(numBytesRead);

        // close and return
        fclose(pFile);
        return CPUT_SUCCESS;
    }

    // some kind of file error, translate the error code and return it
    return TranslateFileError(err);
}
开发者ID:Cristianohh,项目名称:InstancingAndroid,代码行数:51,代码来源:CPUTOSServicesWin.cpp


示例20: CPUTSetDebugName

//-----------------------------------------------------------------------------
void CPUTSetDebugName( void *pResource, cString name )
{
#ifdef _DEBUG
    char pCharString[CPUT_MAX_STRING_LENGTH];
    const wchar_t *pWideString = name.c_str();
    UINT ii;
    UINT length = min( (UINT)name.length(), (CPUT_MAX_STRING_LENGTH-1));
    for(ii=0; ii<length; ii++)
    {
        pCharString[ii] = (char)pWideString[ii];
    }
    pCharString[ii] = 0; // Force NULL termination
    ((ID3D11DeviceChild*)pResource)->SetPrivateData( WKPDID_D3DDebugObjectName, (UINT)name.length(), pCharString );
#endif // _DEBUG
}
开发者ID:galek,项目名称:SoftOcclude,代码行数:16,代码来源:CPUT_DX11.cpp



注:本文中的cString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cTheme类代码示例发布时间:2022-05-31
下一篇:
C++ cRng类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap