00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _ptokenizer_h_
00021 #define _ptokenizer_h_
00022
00023 #include <pclasses/pexport.h>
00024 #include <string>
00025 #include <iostream>
00026 #include <sstream>
00027
00028 namespace P {
00029
00031
00035 class PCORE_EXPORT StreamTokenizer {
00036 public:
00037
00039 enum matchMode_t {
00040 MatchAll,
00041 MatchAny
00042 };
00043
00045
00050 StreamTokenizer(std::istream& is, const std::string& seperator, matchMode_t mode = MatchAny);
00051 ~StreamTokenizer();
00052
00054 operator bool() const;
00055
00057 StreamTokenizer& operator>>(std::string& token);
00058
00059 private:
00060 matchMode_t m_mode;
00061 std::istream& m_is;
00062 std::string m_separator;
00063 };
00064
00065
00067
00071 class PCORE_EXPORT StringTokenizer: public StreamTokenizer {
00072 public:
00073 StringTokenizer(const std::string& str, const std::string& seperator, matchMode_t mode = MatchAny);
00074 ~StringTokenizer();
00075
00076 private:
00077 std::istringstream m_is;
00078 };
00079
00080 }
00081
00082 #endif