Main Page   Namespace List   Alphabetical List   Compound List   File List   Compound Members   File Members  

PlayListConverter Class Reference

class to convert rmp files to more useful things More...

#include <PlayListConverter.h>

Collaboration diagram for PlayListConverter:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::list< FormatDescFormatDescList

Public Member Functions

 PlayListConverter ()
bool load_config ()
 load the config file

void set_options (const Options &options)
 set the ooutput options

bool process_rmp (const char *rmp_file)
 process the rmp file useing the current list of formats & options


Static Public Member Functions

int get_formats (FormatDescList &formats)
 return a list of available formats & their descriptions


Private Member Functions

bool parse_rmp (const char *filename)
 parse the emp file

bool write_output (OutputFormat &format)
 generate the output file for the current format

bool exec_output (const OutputFormat &format, bool wait)
 execute the action (if any) for this format

bool process_format (const std::string &format_name)
 generate output for & exec a single format

bool load_format (const char *format_name, OutputFormat &format)
 load the specified format

void add_format_line (std::string &entry, const std::string newline)
 append a new line to a config entry

std::string copy_format_name (std::string format)
 copy the format name into the local options

std::string make_subs (const std::string &templ, const RmpSession &session, const RmpTrack &trk)
 given a template & info on the current session/track make all the special char substitutions

void insert_subst (std::string &to_change, size_t &pos, const std::string &toinsert)
 fucntion to make a single escape char substitution

bool is_command_modifier (char c)
 check if a character is a command modifier

void change_working_dir ()
 change to the working directory

void open_output (std::ofstream &os)
 open the output stream, creating new directories as necessary


Static Private Member Functions

bool get_config_file (std::string &filename)
 find the correct config file & return true on success


Private Attributes

TrackList m_tracks
 the parsed list if tracks

RmpSession m_session
 the parsed session info

Options m_options
 the current set of options

xmlpp::DomParser m_config
 A DOM tree containing the XML config file.


Detailed Description

class to convert rmp files to more useful things

Definition at line 36 of file PlayListConverter.h.


Member Typedef Documentation

typedef std::list<FormatDesc> PlayListConverter::FormatDescList
 

Definition at line 68 of file PlayListConverter.h.

Referenced by list_formats().


Constructor & Destructor Documentation

PlayListConverter::PlayListConverter  
 

Definition at line 40 of file PlayListConverter.cpp.


Member Function Documentation

void PlayListConverter::add_format_line std::string &    entry,
const std::string    newline
[private]
 

append a new line to a config entry

Parameters:
entry the string to append to
newline the new config line

Definition at line 230 of file PlayListConverter.cpp.

Referenced by load_format().

void PlayListConverter::change_working_dir   [private]
 

change to the working directory

Definition at line 370 of file PlayListConverter.cpp.

References expand_tilde(), m_options, make_dir(), and PlayListConverter::Options::workingdir.

Referenced by process_rmp(), and set_options().

string PlayListConverter::copy_format_name std::string    format [private]
 

copy the format name into the local options

if the fomrmat name begins with '<' its treated as the body of a elment and added to the parsed config file.

Parameters:
format the name of the format to use (or the contents of an anonymous format) This param cant be a reference beacuse it would cause a reference to a reference when called by stl algorithms.
Returns:
the name of the format to copy

Definition at line 439 of file PlayListConverter.cpp.

References addChild(), and m_config.

bool PlayListConverter::exec_output const OutputFormat   format,
bool    wait_for_child
[private]
 

execute the action (if any) for this format

Parameters:
format the format to execute the output for
wait_for_child true if we should wait for the child process before returning
Returns:
true on success

Definition at line 162 of file PlayListConverter.cpp.

References PlayListConverter::OutputFormat::exec.

Referenced by process_format().

bool PlayListConverter::get_config_file std::string &    filename [static, private]
 

find the correct config file & return true on success

Parameters:
filename the config file to load
Returns:
true on success

Definition at line 202 of file PlayListConverter.cpp.

References expand_tilde().

Referenced by get_formats(), and load_config().

int PlayListConverter::get_formats FormatDescList   format_desc [static]
 

return a list of available formats & their descriptions

Parameters:
format_desc the list of available formats
Returns:
the number of formats found

Definition at line 574 of file PlayListConverter.cpp.

References PlayListConverter::FormatDesc::desc, get_config_file(), getChildContent(), getPropValue(), and PlayListConverter::FormatDesc::name.

Referenced by list_formats().

void PlayListConverter::insert_subst std::string &    to_change,
size_t &    pos,
const std::string &    toinsert
[inline, private]
 

fucntion to make a single escape char substitution

Parameters:
to_change string to modify
pos position to make the change
toinsert teh string to insert

Definition at line 328 of file PlayListConverter.cpp.

References escape_shell_chars(), is_command_modifier(), remove_shell_chars(), and replace_str().

Referenced by make_subs().

bool PlayListConverter::is_command_modifier char    c [private]
 

check if a character is a command modifier

Parameters:
c the char to check
Returns:
true if the character modifies an escape sequence

Definition at line 392 of file PlayListConverter.cpp.

Referenced by insert_subst(), and make_subs().

bool PlayListConverter::load_config  
 

load the config file

Definition at line 52 of file PlayListConverter.cpp.

References expand_tilde(), PlayListConverter::Options::formats, get_config_file(), getFirstChild(), getPropValue(), m_config, m_options, and PlayListConverter::Options::workingdir.

Referenced by main().

bool PlayListConverter::load_format const char *    format_name,
OutputFormat   oformat
[private]
 

load the specified format

Parameters:
format_name the fomrat to load
oformat the loaded format
Returns:
true on success

Definition at line 509 of file PlayListConverter.cpp.

References add_format_line(), PlayListConverter::OutputFormat::begin, PlayListConverter::OutputFormat::chained_formats, PlayListConverter::OutputFormat::clear(), PlayListConverter::OutputFormat::end, PlayListConverter::OutputFormat::exec, expand_tilde(), PlayListConverter::OutputFormat::filename, getChildContent(), getPropValue(), m_config, and PlayListConverter::OutputFormat::track.

Referenced by process_format().

string PlayListConverter::make_subs const std::string &    templ,
const RmpSession   session,
const RmpTrack   trk
[private]
 

given a template & info on the current session/track make all the special char substitutions

Parameters:
templ the template for the substitution (eg. "%A.m3u")
session the session info for the current rmp file
trk information for the current track
Returns:
the string with substitutions made (eg. "Massive Attack.m3u"

Definition at line 244 of file PlayListConverter.cpp.

References RmpTrack::artist, RmpTrack::channels, RmpTrack::cover, RmpTrack::duration, RmpSession::emp_file, RmpTrack::file_name, RmpTrack::format, RmpTrack::genre, insert_subst(), is_command_modifier(), m_options, m_session, RmpSession::output_file, RmpSession::package_artist, RmpSession::package_title, RmpSession::provider, RmpTrack::quality, RmpTrack::title, RmpTrack::track_id, RmpTrack::track_num, RmpTrack::url, and PlayListConverter::Options::workingdir.

Referenced by write_output().

void PlayListConverter::open_output std::ofstream &    os [private]
 

open the output stream, creating new directories as necessary

Parameters:
os the stream to open

Definition at line 604 of file PlayListConverter.cpp.

References m_session, make_dir(), and RmpSession::output_file.

Referenced by write_output().

bool PlayListConverter::parse_rmp const char *    filename [private]
 

parse the emp file

Parameters:
filename the rmp file to process
Returns:
true on success

Definition at line 95 of file PlayListConverter.cpp.

References RmpSession::emp_file, m_session, and EmpParser::parse_file().

Referenced by process_rmp().

bool PlayListConverter::process_format const std::string &    format_name [private]
 

generate output for & exec a single format

Parameters:
format_name the name of the format to run
Returns:
true on success

Definition at line 494 of file PlayListConverter.cpp.

References exec_output(), load_format(), m_options, PlayListConverter::Options::wait_for_child, and write_output().

Referenced by process_rmp(), and write_output().

bool PlayListConverter::process_rmp const char *    rmp_file
 

process the rmp file useing the current list of formats & options

Parameters:
rmp_file the rmp file to process
Returns:
true on success

Definition at line 474 of file PlayListConverter.cpp.

References change_working_dir(), PlayListConverter::Options::formats, m_options, parse_rmp(), and process_format().

Referenced by main().

void PlayListConverter::set_options const Options   new_opt
 

set the ooutput options

if the list of formats is empty the default set will we used

Parameters:
new_opt the new optons

Definition at line 411 of file PlayListConverter.cpp.

References change_working_dir(), PlayListConverter::Options::formats, m_options, PlayListConverter::Options::wait_for_child, and PlayListConverter::Options::workingdir.

Referenced by main().

bool PlayListConverter::write_output OutputFormat   format [private]
 

generate the output file for the current format

Definition at line 103 of file PlayListConverter.cpp.

References PlayListConverter::OutputFormat::begin, PlayListConverter::OutputFormat::chained_formats, PlayListConverter::OutputFormat::end, PlayListConverter::OutputFormat::exec, PlayListConverter::OutputFormat::filename, m_session, m_tracks, make_subs(), open_output(), RmpSession::output_file, process_format(), and PlayListConverter::OutputFormat::track.

Referenced by process_format().


Member Data Documentation

xmlpp::DomParser PlayListConverter::m_config [private]
 

A DOM tree containing the XML config file.

Definition at line 90 of file PlayListConverter.h.

Referenced by copy_format_name(), load_config(), and load_format().

Options PlayListConverter::m_options [private]
 

the current set of options

Definition at line 89 of file PlayListConverter.h.

Referenced by change_working_dir(), load_config(), make_subs(), process_format(), process_rmp(), and set_options().

RmpSession PlayListConverter::m_session [private]
 

the parsed session info

Definition at line 88 of file PlayListConverter.h.

Referenced by make_subs(), open_output(), parse_rmp(), and write_output().

TrackList PlayListConverter::m_tracks [private]
 

the parsed list if tracks

Definition at line 87 of file PlayListConverter.h.

Referenced by write_output().


The documentation for this class was generated from the following files:
Generated on Sat May 3 09:16:17 2003 for empxform by doxygen1.3-rc3