本文整理汇总了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;
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}