本文整理汇总了C++中ACE_CString::substring方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_CString::substring方法的具体用法?C++ ACE_CString::substring怎么用?C++ ACE_CString::substring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_CString
的用法示例。
在下文中一共展示了ACE_CString::substring方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jo_key
Server_Info_Ptr
Locator_Repository::get_active_server (const ACE_CString& name, int pid)
{
sync_load ();
ACE_CString key;
Server_Info_Ptr si;
if (name.length() == 0)
{
return si;
}
Server_Info::fqname_to_key (name.c_str(), key);
servers ().find (key, si);
if (si.null())
{
if (this->opts_.debug() > 5)
{
ORBSVCS_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) get_active_server could not find %C\n"),
name.c_str()));
}
si = find_by_poa (key);
if (si.null())
{
if (name.find ("JACORB:") == ACE_CString::npos)
{
ACE_CString jo_key ("JACORB:");
ACE_CString::size_type pos = name.find (':');
if (pos == ACE_CString::npos)
{
jo_key += name;
}
else
{
jo_key += name.substring (0, pos);
jo_key += '/';
jo_key += name.substring (pos+1);
}
return this->get_active_server (jo_key, pid);
}
else
{
return si;
}
}
}
if (pid != 0 && si->pid != 0 && si->pid != pid)
{
if (this->opts_.debug() > 5)
{
ORBSVCS_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) get_active_server could not")
ACE_TEXT (" find %C, %d != %d\n"),
name.c_str(), pid, si->pid));
}
si.reset ();
}
return si;
}
示例2:
int
HTML_Body_Iterator::next (ACE_CString &url)
{
size_t len = BUFSIZ;
const char *buf;
ACE_CString buffer;
int href_index = 0;
for (buf = this->url_.stream ().recv (len);
buf > 0;
buf = this->url_.stream ().recv (len))
{
buffer.set (buf, BUFSIZ, 1);
href_index = ACE_Utils::truncate_cast<int> (buffer.find ("HREF"));
if (href_index < 0)
href_index = ACE_Utils::truncate_cast<int> (buffer.find ("href"));
// Grep fpr " and grab the string until end-"
if ( href_index > 0)
{
// Get back to buffer start location.
this->url_.stream ().seek (-1 * static_cast<ACE_OFF_T> (len),
SEEK_CUR);
int start_index =
ACE_Utils::truncate_cast<int> (
buffer.find ('\"', href_index));
if (start_index <= 0)
break;
start_index += href_index;
int end_index =
ACE_Utils::truncate_cast<int> (
buffer.find ('\"', start_index + 1));
if (end_index <= 0)
break;
end_index += start_index + 1;
ssize_t url_len = end_index - (start_index + 1);
ACE_CString temp = buffer.substring (start_index + 1,
url_len);
url.set (temp.c_str (), len, 1);
this->url_.stream ().seek (end_index + 1);
return url_len;
}
}
return 0;
}
示例3: dup_src_file
//
// get_target_basename
//
const ACE_CString & BE_GlobalData::get_target_basename (void) const
{
if (!this->target_basename_.empty ())
return this->target_basename_;
// Normalize the source file name.
ACE_CString dup_src_file (this->source_file_);
std::replace (dup_src_file.begin (), dup_src_file.end (), '\\', '/');
// Extract the basename of the source file. This include removing
// the path from the source file, and removing its extension.
size_t pos = dup_src_file.rfind ('/');
ACE_CString filename;
BE_GlobalData::get_filename (dup_src_file, filename);
pos = filename.rfind ('.');
this->target_basename_ = pos == ACE_CString::npos ? filename : filename.substring (0, pos);
this->target_basename_ += this->suffix_;
return this->target_basename_;
}
示例4: while
bool
ImR_Locator_i::split_key (ACE_CString &full, ACE_CString &key, Server_Info_Ptr &si)
{
key = full;
if (this->get_info_for_name (full.c_str(), si))
{
return true;
}
ACE_CString::size_type pos = full.rfind ('/');
while (pos != ACE_CString::npos)
{
ACE_CString server = full.substring (0, pos);
if (this->get_info_for_name (server.c_str (), si))
{
return true;
}
pos = server.rfind ('/');
}
return false;
}
示例5:
int
TAO_ORB_Parameters::parse_and_add_endpoints (const ACE_CString &endpoints,
TAO_EndpointSet &endpoint_set)
{
// Parse the string into seperate endpoints, where `endpoints' is of
// the form:
//
// protocol1://V,[email protected],...,addrN;protocol2://addr1,...,[email protected];...
//
// A single endpoint, instead of several, can be added just as well.
static char const endpoints_delimiter = ';';
size_t const length = endpoints.length ();
if (endpoints[0] == endpoints_delimiter ||
endpoints[length - 1] == endpoints_delimiter)
{
return -1;
// Failure: endpoints string has an empty endpoint at the
// beginning or the end of the string
// (e.g. ";uiop://foo;iiop://[email protected]")
}
int status = 0;
// Return code: 0 = success, -1 = failure
if (length > 0)
{
int endpoints_count = 1;
for (size_t j = 0; j != length; ++j)
{
if (endpoints[j] == endpoints_delimiter)
{
++endpoints_count;
}
}
ssize_t begin = 0;
ssize_t end = endpoints.find (endpoints_delimiter);
for (int i = 0; i < endpoints_count; ++i)
{
if (end == 0)
{
// Handle case where two consecutive endpoints `;;'
// delimiters are found within the endpoints set.
//
// Is it enough to just skip over it or should we return an
// error?
continue;
}
ACE_CString const endpt =
endpoints.substring (begin, end - begin);
// The substring call will work even if `end' is equal to
// ACE_CString::npos since that will just extract the substring
// from the offset `begin' to the end of the string.
// Check for a valid URL style endpoint set
ACE_CString::size_type const check_offset = endpt.find ("://");
if (check_offset > 0 &&
check_offset != endpt.npos)
{
endpoint_set.enqueue_tail (endpt);
// Insert endpoint into list
}
else
{
status = -1; // Error: invalid URL style endpoint set
}
begin = end + 1;
end = endpoints.find (endpoints_delimiter, begin);
}
}
else
{
status = -1;
// Failure: Empty string
}
return status;
}
示例6:
//.........这里部分代码省略.........
const char endpoint_delimiter = ',';
// The delimiter used to separate individual addresses.
// Count the number of endpoints in the IOR. This will be the number
// of entries in the MProfile.
CORBA::ULong profile_count = 1;
// Number of endpoints in the IOR (initialized to 1).
// Only check for endpoints after the protocol specification and
// before the object key.
for (ACE_CString::size_type i = ior_index; i < objkey_index; ++i)
{
if (ior[i] == endpoint_delimiter)
++profile_count;
}
// Tell the MProfile object how many Profiles it should hold.
// MProfile::set(size) returns the number profiles it can hold.
if (mprofile.set (profile_count) != static_cast<int> (profile_count))
{
throw ::CORBA::INV_OBJREF (
CORBA::SystemException::_tao_minor_code (
TAO_MPROFILE_CREATION_ERROR,
0),
CORBA::COMPLETED_NO);
// Error while setting the MProfile size!
}
// The idea behind the following loop is to split the IOR into several
// strings that can be parsed by each profile.
// For example,
// `[email protected],shu,[email protected]/arf'
// will be parsed into:
// `[email protected]/arf'
// `shu/arf'
// `[email protected]/arf'
ACE_CString::size_type begin = 0;
ACE_CString::size_type end = ior_index - 1;
// Initialize the end of the endpoint index
for (CORBA::ULong j = 0; j < profile_count; ++j)
{
begin = end + 1;
if (j < profile_count - 1)
{
end = ior.find (endpoint_delimiter, begin);
}
else
{
end = objkey_index; // Handle last endpoint differently
}
if (end < ior.length () && end != ior.npos)
{
ACE_CString endpoint = ior.substring (begin, end - begin);
// Add the object key to the string.
endpoint += ior.substring (objkey_index);
// The endpoint should now be of the form:
// `[email protected]/object_key'
// or
// `endpoint/object_key'
TAO_Profile *profile =
this->make_profile ();
// Failure: Problem during profile creation
// Initialize a Profile using the individual endpoint
// string.
// @@ Not exception safe! We need a TAO_Profile_var!
profile->parse_string (endpoint.c_str ()
);
// Give up ownership of the profile.
if (mprofile.give_profile (profile) == -1)
{
profile->_decr_refcnt ();
throw ::CORBA::INV_OBJREF (
CORBA::SystemException::_tao_minor_code (
TAO_MPROFILE_CREATION_ERROR,
0),
CORBA::COMPLETED_NO);
// Failure presumably only occurs when MProfile is full!
// This should never happen.
}
}
else
{
throw ::CORBA::INV_OBJREF ();
// Unable to separate endpoints
}
}
return 0; // Success
}
示例7: main
int main(int argc, char *argv[])
{
int c, instance = -1;
ACE_CString daemonRef;
ACE_CString hostName;
ACE_CString additional;
for (;;) {
int option_index = 0;
c = getopt_long(argc, argv, "hi:d:H:a:",
long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 'h':
usage(argv[0]);
return 0;
case 'i':
instance = ACE_OS::atoi(optarg);
break;
case 'd':
daemonRef = optarg;
break;
case 'H':
hostName = optarg;
break;
case 'a':
additional = optarg;
break;
}
}
if (instance == -1) {
ACE_OS::printf("Error: instance is a mandatory option try %s -h\n",
argv[0]);
return -1;
}
#define DEFAULT_LOG_FILE_NAME "acs_local_log"
ACE_CString daemonsLogFileName = getTempFileName(0, DEFAULT_LOG_FILE_NAME);
// replace "ACS_INSTANCE.x" with "acsdaemonStartAcs_" + <timestamp>
ACE_CString daemonsDir = "acsdaemonStartAcs_" + getStringifiedTimeStamp();
ACE_CString instancePart("ACS_INSTANCE.");
ACE_CString::size_type pos = daemonsLogFileName.find(instancePart);
daemonsLogFileName =
daemonsLogFileName.substring(0, pos) +
daemonsDir +
daemonsLogFileName.substring(pos + instancePart.length() + 1); // +1 for skipping instance number
ACE_OS::setenv("ACS_LOG_FILE", daemonsLogFileName.c_str(), 1);
LoggingProxy *logger = new LoggingProxy(0, 0, 31);
if (logger) {
LoggingProxy::init(logger);
LoggingProxy::ProcessName(argv[0]);
LoggingProxy::ThreadName("main");
} else
ACS_SHORT_LOG((LM_INFO, "Failed to initialize logging."));
StartCallback* sc = new StartCallback();
try {
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "TAO");
// get a reference to the RootPOA
CORBA::Object_var pobj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(pobj.in());
PortableServer::POAManager_var poa_manager = root_poa->the_POAManager();
// create policies
CORBA::PolicyList policy_list;
policy_list.length(5);
policy_list[0] = root_poa->create_request_processing_policy(PortableServer::USE_DEFAULT_SERVANT);
policy_list[1] = root_poa->create_id_uniqueness_policy(PortableServer::MULTIPLE_ID);
policy_list[2] = root_poa->create_id_assignment_policy(PortableServer::USER_ID);
policy_list[3] = root_poa->create_servant_retention_policy(PortableServer::NON_RETAIN);
policy_list[4] = root_poa->create_lifespan_policy(PortableServer::PERSISTENT);
// create a ACSDaemon POA with policies
PortableServer::POA_var poa = root_poa->create_POA("DaemonCallback", poa_manager.in(), policy_list);
// destroy policies
for (CORBA::ULong i = 0; i < policy_list.length(); ++i)
{
CORBA::Policy_ptr policy = policy_list[i];
policy->destroy();
}
// set as default servant
poa->set_servant(sc);
// create reference
PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId("DaemonCallback");
pobj = poa->create_reference_with_id (oid.in(), sc->_interface_repository_id());
CORBA::String_var m_ior = orb->object_to_string(pobj.in());
// bind to IOR table
CORBA::Object_var table_object = orb->resolve_initial_references("IORTable");
IORTable::Table_var adapter = IORTable::Table::_narrow(table_object.in());
//.........这里部分代码省略.........