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
BOOL CxString :: Teilen( CString& h, CString& r, const char* pat, BOOL trimmen ) { CxString head = h; CxString rest = r; BOOL result = FALSE; ASSERT( AfxIsValidString( pat )); if ( *pat == '\0' ) { head = *this; rest = ""; if ( trimmen ) { head.TrimAll(); rest.TrimAll(); } h = head; r = rest; return TRUE; } if ( *(pat + 1 ) == '\0' ) return Teilen( h, r, *pat, trimmen ); int i = Find( pat ); int len = lstrlen( pat ); if ( len >= GetLength()) return FALSE; if ( i >= 0 ) { if ( i == 0 ) // pat steht am Anfang { head.Empty(); rest = Mid( len ); } else { head = Left( i ); if (( i + len ) < GetLength()) rest = Mid( i + len ); else rest = ""; result = TRUE; } } else { // pat nicht gefunden! head = *this; rest.Empty(); } if ( trimmen ) { head.TrimAll(); rest.TrimAll(); } h = head; r = rest; return result; } // Teilen
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; }
FarFileName FarFileName::GetExt() const { int p = LastIndexOf ('.'); if (p == -1) return FarFileName ("."); return FarFileName (Mid (p)); }
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; } }
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); }
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); }
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); }
void Bitmap::roundRect(int radius, int x1, int y1, int x2, int y2, 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)); line(x1+radius, y1, x1+width-radius, y1, color); line(x1+radius, y1+height, x1+width-radius,y1+height, color); line(x1, y1+radius,x1, y1+height-radius, color); line(x1+width, y1+radius,x1+width, y1+height-radius, color); 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 */ arc(x1+radius + (width - radius *2), y1 + radius, quadrant1, quadrant1 + quarterTurn, radius, color); /* upper left. draw from 180 to 270 */ arc(x1 + radius, y1 + radius, quadrant2, quadrant2 + quarterTurn, radius, color); /* lower left. draw from 180 to 270 */ arc(x1 + radius, y1 + height - radius, quadrant3, quadrant3 + quarterTurn, radius, color); /* lower right. draw from 0 to 270 */ arc(x1+width-radius, y1+height-radius, quadrant4, quadrant4 + quarterTurn, radius, color); }
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; }
KString KString::TrimLeft() const { size_t i; for(i = 0 ; _istspace(m_Chars[i]) ; i++); return Mid(i); }
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 }
CString CMyString::GetExt() const { if (IsEmpty()) return _T(""); int index = ReverseFind('.'); if (index < 0) return _T(""); else return Mid(index); }
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; }
void CParseString::GetTail(CString& word) { word.Empty(); int i; for (i = m_CurIndex; i < GetLength() && IsSeparator(i); i++); if (i < GetLength()) word = Mid(i); }
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; } }
void test() { Assign(); Add1(); Add2(); GetBuffer(); Compare(); Mid(); }
//---------------------------------------------------------------------- void GeneralMatrix::display(FILE* fpout) { if (fpout == NULL) return; fprintf(fpout,"{\n"); if (nBlock>0 && blockStruct) { for (int l=0; l<nBlock; ++l) { fprintf(fpout, "{"); if (!isSparse) { int nRow = RowDimension(mat[l]); int nCol = ColDimension(mat[l]); for(int i=0; i<nRow-1; i++) { if(i==0) fprintf(fpout," "); else fprintf(fpout," "); fprintf(fpout,"{"); for(int j=0; j<nCol-1; j++) fprintf(fpout, P_FORMAT",", Mid(mat[l](i+1,j+1))); fprintf(fpout, P_FORMAT" },\n", Mid(mat[l](i+1,nCol))); } if (nRow>1) fprintf(fpout, " {"); for (int j=0; j<nCol-1; j++) fprintf(fpout, P_FORMAT",", Mid(mat[l](nRow, j+1))); fprintf(fpout, P_FORMAT" }", Mid(mat[l](nRow,nCol))); if (nRow>1) fprintf(fpout, " }\n"); else fprintf(fpout, "\n"); } else { for(int i=0; i<ColDimension(smat[l]); i++) { for (int j=smat[l].colStarts[i]; j<smat[l].colStarts[i+1]; j++) { fprintf(fpout, "(%u,%u)", smat[l].rowIndices[j], i); fprintf(fpout, P_FORMAT, BiasMid(&smat[l].theElements[j])); if (j == smat[l].colStarts[ColDimension(smat[l])]-1) fprintf(fpout, "}\n"); else fprintf(fpout, ",\n"); } } } } } fprintf(fpout,"} \n"); }
//-------------------------------------------------------------------------------- CString CPathString::GetExtension() { int nIndex = ReverseFind('.'); CString sTemp; if(nIndex != -1) sTemp = Mid(nIndex); return sTemp; }
KString KString::Trim() const { int i; for(i = 0 ; _istspace(m_Chars[i]) ; i++); int j; for(j = GetLength() - 1 ; j > i && _istspace(m_Chars[j]) ; j--); return Mid(i, j - i + 1); }
CBSString CBSString::GetToken() { CBSString ct; ct = SpanIncluding(separators); // skip white space if (ct.GetLength()) ct = Mid(ct.GetLength()); else ct = (const char *) this[0]; ct = ct.SpanExcluding(separators); return (ct); }
int Instr(char *SearchString, char *SearchTerm) { int ReturnValue = -1; for (int i = 0 ; i <= strlen(SearchString)-strlen(SearchTerm); i++) { if (SearchTerm == Mid(SearchString, i, strlen(SearchTerm))) { ReturnValue ++; } } return ReturnValue; }
BOOL CParseString::GetNextWord(CString& word) { int i, j; word.Empty(); for (i = m_CurIndex; i < GetLength() && IsSeparator(i); i++); if (i >= GetLength()) return FALSE; for (j = i; j < GetLength() && !IsSeparator(j); j++) ; word = Mid(i, j-i); RemoveQuote(word); m_CurIndex = j; return TRUE; }
BOOL CParseString::GetPrevWord(CString& word) { word.Empty(); int i, j; for (i = m_CurIndex; i >= 0 && IsSeparator(i); i--); if (i < 0) return FALSE; for (j = i; j >= 0 && !IsSeparator(j); j--) ; word = Mid(j, i-j); RemoveQuote(word); m_CurIndex = j; return TRUE; }
static void sCubic(LinearPathConsumer& t, const Pointf& p1, const Pointf& p2, const Pointf& p3, const Pointf& p4, double qt, int lvl) { if(lvl < 16) { PAINTER_TIMING("Cubic approximation"); Pointf d = p4 - p1; double q = d.x * d.x + d.y * d.y; if(q >= 1e-30) { Pointf d2 = p2 - p1; Pointf d3 = p3 - p1; double u1 = (d2.x * d.x + d2.y * d.y) / q; double u2 = (d3.x * d.x + d3.y * d.y) / q; if(u1 <= 0 || u1 >= 1 || u2 <= 0 || u2 >= 1 || SquaredDistance(u1 * d, d2) > qt || SquaredDistance(u2 * d, d3) > qt) { Pointf p12 = Mid(p1, p2); Pointf p23 = Mid(p2, p3); Pointf p34 = Mid(p3, p4); Pointf p123 = Mid(p12, p23); Pointf p234 = Mid(p23, p34); Pointf div = Mid(p123, p234); sCubic(t, p1, p12, p123, div, qt, lvl + 1); sCubic(t, div, p234, p34, p4, qt, lvl + 1); return; } } } t.Line(p4); }
CString CFilename::GetLeaf() { CString tempstr; int pos; if ((pos = ReverseFind('\\')) != -1) { tempstr = Mid(pos + 1); } else { tempstr.Empty(); } return tempstr; }
void CVerifyCertDialog::ParseDN_by_prefix(wxWindow* parent, std::list<wxString>& tokens, wxString prefix, const wxString& name, wxSizer* pSizer, bool decode /*=false*/) { prefix += _T("="); int len = prefix.Length(); wxString value; bool append = false; auto iter = tokens.begin(); while (iter != tokens.end()) { if (!append) { if (iter->Left(len) != prefix) { ++iter; continue; } if (!value.empty()) value += _T("\n"); } else { append = false; value += _T(","); } value += iter->Mid(len); if (iter->Last() == '\\') { value.RemoveLast(); append = true; len = 0; } auto remove = iter++; tokens.erase(remove); } if (decode) value = DecodeValue(value); if (!value.empty()) { pSizer->Add(new wxStaticText(parent, wxID_ANY, name)); pSizer->Add(new wxStaticText(parent, wxID_ANY, value)); } }
int main() { char a[1000], left[100], right[100], mid[100]; int n, loc; fgets(a, 1000, stdin); a[strlen(a)-1] = '0'; memset(left, 0, 100); memset(right, 0, 100); memset(mid, 0, 100); scanf("%d %d", &n, &loc); Left(a, n, left); Right(a, n, right); Mid(a, loc, n, mid); return 0; }
NAMESPACE_UPP static void sQuadratic(LinearPathConsumer& t, const Pointf& p1, const Pointf& p2, const Pointf& p3, double qt, int lvl) { if(lvl < 16) { PAINTER_TIMING("Quadratic approximation"); Pointf d = p3 - p1; double q = Squared(d); if(q > 1e-30) { Pointf pd = p2 - p1; double u = (pd.x * d.x + pd.y * d.y) / q; if(u <= 0 || u >= 1 || SquaredDistance(u * d, pd) > qt) { Pointf p12 = Mid(p1, p2); Pointf p23 = Mid(p2, p3); Pointf div = Mid(p12, p23); sQuadratic(t, p1, p12, div, qt, lvl + 1); sQuadratic(t, div, p23, p3, qt, lvl + 1); return; } } } t.Line(p3); }
void CStdString::ProcessResourceTokens() { // Replace string-tokens: %{nnn} where nnn is a resource string identifier int iPos = Find('%'); while( iPos >= 0 ) { if( GetAt(iPos + 1) == '{' ) { int iEndPos = iPos + 2; while( isdigit(GetAt(iEndPos)) ) iEndPos++; if( GetAt(iEndPos) == '}' ) { CStdString sTemp = CStdString::RES((UINT)_ttoi(m_pstr + iPos + 2)); Replace(Mid(iPos, iEndPos - iPos + 1), sTemp); } } iPos = Find('%', iPos + 1); } }