70 const std::string k_numbers =
"0123456789";
71 const std::string k_seqMarks =
"#@";
72 const std::string k_framePlaceholder =
"####";
73 const size_t npos = std::string::npos;
82 const size_t seqMarkIdx = sequence.find_first_of(k_seqMarks);
85 if (seqMarkIdx == npos) {
90 if (sequence.find_first_of(k_seqMarks, seqMarkIdx + 1) != npos) {
91 std::stringstream warning;
92 warning <<
"Multiple sequence marks in filename: " << sequence;
98 size_t seqEndIdx = sequence.find_last_not_of(k_numbers, seqMarkIdx - 1);
99 if (seqEndIdx == npos) {
100 std::stringstream warning;
101 warning <<
"Sequence mark but no sequence range in filename: " 108 if (seqEndIdx == 0) {
109 std::stringstream warning;
110 warning <<
"Sequence mark preceded by single number: " 117 if (sequence[seqEndIdx - 1] !=
'-') {
118 std::stringstream warning;
119 warning <<
"Sequence mark preceded by single number but no '-': " 126 size_t seqStartIdx = sequence.find_last_not_of(k_numbers, seqEndIdx - 2);
127 if (seqStartIdx == npos) {
128 std::stringstream warning;
129 warning <<
"No sequence start in filename: " 138 const std::string startStr = sequence.substr(seqStartIdx, seqEndIdx - 1);
139 const std::string endStr = sequence.substr(seqEndIdx, seqMarkIdx);
142 const int start = atoi(startStr.c_str());
143 const int end = atoi(endStr.c_str());
146 const std::string baseStart = sequence.substr(0, seqStartIdx);
147 const std::string baseEnd = sequence.substr(seqMarkIdx + 1);
150 for (
int i = start; i <= end; ++i) {
152 filename << baseStart << i << baseEnd;
const std::string & filename(const size_t idx) const
Returns a single filename.
Contains the Field3DFile classesOSS sanitized.
#define FIELD3D_NAMESPACE_SOURCE_CLOSE
std::vector< std::string > m_filenames
Stores the resulting filenames.
FIELD3D_API void print(Severity severity, const std::string &message)
Sends the string to the assigned output, prefixing the message with the severity. ...
Contains the Log class which can be used to redirect output to an arbitrary destination.
bool fileExists(const std::string &filename)
checks to see if a file/directory exists or not
FileSequence()
Default constructor. Creates an empty sequence.
Contains the FileSequence class which can be used to turn strings such as "file.1-20#.f3d" into a vector of strings.