00001 00024 #ifndef _PLAYLISTCONVERTER_H_INCLUDED_ 00025 #define _PLAYLISTCONVERTER_H_INCLUDED_ 00026 00027 #include <string> 00028 #include <list> 00029 #include <fstream> 00030 #include <libxml++/libxml++.h> 00031 #include "RmpInfo.h" 00032 00033 typedef std::list<std::string> StringList; 00034 00036 class PlayListConverter 00037 { 00038 public: 00039 PlayListConverter(); 00040 00042 bool load_config(); 00043 00045 struct Options { 00046 Options() : wait_for_child(true) {} 00047 bool wait_for_child; 00048 std::string workingdir; 00049 StringList formats; 00050 }; 00051 00053 void set_options(const Options& options); 00054 00056 bool process_rmp(const char* rmp_file); 00057 00059 struct FormatDesc { 00060 std::string name; 00061 std::string desc; 00062 bool operator<(const FormatDesc& rhs) {return name < rhs.name;} 00063 FormatDesc() {} 00064 FormatDesc(const std::string& _name, const std::string& _desc) 00065 : name(_name), desc(_desc){} 00066 }; 00067 00068 typedef std::list<FormatDesc> FormatDescList; 00069 00071 static int get_formats(FormatDescList& formats); 00072 00073 00074 private: 00076 struct OutputFormat { 00077 std::string filename; 00078 StringList chained_formats; 00079 std::string begin; 00080 std::string track; 00081 std::string end; 00082 std::string exec; 00083 00084 void clear(); 00085 }; 00086 00087 TrackList m_tracks; 00088 RmpSession m_session; 00089 Options m_options; 00090 xmlpp::DomParser m_config; 00091 00092 00094 bool parse_rmp(const char* filename); 00095 00097 bool write_output(OutputFormat& format); 00098 00100 bool exec_output(const OutputFormat& format, bool wait); 00101 00103 bool process_format(const std::string& format_name); 00104 00106 bool load_format(const char* format_name, OutputFormat& format); 00107 00108 static bool get_config_file(std::string& filename); 00109 void add_format_line(std::string &entry, const std::string newline); 00110 std::string copy_format_name(std::string format); 00111 00112 std::string make_subs(const std::string& templ, const RmpSession& session, const RmpTrack& trk); 00113 inline void insert_subst(std::string& to_change, size_t& pos, const std::string& toinsert); 00114 bool is_command_modifier(char c); 00115 00116 void change_working_dir(); 00117 void open_output(std::ofstream& os); 00118 00119 }; 00120 00121 #endif // _PLAYLISTCONVERTER_H_INCLUDED_