00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _PASSENGER_STRING_LIST_CREATOR_H_
00026 #define _PASSENGER_STRING_LIST_CREATOR_H_
00027
00028 #include <string>
00029 #include <vector>
00030 #include <boost/shared_ptr.hpp>
00031 #include "Utils.h"
00032 #include "Utils/Base64.h"
00033
00034 namespace Passenger {
00035
00036 using namespace std;
00037 using namespace boost;
00038
00039 typedef vector<string> StringList;
00040 typedef shared_ptr<StringList> StringListPtr;
00041
00042
00043 class StringListCreator {
00044 public:
00045 virtual ~StringListCreator() {}
00046
00047
00048 virtual const StringListPtr getItems() const = 0;
00049 };
00050
00051 typedef shared_ptr<StringListCreator> StringListCreatorPtr;
00052
00053 class SimpleStringListCreator: public StringListCreator {
00054 public:
00055 StringListPtr items;
00056
00057 SimpleStringListCreator() {
00058 items = ptr(new StringList());
00059 }
00060
00061 SimpleStringListCreator(const StaticString &data) {
00062 items = ptr(new StringList());
00063 string buffer = Base64::decode(data);
00064 if (!buffer.empty()) {
00065 string::size_type start = 0, pos;
00066 const string &const_buffer(buffer);
00067 while ((pos = const_buffer.find('\0', start)) != string::npos) {
00068 items->push_back(const_buffer.substr(start, pos - start));
00069 start = pos + 1;
00070 }
00071 }
00072 }
00073
00074 virtual const StringListPtr getItems() const {
00075 return items;
00076 }
00077 };
00078
00079 typedef shared_ptr<SimpleStringListCreator> SimpleStringListCreatorPtr;
00080
00081 }
00082
00083 #endif