OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNmeaMessage.h
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: MIT See top level LICENSE.txt file.
4 //
5 // File: ossimNmeaMessage.h
6 //
7 // Author: Garrett Potts
8 //
9 // Description: Contains a general parser for NMEA messages.
10 //
11 //
12 // $Id$
13 //----------------------------------------------------------------------------
14 #ifndef ossimNmeaMessage_HEADER
15 #define ossimNmeaMessage_HEADER
16 
17 #include <ossim/base/ossimString.h>
21 #include <iostream>
22 #include <algorithm>
23 #include <vector>
24 
25 
27 {
28 public:
29  typedef std::vector<ossimString> FieldListType;
30 
31  ossimNmeaMessage(const std::string& acceptedStartingCharacters="!$"):m_startChars(acceptedStartingCharacters){}
32 
37  virtual void parseMessage(std::istream& in)throw(ossimException);
38 
39  virtual bool valid()const{return validCheckSum();}
40  bool validCheckSum()const{return m_validCheckSum;}
41 
42 
43  ossim_uint32 numberOfFields()const{return m_fields.size();}
44 
45  const std::string& getField(ossim_uint32 idx)
46  {
47  static ossimString empty="";
48 
49  if(idx < m_fields.size()) return m_fields[idx];
50 
51  return empty;
52  }
53  const std::string& operator [](int idx)const
54  {
55  static ossimString empty="";
56 
57  if ( idx < static_cast<int>( m_fields.size() ) ) return m_fields[idx];
58 
59  return empty;
60  }
61  void setStartChars(const std::string& acceptedStartingCharacters="!$"){m_startChars = acceptedStartingCharacters;}
62 
63  virtual void reset()
64  {
65  m_fields.clear();
66  m_message = "";
67  m_validCheckSum = false;
68  }
69  const std::string& message()const{return m_message;}
70 
71  static ossim_uint32 checksum(std::string::const_iterator start, std::string::const_iterator end);
72 
73 protected:
74  virtual void setFields(std::string::const_iterator start, std::string::const_iterator end);
75 
76  bool isValidStartChar(char c)const;
77 
78  std::string m_message;
80 
82  std::string m_startChars;
83 };
84 
85 #endif
86 
ossim_uint32 numberOfFields() const
std::vector< ossimString > FieldListType
ossimReferenced allows for shared object ref counting if the reference count ever gets to 0 or less i...
virtual void reset()
void setStartChars(const std::string &acceptedStartingCharacters="!$")
ossimNmeaMessage(const std::string &acceptedStartingCharacters="!$")
const std::string & message() const
unsigned int ossim_uint32
virtual bool valid() const
std::string m_startChars
const std::string & getField(ossim_uint32 idx)
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
std::string m_message
#define OSSIM_DLL
bool validCheckSum() const
FieldListType m_fields