Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
gnsstk::FileSpec Class Reference

Detailed Description

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 FileSpecnewSpec (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< FileSpecElementfileSpecList
 Holds all of the FileSpecElements for this FileSpec. More...
 
std::set< FileSpecTypefileSpecSet
 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
 

Member Typedef Documentation

◆ FSTStringMap

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.

Member Enumeration Documentation

◆ FileSpecSortType

An enum for identifying the sort order of the list returned from FileHunter.

Enumerator
ascending 
descending 

Definition at line 141 of file FileSpec.hpp.

◆ FileSpecType

This enum lists the different possible elements you can have in a FileSpec.

Note
Whenever a format is added or removed from the CommonTime class, it more than likely should also be added or removed from the FileSpec class. Additionally, the format character must not conflict with any of the existing format characters in CommonTime or FileSpec.
Enumerator
unknown 

Unknown type.

station 

'n' A field for station numbers

receiver 

'r' A field for the receiver number

prn 

'p' A field for PRN number

selected 

't' A field for selected/unselected receiver

sequence 

'I' A sequence number, as in part 1, part 2, etc..

version 

'v' A version number, as in version 2 is more recent than version 1

fixed 

A field for fixed characters.

clock 

'k' A field for the clock number

text 

'x' A field for arbitrary text, left-aligned and space-padded

year 

'y' or 'Y' A field for a year

firstTime 

First enumeration value pertaining to time.

month 

'm' A field for month (numeric)

dayofmonth 

'd' A field for day-of-month

hour 

'H' A field for hours (out of 24)

minute 

'M' A field for minutes (out of 60)

second 

'S' A field for seconds (out of 60)

fsecond 

'f' A field for seconds (float)

gpsweek 

'G' A field for 10 bit GPS weeks

fullgpsweek 

'F' A field for full GPS weeks

gpssecond 

'g' A field for GPS second-of-week

mjd 

'Q' A field for Modified Julian Date

dayofweek 

'w' A field for day-of-week (numeric)

day 

'j' A field for day of year

doysecond 

's' a field for second-of-day (float)

zcount 

'Z' A field for GPS Z-count

zcountfloor 

'z' A field for GPS Z-count rounded down

unixsec 

'U' A field for UNIX seconds

unixusec 

'u' A field for UNIX microseconds

fullzcount 

'C' or 'c' A field for Full GPS Z-count

end 

A place holder for the end of this list.

Definition at line 93 of file FileSpec.hpp.

Constructor & Destructor Documentation

◆ FileSpec() [1/2]

gnsstk::FileSpec::FileSpec ( )
inline

Default constructor.

Definition at line 148 of file FileSpec.hpp.

◆ FileSpec() [2/2]

gnsstk::FileSpec::FileSpec ( const std::string &  fileSpec)
inline

Constructor with a string to parse

Exceptions
FileSpecException

Definition at line 152 of file FileSpec.hpp.

◆ ~FileSpec()

virtual gnsstk::FileSpec::~FileSpec ( )
inlinevirtual

Destructor.

Definition at line 156 of file FileSpec.hpp.

Member Function Documentation

◆ convertFileSpecType() [1/2]

string gnsstk::FileSpec::convertFileSpecType ( const FileSpecType  fst)
static

Converts the FileSpecType to a string it is identified with.

Exceptions
FileSpecExceptionwhen FileSpecType doesn't match any known types

Definition at line 106 of file FileSpec.cpp.

◆ convertFileSpecType() [2/2]

FileSpec::FileSpecType gnsstk::FileSpec::convertFileSpecType ( const std::string &  fst)
static

Converts the string into its corresponding FileSpecType

Exceptions
FileSpecExceptionwhen FileSpecType doesn't match any known types

Definition at line 144 of file FileSpec.cpp.

◆ createSearchString()

string gnsstk::FileSpec::createSearchString ( ) const
virtual

Returns a string that can be used to search for files matching this FileSpec. Essentailly turns every non-fixed field into strings of '?'.

Exceptions
FileSpecExceptionwhen there's an error in the FileSpec

Definition at line 184 of file FileSpec.cpp.

◆ dump()

void gnsstk::FileSpec::dump ( std::ostream &  o) const
virtual

semi-nicely print the FileSpec to the stream.

Definition at line 402 of file FileSpec.cpp.

◆ extractCommonTime()

CommonTime gnsstk::FileSpec::extractCommonTime ( const std::string &  filename) const
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.

Exceptions
FileSpecExceptionwhen a time can't be formed

Definition at line 247 of file FileSpec.cpp.

◆ extractField()

string gnsstk::FileSpec::extractField ( const std::string &  filename,
const  FileSpecType 
) const
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.

Exceptions
FileSpecExceptionwhen the FileSpecType doesn't exist in the FileSpec

Definition at line 216 of file FileSpec.cpp.

◆ getSpecString()

virtual std::string gnsstk::FileSpec::getSpecString ( void  ) const
inlinevirtual

Returns the string of the filespec.

Definition at line 164 of file FileSpec.hpp.

◆ hasField()

virtual bool gnsstk::FileSpec::hasField ( FileSpecType  fst) const
inlinevirtual

Given a field type, returns true if the FileSpec has that field.

Definition at line 190 of file FileSpec.hpp.

◆ hasNonTimeField()

bool gnsstk::FileSpec::hasNonTimeField ( ) const
inline

Return true if this FileSpec has any non-time fields.

Definition at line 198 of file FileSpec.hpp.

◆ hasTimeField()

bool gnsstk::FileSpec::hasTimeField ( ) const
inline

Return true if this FileSpec has any time fields.

Definition at line 194 of file FileSpec.hpp.

◆ init()

void gnsstk::FileSpec::init ( const std::string &  fileSpec)
protectedvirtual

Parses the string into the FileSpec object

Exceptions
FileSpecException

Definition at line 420 of file FileSpec.cpp.

◆ newSpec()

virtual FileSpec& gnsstk::FileSpec::newSpec ( const std::string &  fileSpec)
inlinevirtual

Reinitializes this FileSpec with the new string

Exceptions
FileSpecException

Definition at line 160 of file FileSpec.hpp.

◆ sortList()

void gnsstk::FileSpec::sortList ( std::vector< std::string > &  fileList,
const FileSpecSortType  fsst = ascending 
) const
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.

Exceptions
FileSpecException

Definition at line 336 of file FileSpec.cpp.

◆ toString()

std::string gnsstk::FileSpec::toString ( const gnsstk::CommonTime dt,
const FSTStringMap fstsMap = FSTStringMap() 
) const
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.

Returns
the new filename.

Definition at line 278 of file FileSpec.cpp.

Friends And Related Function Documentation

◆ FileSpecSort

friend struct FileSpecSort
friend

Definition at line 316 of file FileSpec.hpp.

Member Data Documentation

◆ fileSpecList

std::vector<FileSpecElement> gnsstk::FileSpec::fileSpecList
protected

Holds all of the FileSpecElements for this FileSpec.

Definition at line 310 of file FileSpec.hpp.

◆ fileSpecSet

std::set<FileSpecType> gnsstk::FileSpec::fileSpecSet
protected

Set of all FileSpecType values present in this FileSpec.

Definition at line 312 of file FileSpec.hpp.

◆ fileSpecString

std::string gnsstk::FileSpec::fileSpecString
protected

Holds the string that the fileSpecList was generated from.

Definition at line 314 of file FileSpec.hpp.


The documentation for this class was generated from the following files:


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