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


C++ string_t::subString方法代码示例

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


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

示例1: to_str_date

//---------------------------------------------------------------------------
string_t r::to_str_date(string_t sqlDate, string_t suffix /* = L"" */)
{
  static string_t mounthNames[12]={ "¤нвар¤", "феврал¤", "марта", "апрел¤", "ма¤", "июн¤", "июл¤", "августа", "сент¤бр¤", "окт¤бр¤", "но¤бр¤", "декабр¤"};
  string_t res = "";
  try
  {
    // число 
    res += sqlDate.subString(8,2);
    if (res.size() == 1) 
      res = "0" + res;
    res += " ";
    // мес¤ц 
    int mNum = (sqlDate.subString(5, 2).toInt()-1) % 12;
    if (mNum < 0)
      return "<невалидна¤ дата!>";
    res += mounthNames[mNum] + " ";
    // год
    res += sqlDate.subString(0,4);
    if (suffix.size()) 
      res += L" " + suffix;
  }
  catch(...)
  {
    return "<невалидна¤ дата!>";
  }
  return res;
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: Replace

//---------------------------------------------------------------------------
void WordMacros::Replace(const string_t& text, const string_t& repl)
{
  // обходим проблему текста длинее 255 символов
  const size_t MAX_REPL_LEN = 200;
  if (repl.size() > MAX_REPL_LEN)
  {
    string_t newText;
    std::vector<string_t> rs;
    for (size_t i = 0; i < repl.size(); i+= MAX_REPL_LEN)
    {
      newText += text + aux::itow(rs.size());
      rs.push_back(repl.subString(i, MAX_REPL_LEN));
    }
    Replace(text, newText);
    for (size_t i = 0; i < rs.size(); ++i)
      Replace(text + aux::itow(i), rs[i]);
    return;
  }

  m_Macros += "With Selection.Find \n";
  m_Macros += "   .ClearFormatting \n";
  m_Macros += "   .Replacement.ClearFormatting \n";
  m_Macros += "   .Text = \"" + text +"\" \n";
  m_Macros += "   .Replacement.Text = \"" + repl +"\" \n";
  m_Macros += "   .Execute Replace:=wdReplaceAll \n";
  m_Macros += "End With \n";
  IsLarge();
}
开发者ID:txe,项目名称:ieml,代码行数:29,代码来源:WordMacro.cpp

示例3: SelectionText

//---------------------------------------------------------------------------
void WordMacros::SelectionText(const string_t& text)
{
  if (text.empty())
    return;
  if (text == "vbTab")
  {
    m_Macros += "Selection.TypeText Text:=vbTab\n";
    return;
  }
  int end = text.indexOf(L"\n");
  if (end > -1)
  {
    if (end > 1)
      m_Macros += "Selection.TypeText Text:=\"" + text.subString(0, end) + "\"\n";
    SelectionTypeParagraph();
    SelectionText(text.subString(end+1, text.size()));
  }
  else
    m_Macros += "Selection.TypeText Text:=\"" + text + "\"\n";

  IsLarge();
}
开发者ID:txe,项目名称:ieml,代码行数:23,代码来源:WordMacro.cpp

示例4: PrepareDiscipTitle

//-------------------------------------------------------------------------
// разобьет на строки и вернет сколько строк займет
int ReportDiplom::PrepareDiscipTitle(string_t& title, int symbolMax)
{
  if ((int)title.size() <= symbolMax)
    return 1;
  std::vector<string_t> lines;
  while ((int)title.size() > symbolMax)
  {
    for (int i = symbolMax - 1; i >= 0; --i)
      if (title[i] == L' ' || title[i] == L'(')
      {
        lines.push_back(title.subString(0, i));
        title = title.subString(i, -1);
        break;
      }
  }
  if (!title.empty())
    lines.push_back(title);

  title = lines[0];
  for (size_t i = 1; i < lines.size(); ++i)
    title += L"\n" + lines[i];
  return lines.size();
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例5: to_digital_date

//-------------------------------------------------------------------------
string_t r::to_digital_date(string_t sqlDate)
{
  string_t res = "";
  try
  {
    // число 
    res += sqlDate.subString(8,2);
    if (res.size() == 1) 
      res = "0" + res;
    res += ".";
    // мес¤ц
    string_t m = sqlDate.subString(5, 2);
    if (m.size() == 1)
      m = m + res;
    res += m + ".";
    // год
    res += sqlDate.subString(0,4);
  }
  catch(...)
  {
    return "<невалидна¤ дата!>";
  }
  return res;
}
开发者ID:,项目名称:,代码行数:25,代码来源:


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