Fileseq C++ API
A library for parsing file sequence strings commonly used in VFX and animation applications.
pad.h
1 #ifndef FILESEQ_PAD_H_
2 #define FILESEQ_PAD_H_
3 
4 #include <map>
5 #include <string>
6 #include <vector>
7 
8 
9 namespace fileseq {
10 
11 
12 // Constants defining the style of padding to use
13 // when converting between padding characters ('#', '##', '@@@')
14 // and their equivalent numeric padding width
15 enum PadStyle {
16  PadStyleHash1 = 0,
17  PadStyleHash4 = 1,
18  PadStyleDefault = PadStyleHash4
19 };
20 
21 
26 std::string padFrameRange(const std::string &frange, size_t pad);
27 
28 
33 std::string getPaddingChars(size_t width);
34 
35 
36 // Internal
37 //
38 
39 namespace internal {
40 
41 // Fwd Decl
42 class PaddingMapper;
43 
44 
45 const PaddingMapper& getPadMapperForStyle(PadStyle style);
46 
47 
48 // PaddingMapper defines behavior for converting between
49 // padding characters and their pad width
51 
52 public:
53  virtual ~PaddingMapper() = default;
54 
55  // Return all supported padding characters
56  std::string getAllChars() const;
57 
58  // Return a width for a string of pad characters
59  size_t getPaddingCharsSize(const std::string &chars) const;
60 
61  // Return the padding string sequence representing a width
62  virtual std::string getPaddingChars(long width) const = 0;
63 
64 protected:
65  typedef std::map<char, size_t> CharSizeMap;
66 
67  // Mapping pad characters to their width
68  // CharSizeMap* m_charToSize;
69  CharSizeMap m_charToSize;
70 
71  // The default padding character to use
72  char m_defaultChar;
73 };
74 
75 
76 class SingleHashPad : public PaddingMapper {
77 
78 public:
79  SingleHashPad();
80 
81  virtual std::string getPaddingChars(long width) const;
82 };
83 
84 
85 class MultiHashPad : public PaddingMapper {
86 
87 public:
88  MultiHashPad();
89 
90  virtual std::string getPaddingChars(long width) const;
91 };
92 
93 
94 } // internal
95 
96 
97 } // fileseq
98 
99 #endif // FILESEQ_PAD_H_
100