Fileseq C++ API
A library for parsing file sequence strings commonly used in VFX and animation applications.
fileseq::FileSequence Class Reference

#include <sequence.h>

Public Member Functions

 FileSequence ()
 
 FileSequence (const std::string &path, Status *ok=nullptr)
 
 FileSequence (const std::string &path, PadStyle padStyle, Status *ok=nullptr)
 
 FileSequence (const FileSequence &rhs)
 
FileSequenceoperator= (FileSequence rhs)
 
bool isValid () const
 
 operator bool () const
 
std::string string () const
 
 operator std::string () const
 
size_t length () const
 
Frame start () const
 
Frame end () const
 
int zfill () const
 
std::string format (const std::string &fmt, Status *ok=nullptr) const
 
std::string dirname () const
 
void setDirname (const std::string &dirname) const
 
std::string basename () const
 
void setBasename (const std::string &basename) const
 
std::string ext () const
 
void setExt (const std::string &ext) const
 
std::string padding () const
 
void setPadding (const std::string &padChars) const
 
PadStyle paddingStyle () const
 
void setPaddingStyle (PadStyle style) const
 
std::string frameRange (bool padded=false) const
 
void setFrameRange (const std::string &frange, Status *ok=nullptr)
 
std::string invertedFrameRange (bool padded=false) const
 
std::string index (size_t idx) const
 
std::string frame (Frame frame) const
 
std::string frame (const std::string &fillPattern) const
 
FrameSet frameSet ()
 
void setFrameSet (const FrameSet &frameSet)
 

Friends

void swap (FileSequence &first, FileSequence &second)
 
std::ostream & operator<< (std::ostream &stream, const FileSequence &fs)
 
FileSequence findSequenceOnDisk (const std::string &pattern, Status *ok)
 
FileSequence findSequenceOnDisk (const std::string &pattern, PadStyle style, Status *ok)
 
Status findSequencesOnDisk (FileSequences &seqs, const std::string &path, bool hiddenFiles, bool singleFiles, PadStyle style)
 

Detailed Description

Represents a path to a sequence of files, and expresses a valid frames range (one that can be parsed by FrameSet. It also includes one or more padding characters to dictate how much padding the actual file numbers have.

Valid padding characters:

@ - 1 pad width (@@@@ is equal to 4 padding)
# - 4 pad width (## is equal to 8 padding)

Example paths and padding:

/path/to/single_image.0100.jpg
/path/to/image_foo.1-10x2#.jpg   (i.e. 0001)
/path/to/[email protected]   (i.e. 1)
/path/to/image_foo.1-10x2@@@.jpg (i.e. 001)

Constructor & Destructor Documentation

◆ FileSequence() [1/3]

fileseq::FileSequence::FileSequence ( )

Default constructor creates an invalid FileSequence

◆ FileSequence() [2/3]

fileseq::FileSequence::FileSequence ( const std::string &  path,
Status ok = nullptr 
)
explicit

Create a FileSequence from a string sequence path. The path should be a valid sequence, expressing a frame range, or a single file path.

If error is non-nil, then the given sequence string could not be successfully parsed.

PadStyleDefault is used as the padding character formatter

Example paths: /path/to/image_foo.1-10x2#.jpg /path/to/single_image.0100.jpg

◆ FileSequence() [3/3]

fileseq::FileSequence::FileSequence ( const std::string &  path,
PadStyle  padStyle,
Status ok = nullptr 
)

Create a FileSequence from a string sequence path. The path should be a valid sequence, expressing a frame range, or a single file path.

If error is non-nil, then the given sequence string could not be successfully parsed.

The sequence uses the style of padding given, in order to convert between padding characters and their numeric width.

Example path w/ PadStyleHash1: /path/to/image_foo.1-10x2#.jpg => /path/to/image_foo.1.jpg ... /path/to/image_foo.1-10x2.jpg => /path/to/image_foo.1.jpg ... /path/to/image_foo.1-10x2##.jpg => /path/to/image_foo.01.jpg ...

Example path w/ PadStyleHash4: /path/to/image_foo.1-10x2#.jpg => /path/to/image_foo.0001.jpg ... /path/to/image_foo.1-10x2.jpg => /path/to/image_foo.1.jpg ... /path/to/image_foo.1-10x2##.jpg => /path/to/image_foo.00000001.jpg ...

Member Function Documentation

◆ basename()

std::string fileseq::FileSequence::basename ( ) const

Basename returns the parsed basename component of the sequence string. This is the file part, just before the frame range component.

Here is the call graph for this function:

◆ dirname()

std::string fileseq::FileSequence::dirname ( ) const

Dirname returns the parsed directory component of the sequence string

Here is the call graph for this function:

◆ end()

Frame fileseq::FileSequence::end ( ) const

Return the last frame number in the range

Here is the call graph for this function:

◆ ext()

std::string fileseq::FileSequence::ext ( ) const

Ext returns the file extension component from the sequence, including the leading period character.

Here is the call graph for this function:

◆ format()

std::string fileseq::FileSequence::format ( const std::string &  fmt,
Status ok = nullptr 
) const

Format returns the file sequence as a formatted string according to the given template.

Utilizes a template syntax with a set of available replacement symbols. These symbols are expressed in the form: {{SYMBOL}}

Parameters
dir- the directory name.
base- the basename of the sequence (leading up to the frame range).
ext- the file extension of the sequence including leading period.
startf- the start frame.
endf- the end frame.
len- the length of the frame range.
pad- the detected padding characters (i.e. # , @@ , ...).
frange- the frame range.
inverted- the inverted frame range. (returns empty string if none)
zfill- the int width of the frame padding

Example:

{{dir}}{{base}}{{frange}}{{pad}}{{ext}}
Here is the call graph for this function:

◆ frame() [1/2]

std::string fileseq::FileSequence::frame ( const std::string &  fillPattern) const

Frame returns a path to the given frame in the sequence. Integer or string digits are treated as a frame number and padding is applied, all other values are passed though.

Example:

seq.frame(1)
>> /foo/bar.0001.exr

seq.frame("#")
>> /foo/bar.#.exr
Here is the call graph for this function:

◆ frame() [2/2]

std::string fileseq::FileSequence::frame ( Frame  frame) const

Frame returns a path to the given frame in the sequence. Integer or string digits are treated as a frame number and padding is applied, all other values are passed though.

Example:

seq.frame(1)
>> /foo/bar.0001.exr

seq.frame("#")
>> /foo/bar.#.exr
Here is the call graph for this function:

◆ frameRange()

std::string fileseq::FileSequence::frameRange ( bool  padded = false) const

FrameRange returns the string frame range component, parsed from the sequence. If no frame range was parsed, then this method will return an empty string. If padded is true, then pad the frame range using the zfill

Here is the call graph for this function:

◆ frameSet()

FrameSet fileseq::FileSequence::frameSet ( )

FrameSet returns a FrameSet instance that was created when the sequence was parsed. If no frame range was parsed from the sequence, then this method will return an invalid FrameSet.

◆ index()

std::string fileseq::FileSequence::index ( size_t  idx) const

Index returns the path to the file at the given index in the sequence. If a frame range was not parsed from the sequence, this will always returns the original path. If the index is not valid, this will return an empty string.

Here is the call graph for this function:

◆ invertedFrameRange()

std::string fileseq::FileSequence::invertedFrameRange ( bool  padded = false) const

InvertedFrameRange returns a new frame range that represents all frames not within the current frame range. That is, it will create a range that "fills in" the current one. If padded is true, then pad out frames using zfill

Here is the call graph for this function:

◆ isValid()

bool fileseq::FileSequence::isValid ( ) const

Return whether the sequence was properly parsed and is valid for use

Here is the call graph for this function:

◆ length()

size_t fileseq::FileSequence::length ( ) const

The number of files/frames in the sequence range

Here is the call graph for this function:

◆ operator bool()

fileseq::FileSequence::operator bool ( ) const
inline

Return whether the sequence was properly parsed and is valid for use

Here is the call graph for this function:

◆ padding()

std::string fileseq::FileSequence::padding ( ) const

Returns the parsed padding characters component of the sequence string. May return an empty string if the file sequence was really a single file. i.e. # or @ or @@

Here is the call graph for this function:

◆ paddingStyle()

PadStyle fileseq::FileSequence::paddingStyle ( ) const

Returns the style of padding being used to convert between characters and their numeric width, i.e. # == 4

Here is the call graph for this function:

◆ setBasename()

void fileseq::FileSequence::setBasename ( const std::string &  basename) const

Set the basename component of the sequence string. This is the file part, just before the frame range component.

Here is the call graph for this function:

◆ setDirname()

void fileseq::FileSequence::setDirname ( const std::string &  dirname) const

Set the dir name component of the sequence string

Here is the call graph for this function:

◆ setExt()

void fileseq::FileSequence::setExt ( const std::string &  ext) const

Set a new extension component for the sequence, which should include the leading period character.

Here is the call graph for this function:

◆ setFrameRange()

void fileseq::FileSequence::setFrameRange ( const std::string &  frange,
Status ok = nullptr 
)

Set a new FrameSet, by way of providing a string frame range.

◆ setFrameSet()

void fileseq::FileSequence::setFrameSet ( const FrameSet frameSet)

Set a new FrameSet for this sequence

Here is the call graph for this function:

◆ setPadding()

void fileseq::FileSequence::setPadding ( const std::string &  padChars) const

Set new padding characters for the sequence, i.e. # or @ or @@

◆ setPaddingStyle()

void fileseq::FileSequence::setPaddingStyle ( PadStyle  style) const

Returns the style of padding being used to convert between characters and their numeric width, i.e. # == 4

Here is the call graph for this function:

◆ start()

Frame fileseq::FileSequence::start ( ) const

Return the first frame number in the range

Here is the call graph for this function:

◆ string()

std::string fileseq::FileSequence::string ( ) const

Return the string representation of the file sequence

Here is the call graph for this function:

◆ zfill()

int fileseq::FileSequence::zfill ( ) const

zfill returns the number of "0" fill characters used to pad the frame numbers to match the actual file paths

Here is the call graph for this function:

Friends And Related Function Documentation

◆ findSequenceOnDisk [1/2]

FileSequence findSequenceOnDisk ( const std::string &  pattern,
PadStyle  style,
Status ok 
)
friend

FindSequenceOnDisk takes a string that is a compatible/parsible FileSequence pattern, and finds a sequence on disk which matches the basename and extension. The returned seq will use the given padding style. If no match is found, an invalid FileSequence is returned. If an error occurs while reading the filesystem, it can be captured by passing a fileseq::Status pointer.

◆ findSequenceOnDisk [2/2]

FileSequence findSequenceOnDisk ( const std::string &  pattern,
Status ok 
)
friend

FindSequenceOnDisk takes a string that is a compatible/parsible FileSequence pattern, and finds a sequence on disk which matches the basename and extension. If no match is found, an invalid FileSequence is returned. If an error occurs while reading the filesystem, it can be captured by passing a fileseq::Status pointer.


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