A FileSpec is how file names are defined. For instance, ASM%4Y.%3j is the file spec for a SMODF file. The format is similar to what you would use in sprintf(), and specifically it uses the same fields as CommonTime::printf(). For the most predictable results, fully specify the field length (as in %4Y vs. Y). Check the FileSpecType enum values for how characters map to fields. Any new fields added should conform to CommonTime or already existing fields, if there are any.
Definition at line 80 of file FileSpec.hpp.
#include <FileSpec.hpp>
Classes | |
class | FileSpecElement |
struct | FileSpecSort |
Public Types | |
enum | FileSpecSortType { ascending, descending } |
enum | FileSpecType { unknown, station, receiver, prn, selected, sequence, version, fixed, clock, text, year, firstTime = year, month, dayofmonth, hour, minute, second, fsecond, gpsweek, fullgpsweek, gpssecond, mjd, dayofweek, day, doysecond, zcount, zcountfloor, unixsec, unixusec, fullzcount, end } |
typedef std::map< FileSpecType, std::string > | FSTStringMap |
Public Member Functions | |
virtual std::string | createSearchString () const |
virtual void | dump (std::ostream &o) const |
semi-nicely print the FileSpec to the stream. More... | |
virtual gnsstk::CommonTime | extractCommonTime (const std::string &filename) const |
virtual std::string | extractField (const std::string &filename, const FileSpecType) const |
FileSpec () | |
Default constructor. More... | |
FileSpec (const std::string &fileSpec) | |
virtual std::string | getSpecString (void) const |
Returns the string of the filespec. More... | |
virtual bool | hasField (FileSpecType fst) const |
bool | hasNonTimeField () const |
Return true if this FileSpec has any non-time fields. More... | |
bool | hasTimeField () const |
Return true if this FileSpec has any time fields. More... | |
virtual FileSpec & | newSpec (const std::string &fileSpec) |
virtual void | sortList (std::vector< std::string > &fileList, const FileSpecSortType fsst=ascending) const |
virtual std::string | toString (const gnsstk::CommonTime &dt, const FSTStringMap &fstsMap=FSTStringMap()) const |
virtual | ~FileSpec () |
Destructor. More... | |
Static Public Member Functions | |
static std::string | convertFileSpecType (const FileSpecType) |
static FileSpecType | convertFileSpecType (const std::string &) |
Protected Member Functions | |
virtual void | init (const std::string &fileSpec) |
Protected Attributes | |
std::vector< FileSpecElement > | fileSpecList |
Holds all of the FileSpecElements for this FileSpec. More... | |
std::set< FileSpecType > | fileSpecSet |
Set of all FileSpecType values present in this FileSpec. More... | |
std::string | fileSpecString |
Holds the string that the fileSpecList was generated from. More... | |
Friends | |
struct | FileSpecSort |
typedef std::map<FileSpecType, std::string> gnsstk::FileSpec::FSTStringMap |
A map from a FileSpecType to a string, used in the toString function.
Definition at line 136 of file FileSpec.hpp.
An enum for identifying the sort order of the list returned from FileHunter.
Enumerator | |
---|---|
ascending | |
descending |
Definition at line 141 of file FileSpec.hpp.
This enum lists the different possible elements you can have in a FileSpec.
Definition at line 93 of file FileSpec.hpp.
|
inline |
Default constructor.
Definition at line 148 of file FileSpec.hpp.
|
inline |
Constructor with a string to parse
FileSpecException |
Definition at line 152 of file FileSpec.hpp.
|
inlinevirtual |
Destructor.
Definition at line 156 of file FileSpec.hpp.
|
static |
Converts the FileSpecType to a string it is identified with.
FileSpecException | when FileSpecType doesn't match any known types |
Definition at line 106 of file FileSpec.cpp.
|
static |
Converts the string into its corresponding FileSpecType
FileSpecException | when FileSpecType doesn't match any known types |
Definition at line 144 of file FileSpec.cpp.
|
virtual |
Returns a string that can be used to search for files matching this FileSpec. Essentailly turns every non-fixed field into strings of '?'.
FileSpecException | when there's an error in the FileSpec |
Definition at line 184 of file FileSpec.cpp.
|
virtual |
semi-nicely print the FileSpec to the stream.
Definition at line 402 of file FileSpec.cpp.
|
virtual |
If possible, returns a CommonTime object with the time the file represents. Since the time resolution only goes to days for most file types, all times are set to midnight of that day. If the FileSpec contains fields without an explicit width, the behavior of this method is currently undefined.
FileSpecException | when a time can't be formed |
Definition at line 247 of file FileSpec.cpp.
|
virtual |
Given a file name and a field, returns that field from the string. Use hasField() first to see if the field exists in the FileSpec. If multiple fields of FileSpecType are defined, only the first is returned. If the FileSpec contains fields without an explicit width, the behavior of this method is currently undefined.
FileSpecException | when the FileSpecType doesn't exist in the FileSpec |
Definition at line 216 of file FileSpec.cpp.
|
inlinevirtual |
Returns the string of the filespec.
Definition at line 164 of file FileSpec.hpp.
|
inlinevirtual |
Given a field type, returns true if the FileSpec has that field.
Definition at line 190 of file FileSpec.hpp.
|
inline |
Return true if this FileSpec has any non-time fields.
Definition at line 198 of file FileSpec.hpp.
|
inline |
Return true if this FileSpec has any time fields.
Definition at line 194 of file FileSpec.hpp.
|
protectedvirtual |
Parses the string into the FileSpec object
FileSpecException |
Definition at line 420 of file FileSpec.cpp.
Reinitializes this FileSpec with the new string
FileSpecException |
Definition at line 160 of file FileSpec.hpp.
|
virtual |
Sort the list of files ascending or descending. The fields of the files are sorted in the order that they're specified in the FileSpecType enum. The list fileList is modified as a result of this. If the files in fileList have paths listed, then only the file name (taken to be the word after the last '/') will be used in the comparison. This function also filters out older versions of files in the fileList.
FileSpecException |
Definition at line 336 of file FileSpec.cpp.
|
virtual |
For the given FileSpec, fills in the fields with the given information and returns a string of that file name. Use the FSTStringMap to provide all the other non-time data for the string (i.e. FSTSMap[station] = "85408";). Any unspecified field will be filled with 0's. The one side affect of this is that you can only specify one of each field in the map, but you're likely not going to need two different station numbers in the file name. If you want, you can put the CommonTime information into the FSTSMap, but it's not necessary.
Definition at line 278 of file FileSpec.cpp.
|
friend |
Definition at line 316 of file FileSpec.hpp.
|
protected |
Holds all of the FileSpecElements for this FileSpec.
Definition at line 310 of file FileSpec.hpp.
|
protected |
Set of all FileSpecType values present in this FileSpec.
Definition at line 312 of file FileSpec.hpp.
|
protected |
Holds the string that the fileSpecList was generated from.
Definition at line 314 of file FileSpec.hpp.