FileSpec Class Reference
[File and Directory Processing Utilities]

#include <FileSpec.hpp>

List of all members.


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 DayTime::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 DayTime or already existing fields, if there are any.

Definition at line 91 of file FileSpec.hpp.

Public Types

typedef std::map< FileSpecType,
std::string > 
FSTStringMap
 A map from a FileSpecType to a string, used in the toString function.
enum  FileSpecType {
  unknown, station, receiver, prn,
  selected, sequence, version, fixed,
  clock, text, year, month,
  dayofmonth, hour, minute, second,
  fsecond, gpsweek, fullgpsweek, gpssecond,
  mjd, dayofweek, day, doysecond,
  zcount, zcountfloor, unixsec, unixusec,
  fullzcount, end
}
 This enum lists the different possible elements you can have in a FileSpec. More...
enum  FileSpecSortType { none, ascending, descending }
 An enum for identifying the sort order of the list returned from FileHunter. More...

Public Member Functions

 FileSpec ()
 Default constructor.
 FileSpec (const std::string &fileSpec) throw (FileSpecException)
 Constructor with a string to parse.
virtual ~FileSpec ()
 Destructor.
virtual FileSpecnewSpec (const std::string &fileSpec) throw (FileSpecException)
 Reinitializes this FileSpec with the new string.
virtual std::string getSpecString (void) const
 Returns the string of the filespec.
virtual std::string createSearchString () const throw (FileSpecException)
 Returns a string that can be used to search for files matching this FileSpec.
virtual std::string extractField (const std::string &filename, const FileSpecType) const throw (FileSpecException)
 Given a file name and a field, returns that field from the string.
virtual bool hasField (const FileSpecType) const throw (FileSpecException)
 Given a field type, returns true if the FileSpec has that field.
virtual gpstk::DayTime extractDayTime (const std::string &filename) const throw (FileSpecException)
 If possible, returns a DayTime object with the time the file represents.
virtual std::string toString (const gpstk::DayTime &dt, const FSTStringMap &fstsMap=FSTStringMap()) const
 For the given FileSpec, fills in the fields with the given information and returns a string of that file name.
virtual void sortList (std::vector< std::string > &fileList, const FileSpecSortType fsst=ascending) const throw (FileSpecException)
 Sort the list of files ascending or descending.
virtual void dump (std::ostream &o) const
 semi-nicely print the FileSpec to the stream.

Static Public Member Functions

std::string convertFileSpecType (const FileSpecType) throw (FileSpecException)
 Converts the FileSpecType to a string it is identified with.
FileSpecType convertFileSpecType (const std::string &) throw (FileSpecException)
 Converts the string into its corresponding FileSpecType
Exceptions:
FileSpecException when FileSpecType doesn't match any known types.


Protected Member Functions

virtual void init (const std::string &fileSpec) throw (FileSpecException)
 Parses the string into the FileSpec object.

Protected Attributes

std::vector< FileSpecElementfileSpecList
 Holds all of the FileSpecElements for this FileSpec.
std::string fileSpecString
 Holds the string that the fileSpecList was generated from.


Member Typedef Documentation

typedef std::map<FileSpecType, std::string> FSTStringMap
 

A map from a FileSpecType to a string, used in the toString function.

Definition at line 145 of file FileSpec.hpp.


Member Enumeration Documentation

enum FileSpecSortType
 

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

Enumeration values:
none 
ascending 
descending 

Definition at line 150 of file FileSpec.hpp.

enum FileSpecType
 

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

Note:
Whenever a format is added or removed from the DayTime 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 DayTime or FileSpec.
Enumeration values:
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
year  'y' or 'Y' A field for a year
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 104 of file FileSpec.hpp.


Constructor & Destructor Documentation

FileSpec  )  [inline]
 

Default constructor.

Definition at line 158 of file FileSpec.hpp.

FileSpec const std::string &  fileSpec  )  throw (FileSpecException) [inline]
 

Constructor with a string to parse.

Definition at line 161 of file FileSpec.hpp.

virtual ~FileSpec  )  [inline, virtual]
 

Destructor.

Definition at line 166 of file FileSpec.hpp.


Member Function Documentation

FileSpec::FileSpecType convertFileSpecType const std::string &   )  throw (FileSpecException) [static]
 

Converts the string into its corresponding FileSpecType

Exceptions:
FileSpecException when FileSpecType doesn't match any known types.

Definition at line 129 of file FileSpec.cpp.

References GPSTK_THROW.

string convertFileSpecType const   FileSpecType  )  throw (FileSpecException) [static]
 

Converts the FileSpecType to a string it is identified with.

Exceptions:
FileSpecException when FileSpecType doesn't match any known types

Definition at line 90 of file FileSpec.cpp.

References gpstk::StringUtils::asString(), and GPSTK_THROW.

Referenced by FileSpec::dump().

string createSearchString  )  const throw (FileSpecException) [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:
FileSpecException when there's an error in the FileSpec

Definition at line 170 of file FileSpec.cpp.

References gpstk::StringUtils::asString(), FileSpec::fileSpecList, and GPSTK_THROW.

void dump std::ostream &  o  )  const [virtual]
 

semi-nicely print the FileSpec to the stream.

Definition at line 422 of file FileSpec.cpp.

References FileSpec::convertFileSpecType(), FileSpec::fileSpecList, and FileSpec::fileSpecString.

Referenced by main().

DayTime extractDayTime const std::string &  filename  )  const throw (FileSpecException) [virtual]
 

If possible, returns a DayTime 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.

Exceptions:
FileSpecException when a time can't be formed

Definition at line 255 of file FileSpec.cpp.

References Exception::addText(), GPSTK_THROW, and DayTime::setToString().

Referenced by main().

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

Exceptions:
FileSpecException when the FileSpecType doesn't exist in the FileSpec

Definition at line 203 of file FileSpec.cpp.

References GPSTK_THROW.

Referenced by main().

virtual std::string getSpecString void   )  const [inline, virtual]
 

Returns the string of the filespec.

Definition at line 174 of file FileSpec.hpp.

bool hasField const   FileSpecType  )  const throw (FileSpecException) [virtual]
 

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

Exceptions:
FileSpecException when you pass in an invalid FileSpecType

Definition at line 234 of file FileSpec.cpp.

References GPSTK_THROW.

void init const std::string &  fileSpec  )  throw (FileSpecException) [protected, virtual]
 

Parses the string into the FileSpec object.

Definition at line 440 of file FileSpec.cpp.

References Exception::addText(), gpstk::StringUtils::asInt(), gpstk::StringUtils::asString(), GPSTK_RETHROW, GPSTK_THROW, and gpstk::StringUtils::stripLeading().

virtual FileSpec& newSpec const std::string &  fileSpec  )  throw (FileSpecException) [inline, virtual]
 

Reinitializes this FileSpec with the new string.

Definition at line 169 of file FileSpec.hpp.

Referenced by main(), and FileFilterFrame::newSource().

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

Definition at line 329 of file FileSpec.cpp.

References index(), and slash.

std::string toString const gpstk::DayTime 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 daytime information into the FSTSMap, but it's not necessary.

Returns:
the new filename.

Definition at line 287 of file FileSpec.cpp.

References FileSpec::fileSpecList, DayTime::printf(), and gpstk::StringUtils::rightJustify().

Referenced by main(), and RTFileFrame::openCurrentFile().


Member Data Documentation

std::vector<FileSpecElement> fileSpecList [protected]
 

Holds all of the FileSpecElements for this FileSpec.

Definition at line 318 of file FileSpec.hpp.

Referenced by FileSpec::createSearchString(), FileSpec::dump(), and FileSpec::toString().

std::string fileSpecString [protected]
 

Holds the string that the fileSpecList was generated from.

Definition at line 320 of file FileSpec.hpp.

Referenced by FileSpec::dump().


The documentation for this class was generated from the following files:
Generated on Wed Feb 8 03:31:38 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1