Public Types | Static Public Member Functions | Static Private Member Functions | Friends | List of all members
gnsstk::FileSpecFind Class Reference

Detailed Description

Find existing files matching specified criteria.

Example with text spec token (x):

gnsstk::CommonTime fromTime(gnsstk::YDSTime(2018, 211, 0));
gnsstk::CommonTime toTime(gnsstk::YDSTime(2018, 212, 0));
string site("FOO");
textStore[gnsstk::FileSpec::text] = site;
std::list<std::string> fileList = gnsstk::FileSpecFind::find("/data/%04Y/%05n/%03j/nsh-%x-%5n-%1r-%04Y-%03j-%02H%02M%02S.xml", fromTime, toTime, textStore);

Example without text spec token:

fromTime = gnsstk::YDSTime(2017,1,0);
toTime = gnsstk::YDSTime(2017,2,0);
std::list<std::string> fileList = gnsstk::FileSpecFind::find(
"/archive/%04Y/%05n/%05n-%04Y%03j-%1r%1t.raw",
fromTime, toTime, fsts);

Definition at line 83 of file FileSpecFind.hpp.

#include <FileSpecFind.hpp>

Public Types

typedef std::multimap< FileSpec::FileSpecType, std::string > Filter
 Data type for storing desired FileSpec values. More...
 

Static Public Member Functions

static std::list< std::string > find (const FileSpec &fileSpec, const CommonTime &start, const CommonTime &end, const FileSpec::FSTStringMap &fsts=FileSpec::FSTStringMap())
 
static std::list< std::string > find (const FileSpec &fileSpec, const CommonTime &start, const CommonTime &end, const Filter &filter)
 
static std::list< std::string > find (const std::string &fileSpec, const CommonTime &start, const CommonTime &end, const FileSpec::FSTStringMap &fsts=FileSpec::FSTStringMap())
 
static std::list< std::string > find (const std::string &fileSpec, const CommonTime &start, const CommonTime &end, const Filter &filter)
 

Static Private Member Functions

static std::list< std::string > findGlob (const CommonTime &start, const CommonTime &end, const std::string &spec, const FileSpec::FSTStringMap &dummyFSTS, const Filter &filter, const std::string &matched="", std::string::size_type pos=0)
 
static std::string transToken (const std::string &token)
 

Friends

class ::FileSpecFind_T
 

Member Typedef Documentation

◆ Filter

typedef std::multimap<FileSpec::FileSpecType, std::string> gnsstk::FileSpecFind::Filter

Data type for storing desired FileSpec values.

Definition at line 87 of file FileSpecFind.hpp.

Member Function Documentation

◆ find() [1/4]

static std::list<std::string> gnsstk::FileSpecFind::find ( const FileSpec fileSpec,
const CommonTime start,
const CommonTime end,
const FileSpec::FSTStringMap fsts = FileSpec::FSTStringMap() 
)
inlinestatic

Search for existing files matching a given file spec and time range. May be used for file spec strings that contain (non-time) tokens with no width specified, provided specific values are added to fsts to fix the width.

Parameters
[in]fileSpecThe FileSpec that the files should match.
[in]startFiles/directories that precede this time will be ignored.
[in]endFiles/directories that are after this time will be ignored.
[in]fstsFiller values for fileSpec that have no fixed width. For example, "text" tokens may have no width specified in fileSpec, e.g. "%x", in which case a value should be added here to derive a length from.
Warning
You will not get any matches for file names that contain tokens with no width (e.g. "%x") if you do not specify a text value in fsts.
Returns
A list of matching file names.

Definition at line 116 of file FileSpecFind.hpp.

◆ find() [2/4]

static std::list<std::string> gnsstk::FileSpecFind::find ( const FileSpec fileSpec,
const CommonTime start,
const CommonTime end,
const Filter filter 
)
inlinestatic

Search for existing files matching a given file spec, time range, and set of allowed FileSpec token values.

Parameters
[in]fileSpecThe FileSpec that the files should match.
[in]startFiles/directories that precede this time will be ignored.
[in]endFiles/directories that are after this time will be ignored.
[in]filterSet of allowable values for tokens present in fileSpec (values for tokens not present will be ignored).
Returns
A list of matching file names.

Definition at line 143 of file FileSpecFind.hpp.

◆ find() [3/4]

list< string > gnsstk::FileSpecFind::find ( const std::string &  fileSpec,
const CommonTime start,
const CommonTime end,
const FileSpec::FSTStringMap fsts = FileSpec::FSTStringMap() 
)
static

Search for existing files matching a given file spec and time range. May be used for file spec strings that contain (non-time) tokens with no width specified, provided specific values are added to fsts to fix the width.

Parameters
[in]fileSpecThe FileSpec that the files should match.
[in]startFiles/directories that precede this time will be ignored.
[in]endFiles/directories that are after this time will be ignored.
[in]fstsFiller values for fileSpec that have no fixed width. For example, "text" tokens may have no width specified in fileSpec, e.g. "%x", in which case a value should be added here to derive a length from.
Warning
You will not get any matches for file names that contain tokens with no width (e.g. "%x") if you do not specify a text value in fsts.
Returns
A list of matching file names.

Definition at line 225 of file FileSpecFind.cpp.

◆ find() [4/4]

std::list< std::string > gnsstk::FileSpecFind::find ( const std::string &  fileSpec,
const CommonTime start,
const CommonTime end,
const Filter filter 
)
static

Search for existing files matching a given file spec, time range, and set of allowed FileSpec token values.

Parameters
[in]fileSpecThe FileSpec that the files should match.
[in]startFiles/directories that precede this time will be ignored.
[in]endFiles/directories that are after this time will be ignored.
[in]filterSet of allowable values for tokens present in fileSpec (values for tokens not present will be ignored).
Returns
A list of matching file names.

Definition at line 283 of file FileSpecFind.cpp.

◆ findGlob()

list< string > gnsstk::FileSpecFind::findGlob ( const CommonTime start,
const CommonTime end,
const std::string &  spec,
const FileSpec::FSTStringMap dummyFSTS,
const Filter filter,
const std::string &  matched = "",
std::string::size_type  pos = 0 
)
staticprivate

Recursive (into subdirectories) function for find that uses glob. Look at the .cpp file for a more detailed description of how this works.

Parameters
[in]startFiles/directories that precede this time will be ignored.
[in]endFiles/directories that are after this time will be ignored.
[in]specThe string representation of the FileSpec that the files should match.
[in]dummyFSTSFiller values for the file spec when creating dummy file names to get appropriate time ranges.
[in]matchedA string containing already-matched paths when recursion occurs. This string replaces spec[0] through spec[pos] when doing searches.
[in]posStarting position (from 0) into spec to start looking for FileSpec tokens. Used to support recursion.
Returns
A list of matching file names.

Definition at line 474 of file FileSpecFind.cpp.

◆ transToken()

string gnsstk::FileSpecFind::transToken ( const std::string &  token)
staticprivate

Translates FileSpec formatting tokens into glob expressions.

Parameters
[in]tokenA string containing FileSpec formatting tokens e.g. %04Y.
Returns
a string with all of the known formatting tokens replaced with glob patterns that have a reasonable chance of matching names of existing files generated using the FileSpec. For example, %04Y would become [0-9][0-9][0-9][0-9]

Definition at line 308 of file FileSpecFind.cpp.

Friends And Related Function Documentation

◆ ::FileSpecFind_T

friend class ::FileSpecFind_T
friend

Definition at line 189 of file FileSpecFind.hpp.


The documentation for this class was generated from the following files:
gnsstk::FileSpec::FSTStringMap
std::map< FileSpecType, std::string > FSTStringMap
Definition: FileSpec.hpp:136
gnsstk::YDSTime
Definition: YDSTime.hpp:58
gnsstk::FileSpecFind::find
static std::list< std::string > find(const std::string &fileSpec, const CommonTime &start, const CommonTime &end, const FileSpec::FSTStringMap &fsts=FileSpec::FSTStringMap())
Definition: FileSpecFind.cpp:225
gnsstk::CommonTime
Definition: CommonTime.hpp:84
gnsstk::FileSpec::text
@ text
Definition: FileSpec.hpp:105


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:44