当前位置: 首页>>代码示例>>C++>>正文


C++ String::Cstr方法代码示例

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


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

示例1:

RoundRoom::RoundRoom(String& name, int a_roomID, String& object)
{
	
	roomID = a_roomID;
	roomName.Append( name.Cstr() );
	Object.Append(object.Cstr());
}
开发者ID:Nayrn,项目名称:New,代码行数:7,代码来源:RoundRoom.cpp

示例2: Compare

int32 String::Compare(const String& stringA, const String& stringB, bool caseSensitive)
{
	if (!caseSensitive)
	{
		return String::Compare(stringA.ToLower(), stringB.ToLower(), true);
	}

	return strcmp(stringA.Cstr(), stringB.Cstr());
}
开发者ID:willcassella,项目名称:WillowEngine,代码行数:9,代码来源:String.cpp

示例3: GetPeerIPAddress

void
WUploadThread::SetUpload(const ConstSocketRef &socket, muscle::ip_address remoteIP, WFileThread * ft)
{
	String host;
	fAccept = false;
	fRemoteIP = remoteIP;
	fSocket = socket;
	fFileThread = ft;
	// Set string ip too
	muscle::ip_address _ip = GetPeerIPAddress(fSocket, true);
	host = Inet_NtoA(_ip, true);
	fStrRemoteIP = host.Cstr();
}
开发者ID:mtl1979,项目名称:unizone,代码行数:13,代码来源:uploadthread.cpp

示例4: PublicCommands

//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
bool VoidBot::PublicCommands(const char* SessionID, const String& Command)
{
// todo: these should all be busted out into their own functions

	// "Message For" command
	String keyword("message for");
	int32 pos = WholeWordPos(Command, keyword.Cstr());
	if( B_ERROR != pos )
	{
		if( 2048 < Command.Length() )
		{
			SendMessage(SessionID, "There is _no way_ I can remember all that, please phrase the message shorter.");
			return true;
		}

		pos += keyword.Length();
		String name(GetNick(Command, pos));
		if( 0 == name.Length() )
		{
			SendMessage(SessionID, "Please specify a nick!");
			return true;
		}

		if( B_ERROR != name.IndexOf(' ') )
		{
			// name with space, adjust for delimiter chars.
			pos += 2;
		}

		pos += name.Length() + 1;

		if( (int32)Command.Length() < (pos - 1) )
		{
			SendMessage(SessionID, "Please specify a message.");
			return true;
		}

		String message("Message from ");
		message += fData.UserByID(SessionID)->Name();
		message += " Left at";
		message += " [";
		message += Time();
		message += "]";
		message += ": ";
		message += Command.Substring(pos);
		fMessagesForName[name].push_back(message);
		SendPrivateMessage(SessionID, "Will there be anything else?.");
		fReportedNewMessages[name] = false;
		return true;
	}

	// "Seen" command
	keyword = "seen";
	pos = WholeWordPos(Command, keyword.Cstr());
	if( -1 != pos )
	{
		pos += keyword.Length();

		String name(GetNick(Command, pos));
		if( 0 == name.Length() )
		{
			SendMessage(SessionID, "Please specify a nick!");
			return true;
		}

		if( fLastWords.find(name.Cstr()) != fLastWords.end() )
		{
			String info(name);
			info += " was last seen ";
			info += fLastWords[name.Cstr()];
			SendMessage(SessionID, info.Cstr());
		}
		else
		{
			String negatory("No, I haven't seen ");
			negatory += name;
			SendMessage(SessionID, negatory.Cstr());
		}
		return true;
	}

		//*****************<FORTUNE ADDED BY MISZA>************************//
	pos = WholeWordPos(Command, "fortune");
	if(-1 != pos)
	{
		FILE *fp = popen ("fortune", "r");
		if(fp != NULL)
		{
			char ch;
			String cool= "\n";

			while((ch = fgetc(fp))!= EOF)
			{
				cool += ch;
			}

			fclose(fp);
			if(cool != "\n")
//.........这里部分代码省略.........
开发者ID:ModeenF,项目名称:atrus,代码行数:101,代码来源:VoidBot.cpp

示例5: main

// This program exercises the Message class.
int main(void)
{
   Message m1;
   m1.AddFloat("va", 1.0f);
   printf("m1=" UINT32_FORMAT_SPEC "\n", m1.FlattenedSize());
   m1.AddInt32("co", 32);
   printf("m2=" UINT32_FORMAT_SPEC "\n", m1.FlattenedSize());

   printSep("Testing Replace*() with okayToAdd...");
   Message butter;
   butter.ReplaceInt8(true, "int8", 8);
   butter.ReplaceInt16(true, "int16", 16);
   butter.ReplaceInt32(true, "int32", 32);
   butter.ReplaceInt64(true, "int64", 64);
   butter.ReplaceFloat(true, "float", 3.14f);
   butter.ReplaceDouble(true, "double", 6.28);
   butter.ReplacePoint(true, "point", Point(5,4));
   butter.ReplaceRect(true, "rect", Rect(5,6,7,8));
   butter.ReplacePointer(true, "pointer", &butter);
   butter.PrintToStream();

   butter.ReplaceInt16(true, "int16", 0, 17);
   butter.ReplaceInt16(true, "int16", 1, 18);
   butter.ReplaceInt8(true, "int8", 25, 25);  // should work the same as AddInt8("int8", 25);

   butter.AddTag("Tag", RefCountableRef(GetMessageFromPool(6666)()));
   butter.AddTag("Tag", RefCountableRef(GetMessageFromPool(7777)()));
   butter.PrintToStream();

   printf("(butter==m1) == %i\n", butter == m1);
   printf("(butter==butter) == %i\n", butter == butter);

   printSep("Testing Add*()...");

   Message msg(COMMAND_HELLO);
   TEST(msg.AddString("Friesner", "Jeremy"));
   TEST(msg.AddString("Friesner", "Joanna"));
   TEST(msg.AddString("Friesner", "Joellen"));
   TEST(msg.AddString("Chicken", "Soup"));
   TEST(msg.AddString("Chicken", "Vegetable"));
   TEST(msg.AddString("Chicken", "Lips"));
   TEST(msg.AddString("Fred", "Flintstone"));
   TEST(msg.AddString("Buddha", "Bark"));
   TEST(msg.AddPoint("point12", Point(1,2)));
   TEST(msg.AddPoint("point12", Point(2,1)));
   TEST(msg.AddRect("rect1234", Rect(1,2,3,4)));
   TEST(msg.AddRect("rect2345", Rect(2,3,4,5)));
   TEST(msg.AddData("Data", B_RAW_TYPE, "ABCDEFGHIJKLMNOPQRS", 12));
   TEST(msg.AddData("Data", B_RAW_TYPE, "Mouse", 3));

   Message subMessage(1);
   TEST(subMessage.AddString("I am a", "sub message!"));
   TEST(subMessage.AddInt32("My age is", 32));

   Message subsubMessage(2);
   TEST(subsubMessage.AddBool("Wow, that's deep!", true));
   TEST(subsubMessage.AddMessage("This is actually okay to do!", subsubMessage));
   TEST(subMessage.AddMessage("subsubMessage", subsubMessage));

   TEST(msg.AddMessage("subMessage", subMessage));

   {for (int i=0; i<10; i++) TEST(msg.AddInt8("TestInt8", i));    }
   {for (int i=0; i<10; i++) TEST(msg.AddInt16("TestInt16", i));  }
   {for (int i=0; i<10; i++) TEST(msg.AddInt32("TestInt32", i));  }
   {for (int i=0; i<10; i++) TEST(msg.AddInt64("TestInt64", i));  }
   {for (int i=0; i<10; i++) TEST(msg.AddDouble("TestDouble", i));}
   {for (int i=0; i<10; i++) TEST(msg.AddFloat("TestFloat", i));  }
   {for (int i=0; i<10; i++) TEST(msg.AddBool("TestBool", i));    }

   printf("Finished message:\n");
   msg.PrintToStream();

   printSep("Testing RemoveName, RemoveData, Replace*()...");
   TEST(msg.RemoveData("TestInt8", 5));
   TEST(msg.RemoveName("Buddha"));
   TEST(msg.RemoveData("Fred", 0));
   TEST(msg.RemoveData("Friesner", 1));
   NEGATIVETEST(msg.RemoveData("Glorp", 0));
   NEGATIVETEST(msg.RemoveData("Chicken", 5));
   TEST(msg.ReplaceString(false, "Friesner", 0, "Jorge"));
   TEST(msg.ReplaceString(false, "Chicken", 1, "Feet"));
   TEST(msg.ReplaceString(false, "Chicken", 2, "Breast"));
   NEGATIVETEST(msg.ReplaceString(false, "Chicken", 3, "Soul"));
   TEST(msg.ReplaceDouble(true, "TestDouble", 2, 222.222));
   TEST(msg.ReplaceFloat(true, "TestFloat", 3, 333.333));
   NEGATIVETEST(msg.ReplaceFloat(false, "RootBeerFloat", 0, 444.444f));
   TEST(msg.ReplaceBool(false, "TestBool", 5));
   TEST(msg.ReplaceRect(false, "rect2345", Rect(2,3,4,5)));

   Message eqMsg = msg;
   printf("EQMSG=msg == %i\n", eqMsg==msg);

   printf("Replaced message:\n");
   msg.PrintToStream();

   printSep("Testing the Find() commands...");
   String strResult;
   TEST(msg.FindString("Friesner", strResult));
   printf("Friesner(0) = %s\n", strResult.Cstr());
//.........这里部分代码省略.........
开发者ID:mtl1979,项目名称:muscle,代码行数:101,代码来源:testqueryfilter.cpp

示例6: Equals

	bool String::Equals(const String& other) const
	{
		return !strcmp(data, other.Cstr());
	}
开发者ID:kevinrichey,项目名称:CppLib,代码行数:4,代码来源:kwrstring.cpp

示例7: data

	String::String(const String& other)
		: data(new char[other.Length()+1])
	{
		strcpy(data, other.Cstr());
	}
开发者ID:kevinrichey,项目名称:CppLib,代码行数:5,代码来源:kwrstring.cpp

示例8:

	void FromString<long double>::Function(String& out, long double& value, const String& string)
	{
		std::size_t remainder;
		value = std::stold(string.Cstr(), &remainder);
		out = string.SubString(remainder);
	}
开发者ID:willcassella,项目名称:WillowEngine,代码行数:6,代码来源:FromString.cpp


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