All Classes Files Functions Variables Enumerations Enumerator Macros
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Parser Class Reference

Creates an object for each input file and parses file and folder names. More...

#include <parser.hpp>

Public Member Functions

 Parser ()
 Default constructor, yields default values. More...
 
 ~Parser ()
 Default destructor. More...
 
void parseShow (string, ConfigOpts *)
 Parses the filename. More...
 
string getOldDir () const
 
string getOldFile () const
 
string getDir () const
 
string getShow () const
 
int getShowNameIndex () const
 
int getSeason () const
 
int getEpisode () const
 
int getXEpisode () const
 
string getPEpisode () const
 
string getTitle () const
 
string getExtension () const
 
bool getOverRideDir () const
 
bool getError () const
 
ConfigOpts::errorType getErrorData () const
 

Private Member Functions

bool findShow (string &, ConfigOpts *)
 Determines if the given filename contains a show name. More...
 
void newName (ConfigOpts *)
 Generates the new filename from parsed data complete with extension. More...
 
void newDir (ConfigOpts *)
 Generates the new directory in which the file will be located. More...
 

Static Private Member Functions

static void matchPattern (string &, int *, int &, int &, int &, string &)
 Finds a season and episode number in a given string (filename). More...
 
static void cleanUp (string &, ConfigOpts *)
 Removes filler characters and extra white spaces from a string. More...
 
static void removeTag (string &, ConfigOpts *)
 Removes release group tags as defined in the blacklist file. More...
 
static void titleCase (string &, ConfigOpts *)
 Standardizes capitalization of titles. More...
 

Private Attributes

string oldDir
 Holds the show's original directory. More...
 
string oldFile
 Holds the show's original filename. More...
 
string dir
 Holds the show's new directory. More...
 
string show
 Holds the show's new filename. More...
 
int showNameIndex
 Holds the index of the showname. More...
 
int season
 Holds the show's season number. More...
 
int episode
 Holds the show's episode number. More...
 
int xepisode
 Holds the show's multi-episode number. More...
 
string pepisode
 Holds the show's episode part. More...
 
string title
 Holds the show's new title. More...
 
string extension
 Holds the show's new extension. More...
 
bool overrideDir
 Override directory flag - (WTF?) More...
 
bool error
 Error flag - True if an error occured. More...
 
ConfigOpts::errorType errorData
 Stores the error type code. More...
 
int weight
 Holds the value used for duplicate selection - (WTF?) More...
 

Detailed Description

Creates an object for each input file and parses file and folder names.

Matches filename with a showname in the showlist file. Removes all extra info, release tags, non-blank space characters. Corrects capitalization, and formats season and episode data.

Definition at line 23 of file parser.hpp.

Constructor & Destructor Documentation

Parser::Parser ( )

Default constructor, yields default values.

Definition at line 32 of file showParser.cpp.

Parser::~Parser ( )

Default destructor.

Definition at line 53 of file showParser.cpp.

Member Function Documentation

void Parser::cleanUp ( string &  fillStr,
ConfigOpts confOpt 
)
staticprivate

Removes filler characters and extra white spaces from a string.

Parameters
fillStr- the string to be cleaned up.
confOpt- contains the showlist, blacklist, and list of filenames to be parsed.

Definition at line 77 of file parseFilter.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Parser::findShow ( string &  p_showName,
ConfigOpts confOpt 
)
private

Determines if the given filename contains a show name.

This function utilizes the contents of the showlist file (previously parsed into confOpt) to determine if given string contains a tv show name and returns true if a show name is matched.

Parameters
p_showName- the original filename passed by reference to be searched for a pattern.
confOpt- contains the showlist, blacklist, and list of filenames to be parsed.
Returns
A boolean, True = match found, False = no match found

Definition at line 31 of file parseFilter.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

string Parser::getDir ( ) const
Returns
dir The new directory information.

Definition at line 351 of file showParser.cpp.

Here is the caller graph for this function:

int Parser::getEpisode ( ) const
Returns
episode The episode number.

Definition at line 379 of file showParser.cpp.

Here is the caller graph for this function:

bool Parser::getError ( ) const
Returns
error The error flag.

Definition at line 421 of file showParser.cpp.

Here is the caller graph for this function:

ConfigOpts::errorType Parser::getErrorData ( ) const
Returns
errorData The error information.

Definition at line 428 of file showParser.cpp.

Here is the caller graph for this function:

string Parser::getExtension ( ) const
Returns
extension The file extension.

Definition at line 407 of file showParser.cpp.

string Parser::getOldDir ( ) const
Returns
oldDir The original directory information.

Definition at line 337 of file showParser.cpp.

Here is the caller graph for this function:

string Parser::getOldFile ( ) const
Returns
oldFile The original filename information.

Definition at line 344 of file showParser.cpp.

Here is the caller graph for this function:

bool Parser::getOverRideDir ( ) const
Returns
overrideDir The override directory flag.

Definition at line 414 of file showParser.cpp.

string Parser::getPEpisode ( ) const
Returns
pepisode The partial episode number.

Definition at line 393 of file showParser.cpp.

Here is the caller graph for this function:

int Parser::getSeason ( ) const
Returns
season The season number.

Definition at line 372 of file showParser.cpp.

Here is the caller graph for this function:

string Parser::getShow ( ) const
Returns
show The new filename.

Definition at line 358 of file showParser.cpp.

Here is the caller graph for this function:

int Parser::getShowNameIndex ( ) const
Returns
showNameIndex The show name's index.

Definition at line 365 of file showParser.cpp.

Here is the caller graph for this function:

string Parser::getTitle ( ) const
Returns
title The new title.

Definition at line 400 of file showParser.cpp.

Here is the caller graph for this function:

int Parser::getXEpisode ( ) const
Returns
xepisode The extra episode number.

Definition at line 386 of file showParser.cpp.

Here is the caller graph for this function:

void Parser::matchPattern ( string &  t_oldFile,
int *  coordofSnE,
int &  season,
int &  episode,
int &  xepisode,
string &  pepisode 
)
staticprivate

Finds a season and episode number in a given string (filename).

Parameters
t_oldFile- the original filename passed by reference to be searched for a pattern.
coordofSnE- an integer array passed by reference with the first and last indices of the detected pattern.
season- an integer passed by reference to store the found season number.
episode- an integer passed by reference to store the found episode number.
xepisode- an integer passed by reference to store the found extra episode number.
pepisode- an integer passed by reference to store the found partial episode number.

Definition at line 17 of file matchPattern.cpp.

Here is the caller graph for this function:

void Parser::newDir ( ConfigOpts confOpt)
private

Generates the new directory in which the file will be located.

The directory is constructed from the show name, season, and the desired root directory for the output.

Parameters
confOpt- contains the showlist, blacklist, and list of filenames to be parsed.

Definition at line 303 of file parseFilter.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Parser::newName ( ConfigOpts confOpt)
private

Generates the new filename from parsed data complete with extension.

Parameters
confOpt- contains the showlist, blacklist, and list of filenames to be parsed.

Definition at line 228 of file parseFilter.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Parser::parseShow ( string  fileName,
ConfigOpts confOpt 
)

Parses the filename.

This function does the majority of the real 'work' of clerk. It accesses numerous other functions to complete the job of breaking a filename into its useful parts and storing that data in preparation for the output functions.

Parameters
fileName- the name of the file to be parsed including directory information and the extension.
confOpt- contains the showlist, blacklist, and list of filenames to be parsed.

Definition at line 66 of file showParser.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Parser::removeTag ( string &  tagStr,
ConfigOpts confOpt 
)
staticprivate

Removes release group tags as defined in the blacklist file.

This function is used to 'pretty up' a string by removing extraneous tags that are often added to an episode name by the group that initially created the file.

Parameters
tagStr- the string to be cleaned up.
confOpt- contains the showlist, blacklist, and list of filenames to be parsed.

Definition at line 142 of file parseFilter.cpp.

Here is the caller graph for this function:

void Parser::titleCase ( string &  capStr,
ConfigOpts confOpt 
)
staticprivate

Standardizes capitalization of titles.

Parameters
capStr- the string to be cleaned up.
confOpt- contains the showlist, blacklist, and list of filenames to be parsed.

Definition at line 163 of file parseFilter.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

string Parser::dir
private

Holds the show's new directory.

Definition at line 65 of file parser.hpp.

int Parser::episode
private

Holds the show's episode number.

Definition at line 69 of file parser.hpp.

bool Parser::error
private

Error flag - True if an error occured.

Definition at line 75 of file parser.hpp.

Parser::errorData
private

Stores the error type code.

See Also
ConfigOpts::errorType
Value Reference:
SeasonEpisodeError - A Season or Episode pattern match failure occured
ShowNameMatchError - A Show name match failure occured
DuplicateEpisodeError - A duplicate Episode failure occured
SortFailureError - A sort failure occured
NoError - No errors occured

Definition at line 76 of file parser.hpp.

string Parser::extension
private

Holds the show's new extension.

Definition at line 73 of file parser.hpp.

string Parser::oldDir
private

Holds the show's original directory.

Definition at line 63 of file parser.hpp.

string Parser::oldFile
private

Holds the show's original filename.

Definition at line 64 of file parser.hpp.

bool Parser::overrideDir
private

Override directory flag - (WTF?)

Definition at line 74 of file parser.hpp.

string Parser::pepisode
private

Holds the show's episode part.

Definition at line 71 of file parser.hpp.

int Parser::season
private

Holds the show's season number.

Definition at line 68 of file parser.hpp.

string Parser::show
private

Holds the show's new filename.

Definition at line 66 of file parser.hpp.

int Parser::showNameIndex
private

Holds the index of the showname.

Definition at line 67 of file parser.hpp.

string Parser::title
private

Holds the show's new title.

Definition at line 72 of file parser.hpp.

int Parser::weight
private

Holds the value used for duplicate selection - (WTF?)

Value Reference:
weight = 28      // "S##E##"
weight = 27      // "S##E##-##"
weight = 26      // "S## E##" OR "S##XE##"
weight = 25      // "S## E##-##" OR "S##XE##-##"
weight = 24      // "S# E##"
weight = 23      // "S# E##-##"
weight = 22      // "S#E##"
weight = 21      // "S#E##-##"
weight = 20      // "S#E#"
weight = 19      // "S#E#-##"
weight = 18      // "####"
weight = 17      // "####-##"
weight = 16      // "###"
weight = 15      // "###-##"
weight = 14      // "##X##"
weight = 13      // "##X##-##"
weight = 12      // "#X## OR #/##"
weight = 11      // "#X##-## OR #/##-##"
weight = 10      // "S##"
weight = 09      // "S#"
weight = 08      // "##"
weight = 07      // "#"

Definition at line 89 of file parser.hpp.

int Parser::xepisode
private

Holds the show's multi-episode number.

Definition at line 70 of file parser.hpp.


The documentation for this class was generated from the following files: