4 #include "Exceptions.hpp"
6 inline static bool IsSpace( char c
)
11 inline static bool IsNotSpace( char c
)
16 inline static bool IsSlash( char c
)
21 inline static bool IsNotSlash( char c
)
26 inline static bool IsComma( char c
)
31 inline static bool IsNotComma( char c
)
36 PathVector
SplitPath( const std::string
& str
)
40 typedef std::string::const_iterator Iter
;
42 Iter i
= str
.begin(), j
;
44 while( i
!= str
.end() )
46 i
= std::find_if( i
, str
.end(), IsNotSlash
);
47 j
= std::find_if( i
, str
.end(), IsSlash
);
51 ret
.push_back( std::string( i
, j
) );
57 if( ret
.size() > 0 && ret
[0] == "~" )
59 ret
.erase( ret
.begin() );
65 PortVector
SplitPort( const std::string
& str
)
69 typedef std::string::const_iterator Iter
;
71 Iter i
= str
.begin(), j
;
73 while( i
!= str
.end() )
75 i
= std::find_if( i
, str
.end(), IsNotComma
);
76 j
= std::find_if( i
, str
.end(), IsComma
);
80 ret
.push_back( std::string( i
, j
) );
89 Command
Split( const std::string
& str
)
93 std::string::const_iterator it
= std::find_if( str
.begin(), str
.end(), IsSpace
);
101 ret
.push_back( std::string( str
.begin(), it
) );
102 ret
.push_back( std::string( it
+ 1, str
.end() ) );
108 Command
ParseCommand( const std::string
& cmd
)
110 Command
ret( Split( cmd
) );
112 if( cmd
.size() == 0 )
114 throw SyntaxErrorException
;
122 void ToUpper( std::string
& str
)
124 std::transform( str
.begin(), str
.end(), str
.begin(), toupper
);