String NDS

zhaozj2021-02-16  55

#ifndef _nds_trim_h # Define _nds_trim_h

#include #include #include #include Using Namespace Std;

Namespace nds {

Inline string & ltrim (String & SS, INT) {String :: Iterator P = FIND_IF (ss.begin (), ss.end (), not1 (PTR_FUN (PF))); SS. ERASE (ss.begin (), p); return ss;}

Inline String & RTRIM (String & SS, INT) {String :: Reverse_iterator P = Find_IF (s.rbegin (), ss.rend (), NOT1 (PTR_FUN (PF))); SS. ERASE (P.Base (), ss.end ()); return ss;}

INLINE STRING & TRIM (String & St) {LTRIM (RTRIM (ST)); Return st;}

Inline void stringupper (string & str) {for (String :: item i = str.begin (); i! = str.end (); i ) * i = TouPper (* i);}

Inline void stringlower (string & str) {for (String :: itrator i = str.begin (); i! = str.end (); i ) * i = tolower (* i);}

Template Inline const string to_string (const t & v) {ostringstream OS; OS << v; returnos.str ();

Template inline const t from_string (const string & v) {istringstream is (v); t t; is >> t; return t;}

Template Inline Void from_String (T & T, Const String & V) {IstringStream IS (V); IS >> T;}

}

#ENDIF

For the operation of the string string to head tail blank characters, the new string is added to the T type operation function. One thing has not been resolved, it is a formatted problem when any type is converted to a string.

转载请注明原文地址:https://www.9cbs.com/read-21463.html

New Post(0)