Bayeux  3.4.1
Core Foundation library for SuperNEMO
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
datatools::smart_filename Class Reference

A class that builds an arbitrary list of filenames on user request. Supported modes are: More...

#include <bayeux/datatools/smart_filename.h>

Classes

struct  labels
 

Public Types

enum  mode_t { MODE_INVALID = 0, MODE_SINGLE = 0x1, MODE_LIST = 0x2, MODE_INCREMENTAL = 0x4 }
 
typedef std::vector< std::string > list_type
 
typedef list_type::const_iterator const_iterator
 

Public Member Functions

 smart_filename ()
 Default constructor: More...
 
virtual ~smart_filename ()
 Destructor. More...
 
void set_logging_priority (datatools::logger::priority p_)
 Set logging priority. More...
 
datatools::logger::priority get_logging_priority () const
 Returns logging priority. More...
 
int get_mode () const
 Return the mode. More...
 
bool is_initialized () const
 Check the initialization flag. More...
 
bool is_single () const
 Check the single mode. More...
 
bool is_list () const
 Check the list mode. More...
 
bool is_incremental () const
 Check the incremental mode. More...
 
bool is_valid () const
 Check if the object is valid. More...
 
bool is_ranged () const
 Check is the list of filenames is ranged. More...
 
bool is_expand_path () const
 Check the expand path flag. More...
 
size_t size () const
 Return the number of filenames. More...
 
size_t current_size () const
 Return the current number of filenames. More...
 
const_iterator begin () const
 Return the first const iterator from the embedded list of filenames. More...
 
const_iterator end () const
 Return the fpast-the-end const iterator from the embedded list of filenames. More...
 
const std::string & operator[] (int index_) const
 Access to a filename by index. More...
 
const std::string & get_filename (int index_) const
 Access to a filename by index. More...
 
bool has_filename (const std::string &name_, bool expand_=true) const
 Check if a given filename exists from the embedded list of filenames. More...
 
void set (const std::string &filename_)
 Set the filename in single mode. More...
 
void set_single (const std::string &filename_)
 Set the single mode and associated filename. More...
 
void add (const std::string &filename_)
 Add a filename in list mode. More...
 
void add_to_list (const std::string &filename_)
 Add a filename in list mode. More...
 
void reset ()
 Reset the object. More...
 
void build_incremental_filename (int increment_index_, std::string &filename_) const
 Build the filename from the increment index in incremental mode. More...
 
void dump (std::ostream &out_=std::clog) const
 Raw print. More...
 
void initialize (const properties &config_)
 Initialize from a list of configuration parameters. More...
 
void print_list_of_filenames (std::ostream &out_=std::clog) const
 Print the list of filenames. More...
 
void store_list_of_filenames (const std::string &list_filename_, bool append_=true) const
 Store the list of filenames in a file. More...
 

Static Public Member Functions

static void make_single (smart_filename &smart_filename_, const std::string &filename_, bool expand_path_=true)
 Make a smart_filename object in single mode. More...
 
static void make_list (smart_filename &smart_filename_, bool allow_duplication_=false, bool expand_path_=true)
 Make a smart_filename object in list mode. More...
 
static void make_list (smart_filename &smart_filename_, const std::string &list_file_, bool allow_duplication_=false, bool expand_path_=true)
 Make a smart_filename object in list mode. More...
 
static void make_incremental (smart_filename &smart_filename_, const std::string &path_, const std::string &prefix_, const std::string &extension_, int stopping_index_, int starting_index_=0, int increment_index_=1, const std::string &suffix_="", int incremental_index_ndigit_=0, bool expand_path_=true)
 Make a smart_filename object in incremental mode. More...
 
static void make_unranged_incremental (smart_filename &smart_filename_, const std::string &path_, const std::string &prefix_, const std::string &extension_, int starting_index_=0, int increment_index_=1, const std::string &suffix_="", int incremental_index_ndigit_=0, bool expand_path_=true)
 Make a smart_filename object in unranged incremental mode. More...
 

Static Public Attributes

static const int MODE_INCREMENTAL_UNRANGED = -1
 
static const int MODE_INCREMENTAL_DEFAULT_START = 0
 
static const int MODE_INCREMENTAL_DEFAULT_INCREMENT = 1
 

Protected Member Functions

void set_mode (int)
 Set the mode. More...
 
void add_list (const std::string &filename_)
 Add a file name in the embedded list of filenames. More...
 
void set_list_allow_duplication (bool)
 Set the flag to allow duplicated filenames. More...
 
void set_current_index (int)
 Set the current in incremental/list mode. More...
 

Detailed Description

A class that builds an arbitrary list of filenames on user request. Supported modes are:

Member Typedef Documentation

◆ const_iterator

typedef list_type::const_iterator datatools::smart_filename::const_iterator

◆ list_type

typedef std::vector<std::string> datatools::smart_filename::list_type

Member Enumeration Documentation

◆ mode_t

Enumerator
MODE_INVALID 
MODE_SINGLE 
MODE_LIST 
MODE_INCREMENTAL 

Constructor & Destructor Documentation

◆ smart_filename()

datatools::smart_filename::smart_filename ( )

Default constructor:

◆ ~smart_filename()

virtual datatools::smart_filename::~smart_filename ( )
virtual

Destructor.

Member Function Documentation

◆ add()

void datatools::smart_filename::add ( const std::string &  filename_)

Add a filename in list mode.

◆ add_list()

void datatools::smart_filename::add_list ( const std::string &  filename_)
protected

Add a file name in the embedded list of filenames.

◆ add_to_list()

void datatools::smart_filename::add_to_list ( const std::string &  filename_)

Add a filename in list mode.

◆ begin()

const_iterator datatools::smart_filename::begin ( ) const

Return the first const iterator from the embedded list of filenames.

◆ build_incremental_filename()

void datatools::smart_filename::build_incremental_filename ( int  increment_index_,
std::string &  filename_ 
) const

Build the filename from the increment index in incremental mode.

◆ current_size()

size_t datatools::smart_filename::current_size ( ) const

Return the current number of filenames.

◆ dump()

void datatools::smart_filename::dump ( std::ostream &  out_ = std::clog) const

Raw print.

◆ end()

const_iterator datatools::smart_filename::end ( ) const

Return the fpast-the-end const iterator from the embedded list of filenames.

◆ get_filename()

const std::string& datatools::smart_filename::get_filename ( int  index_) const

Access to a filename by index.

◆ get_logging_priority()

datatools::logger::priority datatools::smart_filename::get_logging_priority ( ) const

Returns logging priority.

◆ get_mode()

int datatools::smart_filename::get_mode ( ) const

Return the mode.

◆ has_filename()

bool datatools::smart_filename::has_filename ( const std::string &  name_,
bool  expand_ = true 
) const

Check if a given filename exists from the embedded list of filenames.

◆ initialize()

void datatools::smart_filename::initialize ( const properties config_)

Initialize from a list of configuration parameters.

◆ is_expand_path()

bool datatools::smart_filename::is_expand_path ( ) const

Check the expand path flag.

◆ is_incremental()

bool datatools::smart_filename::is_incremental ( ) const

Check the incremental mode.

◆ is_initialized()

bool datatools::smart_filename::is_initialized ( ) const

Check the initialization flag.

◆ is_list()

bool datatools::smart_filename::is_list ( ) const

Check the list mode.

◆ is_ranged()

bool datatools::smart_filename::is_ranged ( ) const

Check is the list of filenames is ranged.

◆ is_single()

bool datatools::smart_filename::is_single ( ) const

Check the single mode.

◆ is_valid()

bool datatools::smart_filename::is_valid ( ) const

Check if the object is valid.

◆ make_incremental()

static void datatools::smart_filename::make_incremental ( smart_filename smart_filename_,
const std::string &  path_,
const std::string &  prefix_,
const std::string &  extension_,
int  stopping_index_,
int  starting_index_ = 0,
int  increment_index_ = 1,
const std::string &  suffix_ = "",
int  incremental_index_ndigit_ = 0,
bool  expand_path_ = true 
)
static

Make a smart_filename object in incremental mode.

◆ make_list() [1/2]

static void datatools::smart_filename::make_list ( smart_filename smart_filename_,
bool  allow_duplication_ = false,
bool  expand_path_ = true 
)
static

Make a smart_filename object in list mode.

◆ make_list() [2/2]

static void datatools::smart_filename::make_list ( smart_filename smart_filename_,
const std::string &  list_file_,
bool  allow_duplication_ = false,
bool  expand_path_ = true 
)
static

Make a smart_filename object in list mode.

◆ make_single()

static void datatools::smart_filename::make_single ( smart_filename smart_filename_,
const std::string &  filename_,
bool  expand_path_ = true 
)
static

Make a smart_filename object in single mode.

◆ make_unranged_incremental()

static void datatools::smart_filename::make_unranged_incremental ( smart_filename smart_filename_,
const std::string &  path_,
const std::string &  prefix_,
const std::string &  extension_,
int  starting_index_ = 0,
int  increment_index_ = 1,
const std::string &  suffix_ = "",
int  incremental_index_ndigit_ = 0,
bool  expand_path_ = true 
)
static

Make a smart_filename object in unranged incremental mode.

◆ operator[]()

const std::string& datatools::smart_filename::operator[] ( int  index_) const

Access to a filename by index.

◆ print_list_of_filenames()

void datatools::smart_filename::print_list_of_filenames ( std::ostream &  out_ = std::clog) const

Print the list of filenames.

◆ reset()

void datatools::smart_filename::reset ( )

Reset the object.

◆ set()

void datatools::smart_filename::set ( const std::string &  filename_)

Set the filename in single mode.

◆ set_current_index()

void datatools::smart_filename::set_current_index ( int  )
protected

Set the current in incremental/list mode.

◆ set_list_allow_duplication()

void datatools::smart_filename::set_list_allow_duplication ( bool  )
protected

Set the flag to allow duplicated filenames.

◆ set_logging_priority()

void datatools::smart_filename::set_logging_priority ( datatools::logger::priority  p_)

Set logging priority.

◆ set_mode()

void datatools::smart_filename::set_mode ( int  )
protected

Set the mode.

◆ set_single()

void datatools::smart_filename::set_single ( const std::string &  filename_)

Set the single mode and associated filename.

◆ size()

size_t datatools::smart_filename::size ( ) const

Return the number of filenames.

◆ store_list_of_filenames()

void datatools::smart_filename::store_list_of_filenames ( const std::string &  list_filename_,
bool  append_ = true 
) const

Store the list of filenames in a file.

Member Data Documentation

◆ MODE_INCREMENTAL_DEFAULT_INCREMENT

const int datatools::smart_filename::MODE_INCREMENTAL_DEFAULT_INCREMENT = 1
static

◆ MODE_INCREMENTAL_DEFAULT_START

const int datatools::smart_filename::MODE_INCREMENTAL_DEFAULT_START = 0
static

◆ MODE_INCREMENTAL_UNRANGED

const int datatools::smart_filename::MODE_INCREMENTAL_UNRANGED = -1
static

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