String CUtils::Trim(const String & data) { String aux(data); if (aux.length() == 0) return aux; aux = LTrim(aux); aux = RTrim(aux); return aux; }
BOOL CADORecordset::Open(_ConnectionPtr mpdb, LPCTSTR lpstrExec, int nOption) { Close(); if(_tcscmp(lpstrExec, _T("")) != 0) m_strQuery = lpstrExec; ASSERT(!m_strQuery.empty()); if(m_pConnection == NULL) m_pConnection = mpdb; LTrim(m_strQuery); BOOL bIsSelect = m_strQuery.substr(0,_tcslen(_T("select "))).compare(_T("select ")) == 0 && nOption == openUnknown; try { m_pRecordset->CursorType = adOpenStatic; m_pRecordset->CursorLocation = adUseClient; if(bIsSelect || nOption == openQuery || nOption == openUnknown) { m_pRecordset->Open(m_strQuery.c_str(), _variant_t((IDispatch*)mpdb, TRUE), adOpenStatic, adLockOptimistic, adCmdUnknown); } else if(nOption == openTable) { m_pRecordset->Open(m_strQuery.c_str(), _variant_t((IDispatch*)mpdb, TRUE), adOpenKeyset, adLockOptimistic, adCmdTable); } else if(nOption == openStoredProc) { m_pCmd->ActiveConnection = mpdb; m_pCmd->CommandText = _bstr_t(m_strQuery.c_str()); m_pCmd->CommandType = adCmdStoredProc; m_pConnection->CursorLocation = adUseClient; m_pRecordset = m_pCmd->Execute(NULL, NULL, adCmdText); } else { TRACE( _T("Unknown parameter. %d"), nOption); return FALSE; } } catch(_com_error &e) { dump_com_error(e); return FALSE; } return m_pRecordset != NULL && m_pRecordset->GetState()!= adStateClosed; }
void sendThroughUARTtoMSVS(void) { IntToStr(AccX, data_); UART1_Write_Text(data_); UART1_Write(' '); IntToStr(AccY, data_); UART1_Write_Text(data_); UART1_Write(' '); IntToStr(AccZ, data_); UART1_Write_Text(data_); UART1_Write(' '); IntToStr(GyrX, data_); UART1_Write_Text(data_); UART1_Write(' '); IntToStr(GyrY, data_); UART1_Write_Text(data_); UART1_Write(' '); IntToStr(GyrZ, data_); UART1_Write_Text(data_); UART1_Write(' '); IntToStr(Tmp, data_); UART1_Write_Text(data_); UART1_Write(' '); IntToStr(UT, data_); UART1_Write_Text(data_); UART1_Write(' '); LongWordToStr(UP, data_); LTrim(data_); UART1_Write_Text(data_); IntToStr(Xmag, data_); UART1_Write_Text(data_); UART1_Write(' '); IntToStr(Ymag, data_); UART1_Write_Text(data_); UART1_Write(' '); IntToStr(Zmag, data_); UART1_Write_Text(data_); UART1_Write(' '); // UART1_Write(13);//CR UART1_Write(31);//US return; }
void test_util() { char tmp[100]; strcpy(tmp,"strIng"); printf("test string Lower to Upper\n"); printf("before:%s\n",tmp); StrToUpper(tmp); printf("after:%s\n",tmp); memset(tmp,0x00,sizeof tmp); strcpy(tmp,"STRiNG"); printf("test string Lower to Upper\n"); printf("before:%s\n",tmp); StrToLower(tmp); printf("after:%s\n",tmp); memset(tmp,0x00,sizeof tmp); strcpy(tmp,"STRiNG "); printf("test string remove right space\n"); printf("before:%s\n",tmp); RTrim(tmp); printf("after:%s\n",tmp); memset(tmp,0x00,sizeof tmp); strcpy(tmp," STRiNG"); printf("test string remove left space\n"); printf("before:%s\n",tmp); LTrim(tmp); printf("after:%s\n",tmp); memset(tmp,0x00,sizeof tmp); strcpy(tmp," STRiNG "); printf("test string remove left and right space\n"); printf("before:%s\n",tmp); Trim(tmp); printf("after:%s\n",tmp); }
void XMLElement :: DumpOn( std::ostream & os, bool recurse ) const { os << "<" << Name(); for ( unsigned int i = 0; i < AttrCount(); i++ ) { os << " " << AttrName(i) << "=\""; os << AttrValue( AttrName(i) ) << "\""; } if ( ! recurse ) { os << "/>\n"; } else { os << ">\n"; for ( unsigned int i = 0; i < ChildCount(); i++ ) { const XMLElement * ce = ChildElement( i ) ; if ( ce ) { ce->DumpOn( os, recurse ); } const XMLText * ct = ChildText( i ); if ( ct ) { os << LTrim( ct->Text() ) << "\n"; } } os << "</" << Name() << ">\n"; } }
static std::string Trim(std::string instr) { return LTrim(RTrim(instr)); }
void Trim(string& strStr) { LTrim(strStr); RTrim(strStr); }
void AxString::Trim() { RTrim(); LTrim(); }
inline std::string& Trim(std::string &s) { return LTrim(RTrim(s)); }
void Trim( txstring& wsInOut ) { RTrim(wsInOut); LTrim(wsInOut); }
free(ptr); ptr=Substr("LIGNE DE TEXTE","7","0","\0"); printf("Cas longueur=0 :%s:\n",ptr); free(ptr); ptr=Substr("LIGNE DE TEXTE","3","18","\0"); printf("Cas trop long :%s:\n",ptr); free(ptr); ptr=Substr("LIGNE DE TEXTE","35","4","\0"); printf("Cas debut>len(chaine) :%s:\n",ptr); free(ptr); ptr=LTrim("ESSAI I ","\0"); printf("Ltrim:%s:\n",ptr); free(ptr); ptr=LTrim(" ESSAI I ","\0"); printf(":%s:\n",ptr); free(ptr); ptr=LTrim(" ","\0"); printf(":%s:\n",ptr); free(ptr); ptr=LTrim("","\0"); printf(":%s:\n",ptr); free(ptr);
std::string Trim(const std::string &source){ return LTrim(RTrim(source)); }
inline std::string& TrimQuotes(std::string& s) { TrimPred qpred = [](char c) { return c != '\'' && c != '\"'; }; return LTrim(RTrim(s, qpred), qpred); }
inline std::string& TrimWhitespace(std::string& s) { TrimPred wspred = std::not1(std::ptr_fun<int, int>(std::isspace)); return LTrim(RTrim(s, wspred), wspred); }
inline std::string& Trim(std::string& s, const TrimPred& pred) { return LTrim(RTrim(s, pred), pred); }
std::string& Util::Trim(std::string &str) { return LTrim(RTrim(str)); }
VOID ACLStr::Trim(VOID) { RTrim(); LTrim(); } // Trim
std::string stringUtil::Trim(const std::string& str,const std::string& spaces) { return LTrim(RTrim(str,spaces),spaces); }
CString CString::TrimStart() { return LTrim(); }
csStringBase &csStringBase::Trim() { return LTrim().RTrim(); }
moText0& moText0::Trim() { LTrim(); RTrim(); return *this; }
char *Trim (char *Str) { return RTrim (LTrim (Str)); }
std::string& Trim(std::string &s) { return RTrim(LTrim(s)); }
inline std::string& Trim(std::string &s, char x) { return LTrim(RTrim(s, x), x); }