當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。