コード例 #1
0
ファイル: NString.cpp プロジェクト: 708y/TextBE2
void NString::Replace(NString strToReplace, NString strReplaceWith){
	size_t position;
	int iLength = strToReplace.GetString().length();
	position = m_strInfo.find(strToReplace.GetString());
	while (position != std::string::npos){
		m_strInfo.replace(position,iLength,strReplaceWith.GetString());
		position = m_strInfo.find(strToReplace.GetString());
	}
}
コード例 #2
0
ファイル: NString.cpp プロジェクト: 708y/TextBE2
int NString::Find(NString strSecondString){
	size_t result;
	result = m_strInfo.find(strSecondString.GetString());
	if (result != std::string::npos){
		return (int)result;
	}
	return -1;
}
コード例 #3
0
ファイル: NString.cpp プロジェクト: 708y/TextBE2
NString operator+(const char* charlist, NString& strSecondString){ 
/* This is called for things like NString test2 = "hello";
NString test = "hi" + test2;
(where the  part comes first in the addition.
Note that it is not a member of the NString class.
*/
	std::string nestring = charlist + strSecondString.GetString();
	NString newNString;
	newNString.SetString(nestring);
	return newNString;
 }
コード例 #4
0
ファイル: NString.cpp プロジェクト: 708y/TextBE2
void NString::Format(NString strOriginal, int iNumber){
	// Convert the number part into a string.
	std::stringstream stream;
	stream << iNumber;
	std::string strNumber = stream.str();
	// Put the number into the main string, replacing the %d part.
	std::string strMain = strOriginal.GetString();
	size_t position = strMain.find("%d");
	strMain.replace(position,2,strNumber);
	m_strInfo = strMain;
}
コード例 #5
0
ファイル: NFileUtilities.cpp プロジェクト: refnum/nano
//============================================================================
//		NFileUtilities::GetUniqueFile : Get a uniquely-named file.
//----------------------------------------------------------------------------
NFile NFileUtilities::GetUniqueFile(const NFile &theDirectory, const NString &fileName)
{	NString		nameChild, nameFile, nameExt;
	NRange		extBreak;
	NFile		theFile;
	NIndex		n;



	// Validate our parameters
	NN_ASSERT(theDirectory.IsDirectory());



	// Get the state we need
	if (fileName.IsEmpty())
		{
		nameFile = "Temp";
		nameExt  = ".tmp";
		}
	else
		{
		extBreak = fileName.Find(".", kNStringBackwards);
		if (extBreak.GetSize() == 1)
			{
			nameFile = fileName.GetLeft(  extBreak.GetLocation());
			nameExt  = fileName.GetString(extBreak.GetLocation());
			}
		else
			{
			nameFile = fileName;
			nameExt  = "";
			}
		}



	// Generate a unique name
	n = 0;
	
	while (n < 10000)
		{
		// Build the name
		if (n == 0)
			nameChild = nameFile;
		else
			nameChild.Format("%@ %ld", nameFile, n);

		if (!nameExt.IsEmpty())
			nameChild += nameExt;



		// Check for the file
		theFile = theDirectory.GetChild(nameChild);
		if (!theFile.Exists())
			return(theFile);

		n++;
		}



	// Handle failure
	NN_LOG("Unable to create a unique name");
	theFile.Clear();
	
	return(theFile);
}
コード例 #6
0
ファイル: NString.cpp プロジェクト: 708y/TextBE2
void NString::Append(const NString strSecondString){
	m_strInfo.append(strSecondString.GetString());
}
コード例 #7
0
ファイル: NString.cpp プロジェクト: 708y/TextBE2
void NString::operator=(const NString strSecondString){
	m_strInfo = strSecondString.GetString();
}
コード例 #8
0
ファイル: NString.cpp プロジェクト: 708y/TextBE2
bool NString::operator!=(NString& strSecondString){
	if (m_strInfo != strSecondString.GetString()){
		return true;
	}
	return false;
}
コード例 #9
0
ファイル: NString.cpp プロジェクト: 708y/TextBE2
NString NString::operator+(const NString strSecondString){
	std::string nestring = m_strInfo + strSecondString.GetString();
	NString newNString;
	newNString.SetString(nestring);
	return newNString;
}