Fileseq C++ API
A library for parsing file sequence strings commonly used in VFX and animation applications.
|
#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) | |
FileSequence & | operator= (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) |
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)
fileseq::FileSequence::FileSequence | ( | ) |
Default constructor creates an invalid FileSequence
|
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
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 ...
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.
std::string fileseq::FileSequence::dirname | ( | ) | const |
Dirname returns the parsed directory component of the sequence string
Frame fileseq::FileSequence::end | ( | ) | const |
Return the last frame number in the range
std::string fileseq::FileSequence::ext | ( | ) | const |
Ext returns the file extension component from the sequence, including the leading period character.
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}}
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}}
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
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
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
FrameSet fileseq::FileSequence::frameSet | ( | ) |
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.
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
bool fileseq::FileSequence::isValid | ( | ) | const |
Return whether the sequence was properly parsed and is valid for use
size_t fileseq::FileSequence::length | ( | ) | const |
The number of files/frames in the sequence range
|
inline |
Return whether the sequence was properly parsed and is valid for use
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 @@
PadStyle fileseq::FileSequence::paddingStyle | ( | ) | const |
Returns the style of padding being used to convert between characters and their numeric width, i.e. # == 4
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.
void fileseq::FileSequence::setDirname | ( | const std::string & | dirname | ) | const |
Set the dir name component of the sequence string
void fileseq::FileSequence::setExt | ( | const std::string & | ext | ) | const |
Set a new extension component for the sequence, which should include the leading period character.
void fileseq::FileSequence::setFrameRange | ( | const std::string & | frange, |
Status * | ok = nullptr |
||
) |
Set a new FrameSet, by way of providing a string frame range.
void fileseq::FileSequence::setFrameSet | ( | const FrameSet & | frameSet | ) |
void fileseq::FileSequence::setPadding | ( | const std::string & | padChars | ) | const |
Set new padding characters for the sequence, i.e. # or @ or @@
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
Frame fileseq::FileSequence::start | ( | ) | const |
Return the first frame number in the range
std::string fileseq::FileSequence::string | ( | ) | const |
Return the string representation of the file sequence
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
|
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.
|
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.