Fileseq C++ API
A library for parsing file sequence strings commonly used in VFX and animation applications.
frameset.h
1 #ifndef FILESEQ_FRAMESET_H_
2 #define FILESEQ_FRAMESET_H_
3 
4 #include "ranges/ranges.h"
5 
6 #include <algorithm>
7 #include <inttypes.h>
8 #include <ostream>
9 #include <string>
10 #include <vector>
11 
12 
13 namespace fileseq {
14 
15 // Forward decl
16 class Status;
17 class FileSequence;
18 
19 
20 namespace internal {
21 
22 // Forward decl
23 class FrameSetData;
24 struct RangePatternMatch;
25 
26 } // internal
27 
28 
29 // typedefs
30 typedef long Frame;
31 typedef std::vector<Frame> Frames;
32 
33 
39 class FrameSet {
40 
41 public:
47  explicit FrameSet(const std::string &frange, Status* ok=nullptr);
48 
50  FrameSet();
51 
52  // Destructor
53  virtual ~FrameSet();
54 
55  // Copy constructor
56  FrameSet(const FrameSet& rhs);
57 
58  // Assignment
59  FrameSet& operator=(FrameSet rhs) {
60  // Swap with copied arg
61  swap(*this, rhs);
62  return *this;
63  }
64 
65  // Swap functionality
66  friend void swap(FrameSet &first, FrameSet &second) {
67  using std::swap;
68 
69  swap(first.m_frameData, second.m_frameData);
70  }
71 
73  bool isValid() const;
74 
76  std::string string() const;
77 
78  operator std::string() const { return string(); }
79 
80  friend std::ostream& operator<< (std::ostream& stream, const FrameSet& fs) {
81  stream << fs.string();
82  return stream;
83  }
84 
86  size_t length() const;
87 
92  size_t index(Frame frame) const;
93 
98  Frame frame(size_t index, Status* ok=nullptr) const;
99 
108  void frames(Frames &frames) const;
109 
122  RangesIterator iterFrames() const;
123 
125  bool hasFrame(Frame frame) const;
126 
128  Frame start() const;
129 
131  Frame end() const;
132 
138  std::string frameRange(int pad=0) const;
139 
144  FrameSet inverted() const;
145 
151  std::string invertedFrameRange(int pad) const;
152 
154  FrameSet normalized() const;
155 
156 private:
157  // Process a rangePattern match group
158  void handleMatch(const internal::RangePatternMatch* match, Status* ok);
159 
160  // Reset the FrameSet to an invalid state;
161  void setInvalid();
162 
163  internal::FrameSetData* m_frameData;
164 
165 private:
166  friend class FileSequence;
167 };
168 
169 } // FILESEQ_FRAMESET_H_
170 
171 #endif
Definition: sequence.h:48
Definition: frameset.h:39
void frames(Frames &frames) const
Definition: frameset.cpp:198
std::string string() const
The string representation of the frame range.
Definition: frameset.cpp:178
size_t index(Frame frame) const
Definition: frameset.cpp:186
RangesIterator iterFrames() const
Definition: frameset.cpp:218
FrameSet()
Definition: frameset.cpp:14
bool hasFrame(Frame frame) const
HasFrame returns true if the FrameSet contains the given frame value.
Definition: frameset.cpp:226
std::string frameRange(int pad=0) const
Definition: frameset.cpp:238
FrameSet normalized() const
Normalize returns a new sorted and compacted FrameSet.
Definition: frameset.cpp:285
size_t length() const
The number of frames in the range.
Definition: frameset.cpp:182
Frame frame(size_t index, Status *ok=nullptr) const
Definition: frameset.cpp:190
FrameSet inverted() const
Definition: frameset.cpp:250
Frame start() const
The first frame of the range.
Definition: frameset.cpp:230
bool isValid() const
Return whether the FrameSet is properly parsed and valid as a range.
Definition: frameset.cpp:169
std::string invertedFrameRange(int pad) const
Definition: frameset.cpp:268
Frame end() const
The last frame in the range.
Definition: frameset.cpp:234
Definition: ranges.h:141
Definition: error.h:31