本文整理汇总了C++中Mid函数的典型用法代码示例。如果您正苦于以下问题:C++ Mid函数的具体用法?C++ Mid怎么用?C++ Mid使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Mid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Teilen
BOOL CxString :: Teilen( CString& h, CString& r, char c, BOOL trimmen )
{ int i = Find( c );
CxString head = h;
CxString rest = r;
BOOL result = FALSE;
if( i > 0 ) {
head = Left( i );
rest = Mid( i + 1 );
result = TRUE;
}
else if( i == 0 ) { // c ist erstes Zeichen
head.Empty();
rest = Mid( 1 );
}
else { // Zeichen nicht gefunden!
head = *this;
rest.Empty();
}
if ( trimmen )
{ head.TrimAll();
rest.TrimAll();
}
h = head;
r = rest;
return result;
} // Teilen
示例2: while
BOOL ELString::GetFirstArg (ELString& arg)
{
int c;
BOOL quote = FALSE;
BOOL esc = FALSE;
BOOL start = FALSE;
int pos = 0;
int first = -1;
int last = -1;
LPCTSTR line;
line = *this;
while ((c = *line) != '\0') {
if (quote && !start) {
start = TRUE;
first = pos;
}
if (!start && isspace(c)) {
} else if ((!quote && (isspace (c) || c == ';')) || (quote && !esc && c == '"')) {
last = pos;
break;
} else if (start && quote && !esc && c == '\\') {
esc = TRUE;
} else if (!quote && c == '"') {
quote = TRUE;
} else {
if (!start) {
first = pos;
start = TRUE;
}
esc = FALSE;
}
line++;
pos++;
}
if (last < 0)
{
last = pos;
}
if (start)
{
arg = Mid(first, last - first);
ELString temp;
if (pos < GetLength())
{
pos++;
}
temp = Mid(pos);
*this = temp;
}
return start;
}
示例3: LastIndexOf
FarFileName FarFileName::GetExt() const
{
int p = LastIndexOf ('.');
if (p == -1)
return FarFileName (".");
return FarFileName (Mid (p));
}
示例4: RenderCharPath
void RenderCharPath(const char* gbuf, unsigned total_size, FontGlyphConsumer& sw, double xx, double yy)
{
const char* cur_glyph = gbuf;
const char* end_glyph = gbuf + total_size;
Pointf pp(xx, yy);
while(cur_glyph < end_glyph) {
const TTPOLYGONHEADER* th = (TTPOLYGONHEADER*)cur_glyph;
const char* end_poly = cur_glyph + th->cb;
const char* cur_poly = cur_glyph + sizeof(TTPOLYGONHEADER);
sw.Move(fx_to_dbl(pp, th->pfxStart));
while(cur_poly < end_poly) {
const TTPOLYCURVE* pc = (const TTPOLYCURVE*)cur_poly;
if (pc->wType == TT_PRIM_LINE)
for(int i = 0; i < pc->cpfx; i++)
sw.Line(fx_to_dbl(pp, pc->apfx[i]));
if (pc->wType == TT_PRIM_QSPLINE)
for(int u = 0; u < pc->cpfx - 1; u++) {
Pointf b = fx_to_dbl(pp, pc->apfx[u]);
Pointf c = fx_to_dbl(pp, pc->apfx[u + 1]);
if (u < pc->cpfx - 2)
c = Mid(b, c);
sw.Quadratic(b, c);
}
cur_poly += sizeof(WORD) * 2 + sizeof(POINTFX) * pc->cpfx;
}
sw.Close();
cur_glyph += th->cb;
}
}
示例5: GetLength
void COXString::LTrim()
{
int nStringIndex = 0;
int nLength = GetLength();
// find first non-space character
LPCTSTR lpsz = *this;
while (_istspace(*lpsz))
#ifdef WIN32
lpsz = _tcsinc(lpsz);
#else
lpsz++;
#endif
// fix up data and length
#if _MFC_VER < 0x0700
nStringIndex = lpsz - m_pchData;
#else
nStringIndex = PtrToInt(lpsz - GetBuffer());
#endif
if (nStringIndex == nLength)
*this = COXString(_T(""));
else
*this = Mid(nStringIndex);
}
示例6: make_pair
std::pair< std::map<wxString, wxString>,
std::vector<wxString> >
scanning_for_playlists_dlg::parse_properties(wxString const &line,
wxString const &wanted_content)
const {
std::map<wxString, wxString> properties;
std::vector<wxString> files;
wxString info;
int pos_wanted, pos_properties;
if (wxNOT_FOUND == (pos_wanted = line.Find(wanted_content)))
return std::make_pair(properties, files);
auto rest = line.Mid(pos_wanted + wanted_content.Length());
if (wxNOT_FOUND != (pos_properties = rest.Find(wxT("["))))
info = rest.Mid(pos_properties + 1).BeforeLast(wxT(']'));
if (info.IsEmpty())
return std::make_pair(properties, files);
for (auto &arg : split(info, wxU(" "))) {
auto pair = split(arg, wxU(":"), 2);
if (pair[0] == wxT("playlist_file"))
files.push_back(pair[1]);
else
properties[pair[0]] = unescape(pair[1]);
}
return std::make_pair(properties, files);
}
示例7: Mid
void Bitmap::roundRectFill(int radius, int x1, int y1, int x2, int y2, Graphics::Color color) const {
const int width = x2 - x1;
const int height = y2 - y1;
radius = Mid(0, radius, Min((x1+width - x1)/2, (y1+height - y1)/2));
double quarterTurn = Util::pi / 2;
double quadrant1 = 0;
/* signs are flipped because the coordinate system is reflected over the y-axis */
double quadrant2 = -Util::pi / 2;
double quadrant3 = Util::pi;
double quadrant4 = -3 * Util::pi / 2;
/* upper right. draw from 90 to 0 */
arcFilled(x2 - radius, y1 + radius, quadrant1, quadrant1 + quarterTurn, radius, color);
/* upper left. draw from 180 to 90 */
arcFilled(x1 + radius, y1 + radius, quadrant2, quadrant2 + quarterTurn, radius, color);
/* lower left. draw from 270 to 180 */
arcFilled(x1 + radius, y2 - radius, quadrant3, quadrant3 + quarterTurn, radius, color);
/* lower right. draw from 360 to 270 */
arcFilled(x2 - radius, y2 - radius, quadrant4, quadrant4 + quarterTurn, radius, color);
rectangleFill(x1+radius + 1, y1, x2-radius - 1, y1+radius - 1, color);
rectangleFill(x1, y1+radius, x2, y2-radius, color);
rectangleFill(x1+radius + 1, y2-radius + 1, x2-radius - 1, y2, color);
}
示例8: Mid
bool MString::StringAt(int start, int length, ... )
{
if (start < 0) return FALSE;
char buffer[64];
char* test;
CString target;
test = buffer;
target = Mid(start, length);
va_list sstrings;
va_start(sstrings, length);
do
{
test = va_arg(sstrings, char*);
if(*test AND (target == test))
return true;
}while(strcmp(test, ""));
va_end(sstrings);
return false;
}
示例9: Mid
KString KString::TrimLeft() const
{
size_t i;
for(i = 0 ; _istspace(m_Chars[i]) ; i++);
return Mid(i);
}
示例10: Trim
StrPP& StrPP::Justify(char type, int len, char mode)
{
if(mode&TRIM)
Trim(); // delete outter whitespace
if(strLen >= len && !(mode&CLIP)) // check for out-of-bounds
return *this;
if(strLen > len && (mode&CLIP)) // check for clipping
{
if(type == LEFT)
Left(len);
else if(type == CENTER)
Mid((strLen-len)/2, len);
else if(type == RIGHT)
Right(len);
return *this; // return clipped string
}
if(type == LEFT)
*this = *this + StrPP(' ', len-strLen);
else if(type == CENTER)
*this = StrPP(' ', (len-strLen)/2) + *this +
StrPP(' ', len - (len+strLen)/2);
else if(type == RIGHT)
*this = StrPP(' ', len-strLen) + *this;
strLen = strlen(strPtr);
return *this; // return normal string
}
示例11: ReverseFind
CString CMyString::GetExt() const
{
if (IsEmpty()) return _T("");
int index = ReverseFind('.');
if (index < 0) return _T("");
else return Mid(index);
}
示例12: Find
int CUIString::Replace(LPCWSTR pstrFrom, LPCWSTR pstrTo)
{
CUIString sTemp;
int nCount = 0;
//
// search the string we want to replace
//
int nPos = Find(pstrFrom);
if(nPos < 0)
return 0;
//
// here the string exist
//
int cchFrom = (int)wcslen(pstrFrom);
int cchTo = (int)wcslen(pstrTo);
while(nPos >= 0) {
//
// save the left string at position we searched
//
sTemp = Left(nPos);
//
// append the replaced string.
//
sTemp += pstrTo;
//
// append the last string
//
sTemp += Mid(nPos + cchFrom);
//
// assign buffer to this class
//
Assign(sTemp);
//
// Find again until not found
//
nPos = Find(pstrFrom, nPos + cchTo);
nCount++;
}
//
// return how many places we replaced
//
return nCount;
}
示例13: GetTail
void CParseString::GetTail(CString& word)
{
word.Empty();
int i;
for (i = m_CurIndex; i < GetLength() && IsSeparator(i); i++);
if (i < GetLength()) word = Mid(i);
}
示例14: Left
bool CFilename::GetDriver(CString &driver, CString &path)
{
int pos;
if ((pos = Find(':')) != -1) {
driver = Left(pos);
driver.MakeUpper();
path = Mid(pos + 1);
return true;
} else {
driver.Empty();
path = Mid(0);
return false;
}
}
示例15: test
void test()
{
Assign();
Add1();
Add2();
GetBuffer();
Compare();
Mid();
}