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


C++ ACE_TString::substr方法代码示例

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


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

示例1: GetProperty

    bool GetProperty(const mstrings_t& properties, 
        const ACE_TString& prop, std::vector<int>& vec)
    {
        ACE_TString value;
        mstrings_t::const_iterator ite = properties.find(prop);
        if( ite != properties.end() )
        {
            value = (*ite).second;
            ACE_TString token;
            size_t offset = 0;
            size_t i = value.find(',', offset);//Tokenize(ACE_TEXT(","),offset);
            while(i != ACE_TString::npos)
            {
                token = value.substr(offset, i-offset);
                offset = i+1;
                vec.push_back(int(string2i(token)));
                i = value.find(',', offset);

            }
            if( value.length() && (value.length() - 1) >= offset )
            {
                token = value.substr(offset, value.length()-offset);
                offset = i+1;
                vec.push_back(int(string2i(token)));
            }
            return true;
        }
        return false;
    }
开发者ID:BearWare,项目名称:TeamTalk5,代码行数:29,代码来源:Commands.cpp

示例2: stripEOL

 ACE_TString stripEOL(const ACE_TString& input)
 {
     size_t len = ACE_OS::strlen(EOL);
     if(input.length()<len)
         return input;
     if(input.substr(input.length()-len,len) == EOL)
         return input.substr(0,input.length()-len);
     else if(input.substr(input.length()-1,1) == ACE_TEXT("\n"))
         return input.substr(0,input.length()-1);
     return input;
 }
开发者ID:BearWare,项目名称:TeamTalk5,代码行数:11,代码来源:Commands.cpp

示例3: tokens

void
TAO_IMR_Op_Register::addenv (ACE_TCHAR *opt)
{
  CORBA::ULong length = this->environment_vars_.length ();
  // Increase the length of the sequence
  this->environment_vars_.length (length + 1);
  ACE_TString tokens (opt);
  size_t index = tokens.find (ACE_TEXT("="));
  // Insert at position length since that is our new element
  this->environment_vars_ [length].name =
    CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(tokens.substr (0, index).c_str ()));
  this->environment_vars_ [length].value =
    CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(tokens.substr (index + 1).c_str ()));
}
开发者ID:elrafoon,项目名称:ATCD,代码行数:14,代码来源:tao_imr_i.cpp

示例4: while

// Convert a <string> to a <name>
ACE_Registry::Name
ACE_Registry::make_name (const ACE_TString &string)
{
  ACE_TString::size_type new_position = 0;
  ACE_TString::size_type last_position = 0;
  Name name;

  // Rememeber: NPOS is -1
  while (new_position != ACE_TString::npos)
    {
      Name_Component component;
      // Find the separator
      new_position = string.find (STRING_SEPARATOR, new_position);
      if (new_position != ACE_TString::npos)
        // If we have not gone past the end
        {
          // Get the substring
          component.id_ = string.substr (last_position,
                                         new_position - last_position);
          // Skip past the seperator
          new_position +=
            ACE_OS::strlen (STRING_SEPARATOR);
        }
      else
        {
          // Get the last substring
          component.id_ = string.substr (last_position);
        }
      // Update positions
      last_position = new_position;
      // Insert component into name
      name.insert (component);
    }

  return name;
}
开发者ID:16898500,项目名称:SkyFireEMU,代码行数:37,代码来源:Registry.cpp

示例5: PrepareString

    ACE_TString PrepareString(const ACE_TString& str)
    {
        ACE_TString newstr;
        if(str.length()>MAX_STRING_LENGTH)
            newstr = str.substr(0, MAX_STRING_LENGTH);
        else
            newstr = str;

        replace_all(newstr, ACE_TEXT("\\"), ACE_TEXT("\\\\"));
        replace_all(newstr, ACE_TEXT("\""), ACE_TEXT("\\\""));
        replace_all(newstr, ACE_TEXT("\r"), ACE_TEXT("\\r"));
        replace_all(newstr, ACE_TEXT("\n"), ACE_TEXT("\\n"));

        return newstr;
    }
开发者ID:BearWare,项目名称:TeamTalk5,代码行数:15,代码来源:Commands.cpp

示例6: base

void
ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
                               ACE_Array<ACE_TString> &try_names)
{
  // Build the array of DLL names to try on this platform by applying the
  // proper prefixes and/or suffixes to the specified dll_name.
  ACE_TString base (dll_name);
  ACE_TString base_dir, base_file, base_suffix;

  // 1. Separate the dll_name into the dir part and the file part. We
  // only decorate the file part to determine the names to try loading.
  ACE_TString::size_type pos = base.rfind (ACE_DIRECTORY_SEPARATOR_CHAR);
  if (pos != ACE_TString::npos)
    {
      base_dir = base.substr (0, pos + 1);
      base_file = base.substr (pos + 1);
    }
  else
    base_file = base;

  // 2. Locate the file suffix, if there is one. Move the '.' and the
  // suffix to base_suffix.
  if ((pos = base_file.rfind (ACE_TEXT ('.'))) != ACE_TString::npos)
    {
      base_suffix = base_file.substr (pos);
      base_file = base_file.substr (0, pos);
    }

  // 3. Build the combinations to try for this platform.
  // Try these combinations:
  //   - name with decorator and platform's suffix appended (if not supplied)
  //   - name with platform's suffix appended (if not supplied)
  //   - name with platform's dll prefix (if it has one) and suffix
  //   - name with platform's dll prefix, decorator, and suffix.
  //   - name as originally given
  // We first try to find the file using the decorator so that when a
  // filename with and without decorator is used, we get the file with
  // the same decorator as the ACE dll has and then as last resort
  // the one without. For example with msvc, the debug build has a "d"
  // decorator, but the release build has none and we really want to get
  // the debug version of the library in a debug application instead
  // of the release one.
  // So we need room for 5 entries in try_names.
  try_names.size (0);
  if ((try_names.max_size () - try_names.size ()) < 5)
    try_names.max_size (try_names.max_size () + 5);
#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
  ACE_TString decorator (ACE_LD_DECORATOR_STR);
#endif
  ACE_TString suffix (ACE_DLL_SUFFIX);
  ACE_TString prefix (ACE_DLL_PREFIX);

  for (size_t i = 0; i < 5 && try_names.size () < try_names.max_size (); ++i)
    {
      ACE_TString try_this;
      size_t j = try_names.size ();
      switch (i)
        {
        case 0:        // Name + decorator + suffix
        case 1:        // Name + suffix
        case 2:        // Prefix + name + decorator + suffix
        case 3:        // Prefix + name + suffix
          if (
              base_suffix.length () > 0
#if !(defined(ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK))
              || (i == 1 || i == 3)    // No decorator desired; skip
#endif
              )
            break;
          try_this = base_dir;
          if (i > 1)
            try_this += prefix;
          try_this += base_file;
          if (base_suffix.length () > 0)
            try_this += base_suffix;
          else
            {
#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
              try_this += decorator;
#endif
              try_this += suffix;
            }
          break;
        case 4:
          try_this = dll_name;
          break;
        }

      if (try_this.length ())
        {
          try_names.size (j + 1);
          try_names.set (try_this, j);
        }
    }
  return;
}
开发者ID:yuanxu,项目名称:liveshow_r2,代码行数:96,代码来源:DLL_Manager.cpp

示例7: base

void
ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
                               ACE_Array<ACE_TString> &try_names)
{
  // Build the array of DLL names to try on this platform by applying the
  // proper prefixes and/or suffixes to the specified dll_name.
  ACE_TString base (dll_name);
  ACE_TString base_dir, base_file, base_suffix;

  // 1. Separate the dll_name into the dir part and the file part. We
  // only decorate the file part to determine the names to try loading.
  int pos = base.rfind (ACE_DIRECTORY_SEPARATOR_CHAR);
  if (pos != ACE_TString::npos)
    {
      base_dir = base.substr (0, static_cast<ssize_t>(pos) + 1);
      base_file = base.substr (static_cast<size_t>(pos) + 1);
    }
  else
    base_file = base;

  // 2. Locate the file suffix, if there is one. Move the '.' and the
  // suffix to base_suffix.
  if ((pos = base_file.rfind (ACE_LIB_TEXT ('.'))) != ACE_TString::npos)
    {
      base_suffix = base_file.substr (static_cast<size_t>(pos));
      base_file = base_file.substr (0, static_cast<ssize_t>(pos));
    }

  // 3. Build the combinations to try for this platform.
  // Try these combinations:
  //   - name as originally given
  //   - name with decorator and platform's suffix appended (if not supplied)
  //   - name with platform's suffix appended (if not supplied)
  //   - name with platform's dll prefix (if it has one) and suffix
  //   - name with platform's dll prefix, decorator, and suffix.
  // So we need room for 5 entries in try_names.
  try_names.size (0);
  if ((try_names.max_size () - try_names.size ()) < 5)
    try_names.max_size (try_names.max_size () + 5);
#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
  ACE_TString decorator (ACE_LD_DECORATOR_STR);
#endif
  ACE_TString suffix (ACE_DLL_SUFFIX);
  ACE_TString prefix (ACE_DLL_PREFIX);

  for (size_t i = 0; i < 5 && try_names.size () < try_names.max_size (); ++i)
    {
      ACE_TString try_this;
      size_t j = try_names.size ();
      switch (i)
        {
        case 0:
          try_this = dll_name;
          break;

        case 1:        // Name + decorator + suffix
        case 2:        // Name + suffix
        case 3:        // Prefix + name + decorator + suffix
        case 4:        // Prefix + name + suffix
          if (
              base_suffix.length () > 0
#if !(defined(ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK))
              || (i == 2 || i == 4)    // No decorator desired; skip
#endif
              )
            break;
          try_this = base_dir;
          if (i > 2)
            try_this += prefix;
          try_this += base_file;
          if (base_suffix.length () > 0)
            try_this += base_suffix;
          else
            {
#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
              try_this += decorator;
#endif
              try_this += suffix;
            }
          break;
        }

      if (try_this.length ())
        {
          try_names.size (j + 1);
          try_names.set (try_this, j);
        }
    }
  return;
}
开发者ID:mbert,项目名称:mulberry-lib-jx,代码行数:90,代码来源:DLL_Manager.cpp

示例8: ExtractProperties

    int ExtractProperties(const ACE_TString& input, mstrings_t& properties)
    {
        TTASSERT(input.find('\n') == input.rfind('\n'));

        bool bSyntaxError = false;
        if( input.length() == 0 )
            bSyntaxError = true;

        size_t offset = input.find(' ');//past command
        if(offset == ACE_TString::npos)
            return 0;

        while(offset < input.length() && !bSyntaxError)
        {
            //past any spaces
            offset = pastBlanks(offset, input);
            if(offset == input.length())
            {
                break;
            }

            size_t propBegin = offset;
            ACE_TString prop;
            ACE_TString value;
            while(offset < input.length()) //extract property name
            {
                if( input[offset] != ' ' && input[offset] != '=') offset ++;
                else break;
            }
            if(offset == input.length())
            {
                bSyntaxError = true; //no properties in ACE_TString
                break;
            }

            prop = input.substr(propBegin, offset-propBegin); //set propertyname
            TTASSERT(properties.find(prop) == properties.end());
            offset = pastBlanks(offset, input); //past spaces
            if(offset == input.length())
            {
                bSyntaxError = true;
                break;
            }
            if(input[offset] != '=')
            {
                bSyntaxError = true;
                break;
            }
            else offset ++; //past =

            offset = pastBlanks(offset, input); //past spaces
            if(offset == input.length())
            {
                bSyntaxError = true;
                break;
            }

            //determine whether it's a string or an integer
            if(input[offset] == '"') //a ACE_TString
            {
                bool found = false;
                size_t strBegin = ++offset; //past "
                while(!found && offset<input.length())
                {
                    /*
                    if(input[offset]==ACE_TEXT('\"') && input[offset-1] != ACE_TEXT('\\')) found = true;
                    offset++;
                    */
                    if(input[offset] == '\\')
                        offset += 2;
                    else if(input[offset] == '"')
                    {
                        found = true;
                        offset++;
                    }
                    else
                        offset++;
                }

                if(!found)
                {
                    bSyntaxError = true;
                    break;
                }

                value = input.substr(strBegin, offset-strBegin-1);
                offset ++; //past \"

                properties[prop] = RebuildString(value);
                //properties.SetAt(prop, RebuildString(value));
            }
            else if(input[offset] == '[') // an int list
            {
                bool found = false;
                size_t listBegin = ++offset; //past "
                while(!found && offset<input.length())
                {
                    if(input[offset] == ']') found = true;
                    offset++;
                }
//.........这里部分代码省略.........
开发者ID:BearWare,项目名称:TeamTalk5,代码行数:101,代码来源:Commands.cpp


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