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


C++ SimpleString::GetStr方法代码示例

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


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

示例1: GetOmiscidServiceDnsSdType

const SimpleString CommonServiceValues::GetOmiscidServiceDnsSdType()
{
	static SimpleString OmiscidServiceDnsSdType;

	if ( OmiscidServiceDnsSdType.IsEmpty() )
	{
		SimpleString DefaultDomain = "_bip._tcp";

		char * Option = getenv( "OMISCID_WORKING_DOMAIN" );
		if ( Option == NULL || DefaultDomain == Option )
		{
			OmiscidServiceDnsSdType = DefaultDomain;
			OmiscidTrace( "OMiSCID working domain not override. Use '%s'.\n", DefaultDomain.GetStr() );
			return OmiscidServiceDnsSdType;
		}

		// Copy the environment variable
		size_t size = strlen( Option );
		TemporaryMemoryBuffer tmpdomain(128);

		if ( size >= RegtypeLength )
		{
			SimpleString Msg = "OMiSCID working domain '";
			Msg += Option;
			Msg += "' too long (";
			Msg += (RegtypeLength-1);
			Msg += ")";

			// Set default domain in cas of exception catch 
			OmiscidServiceDnsSdType = DefaultDomain;
			
			OmiscidError( Msg.GetStr() );
			throw SimpleException( Msg );
		}

		if ( sscanf( Option, "_bip_%[^.]._tcp", (char*)tmpdomain) == 1 )
		{
			// Set default domain in cas of exception catch 
			OmiscidServiceDnsSdType = DefaultDomain;
			
			OmiscidError( "Old style OMiSCID working domain, please conform to new 'XXX._bip._tcp' pattern" );
			throw SimpleException( "Old style OMiSCID working domain, please conform to new 'XXX._bip._tcp' pattern" );
		}

		if ( sscanf( Option, "%[^.]._bip._tcp", (char*)tmpdomain) == 1 )
		{
			OmiscidServiceDnsSdType = Option;
			OmiscidTrace( "OMISCID_WORKING_DOMAIN defined in environment variable. Use '%s'.\n", OmiscidServiceDnsSdType.GetStr() );
			return OmiscidServiceDnsSdType;
		}

		// OMiSCID Domain simplest way to define it
		OmiscidServiceDnsSdType = Option;
		OmiscidTrace( "OMISCID_WORKING_DOMAIN defined in environment variable. Use '%s'.\n", OmiscidServiceDnsSdType.GetStr() );
	}

	return OmiscidServiceDnsSdType;
}
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:58,代码来源:ServicesCommon.cpp

示例2:

SimpleException::SimpleException(const SimpleString m, int i)
{
	OmiscidTrace( "%s : %d\n", m.GetStr(), i );

	msg = m;
	err = i;
}
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:7,代码来源:SimpleException.cpp

示例3: Connect

void ControlServer::Connect(const SimpleString host, int port, bool tcp, InOutputAttribute* ioa)
{
#ifdef DEBUG
	fprintf(stderr, "in ControlServer::Connect (%s:%d", host.GetStr(), port);
	if (tcp) fprintf(stderr, " [TCP] "); else fprintf(stderr, " [UDP] ");
	fprintf(stderr, "%s\n", ioa->GetName().GetStr());
#endif
}
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:8,代码来源:ControlServer.cpp

示例4: ServiceException

RegisterOmiscidService::RegisterOmiscidService( const SimpleString FullName, uint16_t ePort, bool AutoRegister /* = false */ )
	: RegisterService( FullName, ePort, /* AutoRegister = */ false, /* AutoRename */ false )
{
	if ( strstr( FullName.GetStr(), GetOmiscidServiceDnsSdType().GetStr() ) == NULL )
	{
		throw ServiceException( "It do not seem to be a valid BIP service" );
	}

	Init(AutoRegister);
}
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:10,代码来源:ServicesTools.cpp

示例5: GenerateHeaderDescription

void Attribute::GenerateHeaderDescription(const SimpleString& type,
										  const SimpleString& name,
										  SimpleString& str,
										  bool end)
{
	// "<"+ type + " name=\"" + name + "\"/>" at max
	TemporaryMemoryBuffer MemBuff( 1 + type.GetLength() + 7 + name.GetLength() + 4 );
	if ( end == true )
	{
		snprintf( (char*)MemBuff, MemBuff.GetLength(), "<%s name=\"%s\"/>", type.GetStr(), name.GetStr() );
	}
	else
	{
		snprintf( (char*)MemBuff, MemBuff.GetLength(), "<%s name=\"%s\">", type.GetStr(), name.GetStr() );
	}

	str += (char*)MemBuff;

	//str = str + "<"+ type + " name=\"" + name;
	//if(end) str = str + "\"/>";
	//else  str = str + "\">";
}
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:22,代码来源:Attribute.cpp

示例6: GetConnectionInfos

bool ServiceProxy::GetConnectionInfos( const SimpleString Connector, ConnectionInfos& Connection )
{
	InOutputAttribute * pAtt = FindConnector( Connector );
	if ( pAtt == (InOutputAttribute *)NULL )
	{
		OmiscidError( "Could not find connector nammed '%s'\n", Connector.GetStr() );
		return false;
	}

	Connection.TcpPort = pAtt->GetTcpPort();
	Connection.UdpPort = pAtt->GetUdpPort();
	Connection.Type	   = pAtt->GetType();

	return true;
}
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:15,代码来源:ServiceProxy.cpp

示例7: VariableChange

void ControlServer::VariableChange( VariableAttribute* va, SimpleString NewValue, ControlServerStatus status )
{
	OmiscidTrace( "ControlServer::VariableChange '%s' New Value='%s'\n", va->GetName().GetStr(), NewValue.GetStr());
	// Do what we must do...

	// va will call back me to know if I agree to change it's value
	// va will also notify me that the value has changed (if change have been validated)
	va->SetValue( NewValue );
}
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:9,代码来源:ControlServer.cpp

示例8: ProcessAMessage

void ControlServer::ProcessAMessage(XMLMessage* msg)
{
	// OmiscidTrace( "in ControlServer::ProcessAMessage\n");
	// OmiscidTrace( "from pid = %u \n",msg->pid);

	if ( msg == NULL )
	{
		// Nothing to do
		return;
	}

	xmlNodePtr node = msg->GetRootNode();

	SmartLocker SL_AutoProtect(AutoProtect);

	// if( strcmp((const char*)node->name, "controlQuery") == 0 )
	if ( ControlQueryValidator.ValidateDoc(msg->doc) )
	{
		SL_AutoProtect.Unlock();

		SimpleString id;
		xmlAttrPtr attr = XMLMessage::FindAttribute("id", node);
		if ( attr != (xmlAttrPtr)NULL )
		{
			id = SimpleString((const char*)attr->children->content);
		}

		bool ReplyAnAnswer = true;	// default
		SimpleString str;

		if ( node->children == NULL )
		{
			//global description
			GenerateGlobalShortDescription(str);
		}
		else
		{
			// more precise request
			xmlNodePtr cur_node = node->children;
			for(; cur_node; cur_node = cur_node->next)
			{
				SimpleString name = (const char*)(cur_node->name);
				//std::cerr << "tag name="<<(*it)->name <<"\n";
				if( name == InOutputAttribute::input_str.GetStr() ||
					name == InOutputAttribute::output_str.GetStr() ||
					name == InOutputAttribute::inoutput_str.GetStr() )
				{
					// OmiscidTrace( " process io : %s \n", (*it)->name.GetStr());
					ProcessInOutputQuery(cur_node, str);
				}
				else if( name == VariableAttribute::VariableStr )
				{
					ProcessVariableQuery(cur_node, msg->pid,  str);
				}
				else if( name == "connect" )
				{
					ProcessConnectQuery(cur_node, str);
				}
				else if( name == "subscribe" )
				{
					ProcessSubscribeQuery(cur_node, msg->pid, true, str);
				}
				else if( name == "unsubscribe" )
				{
					ReplyAnAnswer = false;
					ProcessSubscribeQuery(cur_node, msg->pid, false, str);
				}
				else if( name == "lock" )
				{
					ProcessLockQuery(cur_node, msg->pid, true, str);
				}
				else if( name == "unlock" )
				{
					ProcessLockQuery(cur_node, msg->pid, false, str);
				}
				else if( name == "fullDescription" )
				{
					ProcessFullDescriptionQuery(cur_node, str);
				}
				else
				{
					// Should not appear
					OmiscidError( "unknown tag : %s\n", name.GetStr() );
				}
			}
			// OmiscidError( "Send : %s \n", str.GetStr());
		}

		if ( ReplyAnAnswer == true )
		{
			str = "<controlAnswer id=\""+id+"\">"
				+ str
				+ "</controlAnswer>";

#ifdef DEBUG
			SL_AutoProtect.Lock();
			if ( ControlAnswerValidator.ValidateDoc( str ) == false )
			{
				OmiscidError( "ControlServer::ProcessAMessage: bad ControlAnswer sent.\n" );
			}
//.........这里部分代码省略.........
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:101,代码来源:ControlServer.cpp

示例9: DisplayServiceGlobalShortDescription

void ControlServer::DisplayServiceGlobalShortDescription()
{
	SimpleString str;
	GenerateGlobalShortDescription(str);
	printf("%s\n", str.GetStr());
}
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:6,代码来源:ControlServer.cpp

示例10: Receive


//.........这里部分代码省略.........
					}
					//					else if(length_msg == 0)
					//					{
					//						//std::cout << "Empty Msg from "<<pid<<"\n";
					//						offset += length_header;
					//						size =  occupiedSize - offset;
					//					}
					else
					{
						offset += length_header;

						unsigned char* msgptr =  (buffer+offset);

						//verif end tag
						if( memcmp(tag_end, (msgptr + length_msg), tag_end_size))
						{
							OmiscidTrace( "warning end tag\n");
							size =  occupiedSize - offset;
						}
						else
						{
							offset += length_msg + tag_end_size;
							size =  occupiedSize - offset;
#ifdef DEBUG
							if ( Debug & DBG_RECV )
							{
								if ( length_msg != 0 )
								{
									SimpleString SFormat = "MsgSocket::Recv: %";
									SFormat += length_msg;
									SFormat += ".";
									SFormat += length_msg;
									SFormat += "s\n";
									fprintf( stderr, SFormat.GetStr(), msgptr );
								}
								else
								{
									fprintf( stderr, "MsgSocket::Recv: <empty>\n" );
								}
							}
#endif
							// Send info to all receiver
							SL_CallbackObjects.Lock();
							if ( CallbackObjects.GetNumberOfElements() )
							{
								// Prepare data
								*(msgptr+length_msg)='\0';
								callbackData.Msg.len = length_msg;
								if ( length_msg != 0 )
								{
									callbackData.Msg.buffer =  (char*)msgptr;
								}
								else
								{
									callbackData.Msg.buffer =  (char*)NULL;
								}
								callbackData.Msg.origine = FromTCP;
								callbackData.Msg.pid = pid;
								callbackData.Msg.mid = mid;

								// Send info to all listener
								for( CallbackObjects.First(); CallbackObjects.NotAtEnd(); CallbackObjects.Next() )
								{
									try
									{
										CallbackObjects.GetCurrent()->Receive(*this, callbackData);
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:67,代码来源:MsgSocket.cpp

示例11: Disconnected

	/**
	 * Called when the connexion between the local service and the remote
	 * service is broken.
	 * @param TheService A reference to the service which losts a connection
	 * @param LocalConnectorName the name of the connector handling the broken link
	 * @param PeerId the disconnected remote service PeerId
	 */
void ConnectorListener::Disconnected(Service& TheService, const SimpleString LocalConnectorName, unsigned int PeerId)
{
	OmiscidTrace( "The peer %8.8x disconnects from %s:%s.\n", PeerId, TheService.GetName().GetStr(), LocalConnectorName.GetStr() );
}
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:11,代码来源:ConnectorListener.cpp

示例12: ControlClient

ServiceProxy::ServiceProxy( unsigned int PeerId, SimpleString eHostName, int eControlPort, ServiceProperties& ServiceProps )
	: ControlClient(PeerId)
{
	SimpleString TmpString;
	VariableAttribute * VarAtt;
	InOutputAttribute * IOAtt;
	int Pos;
	unsigned int Port;

	HostName	= eHostName;
	ControlPort	= eControlPort;
	FullDescription = false;

	// Is the description
	TmpString = ServiceProps["desc"].GetValue();
	//if ( ServiceProps.IsDefined( "name" ) )
	//{
	//	OmiscidError( "Warning, forced fallback for '%s' (%s).\n",
	//		ServiceProps[NameString].GetValue().GetStr(), ServiceProps["id"].GetValue().GetStr() );
	//}
	//else
	//{
	//	OmiscidError( "Warning, forced fallback for %8.8x.\n", PeerId );
	//}
	//if ( TmpString == "forced fallback" )
	// OmiscidTrace( "Working on'%s' (%s).\n",
	//	 ServiceProps[ControlServer::NameString].GetValue().GetStr(), ServiceProps["id"].GetValue().GetStr() );

	if ( TmpString == "full" )
	{
		FullDescription = true;
	}

	for( Pos = 0; Pos <  ServiceProps.GetNumberOfProperties(); Pos++ )
	{
		ServiceProperty& LocalProp = ServiceProps.GetProperty(Pos);

		if ( LocalProp.GetName() == "desc" )
		{
			continue;
		}

		// SimpleString TmpName = LocalProp.GetName();

		// Parse property
		TmpString = LocalProp.GetValue();
		char * TmpChar = (char*)TmpString.GetStr();
		switch( TmpString[0] )
		{
			// Work on Variables
			case 'c':
				if ( TmpString.GetLength() <= 2 || TmpString[1] != '/' )
				{
					FullDescription = false;
					continue;
				}

				// Ok, something like c/...
				VarAtt = new OMISCID_TLM VariableAttribute( LocalProp.GetName() );
				if ( VarAtt == NULL )
				{
					FullDescription = false;
					continue;
				}
				VarAtt->SetValue( TmpChar+2 );
				VarAtt->SetAccessConstant();
				listVariableName.Add( LocalProp.GetName() );
				listVariableAttr.Add( VarAtt );
				break;

			case 'r':
				if ( TmpString.GetLength() != 1 )
				{
					FullDescription = false;
					continue;
				}

				// Ok, something like r/...
				VarAtt = new OMISCID_TLM VariableAttribute( LocalProp.GetName() );
				if ( VarAtt == NULL )
				{
					FullDescription = false;
					continue;
				}
				VarAtt->SetAccessRead();
				listVariableName.Add( LocalProp.GetName() );
				listVariableAttr.Add( VarAtt );
				break;

			case 'w':
				if ( TmpString.GetLength() != 1 )
				{
					FullDescription = false;
					continue;
				}

				// Ok, something like w/...
				VarAtt = new OMISCID_TLM VariableAttribute( LocalProp.GetName() );
				if ( VarAtt == NULL )
				{
//.........这里部分代码省略.........
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:101,代码来源:ServiceProxy.cpp

示例13: main


//.........这里部分代码省略.........
			ConnectionString = Argument+1;

			ConnectionObjects = ParseConnectionString( argv[ConnectionString], false );
			if ( ConnectionObjects <= 0 )
			{
				sprintf( Message, "Bad connection string in parameter %d\n", Argument+1 );
				Usage( (const char *)Message );
			}

			Argument += 1;
			continue;
		}

		if ( strcmp( "-d", argv[Argument]) == 0 )
		{
			if ( Debug )
			{
				fprintf( stderr, "Warning: debug mode already set\n" );
			}
			Debug = true;
			continue;
		}

		sprintf( Message, "invalid option in parameter %d ('%s')", Argument+1, argv[Argument] );
		Usage( (const char *)Message );
	}

#ifdef _DEBUG
		// MsgSocket::Debug = MsgSocket::DBG_LINKSYNC;
#endif

	// Ok, it seems that parameters looks ok...
	// start registering service
	if ( Debug ) { printf("Launching service '%s' ", ServiceName.GetStr() ); }

	Service * pServ = ServiceFactory.Create( ServiceName );
	if ( Debug ) { printf("with ServiceId %s\n", pServ->GetPeerIdAsString().GetStr() ); }

	// Check argument before launching any registering process
	for( Argument = 2; Argument < argc; Argument++ )
	{
		if ( strcmp( "-o", argv[Argument]) == 0 )
		{
			pServ->AddConnector( argv[Argument+1], argv[Argument+2], AnOutput );

			Argument += 2;
			continue;
		}

		if ( strcmp( "-i", argv[Argument]) == 0 )
		{
			pServ->AddConnector( argv[Argument+1], argv[Argument+2], AnInput );

			Argument += 2;
			continue;
		}

		if ( strcmp( "-io", argv[Argument]) == 0 )
		{
			pServ->AddConnector( argv[Argument+1], argv[Argument+2], AnInOutput );

			Argument += 2;
			continue;
		}

		if ( strcmp( "-v", argv[Argument]) == 0 )
开发者ID:AmibisLabs,项目名称:amibis-cpp,代码行数:67,代码来源:BipService.cpp


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