Garmin Fleet Management Controller  2.19.0
AobrdShipment.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * MODULE NAME:
4 * AobrdShipment.cpp
5 *
6 * Copyright 2012 by Garmin Ltd. or its subsidiaries.
7 *---------------------------------------------------------------------
8 * $NoKeywords$
9 *********************************************************************/
10 
11 #include "AobrdShipment.h"
12 
13 using namespace std;
14 
15 //----------------------------------------------------------------------
17 //----------------------------------------------------------------------
19  : mServerTimestamp(0),
20  mServerStartTime(0),
21  mServerEndTime(0)
22 {
23 
24 }
25 
26 //----------------------------------------------------------------------
28 //----------------------------------------------------------------------
30 {
31 }
32 
33 //----------------------------------------------------------------------
37 //----------------------------------------------------------------------
39 {
40  return mServerTimestamp;
41 }
42 
43 //----------------------------------------------------------------------
47 //----------------------------------------------------------------------
49 {
50  return mServerStartTime;
51 }
52 
53 //----------------------------------------------------------------------
57 //----------------------------------------------------------------------
59 {
60  return mServerEndTime;
61 }
62 
63 //----------------------------------------------------------------------
67 //----------------------------------------------------------------------
69 {
70  CString shipperName;
71  TCHAR tcharName[50];
72  MultiByteToWideChar( CP_UTF8, 0, mShipperName.c_str(), -1, tcharName, 50 );
73  shipperName.SetString( tcharName );
74 
75  return shipperName;
76 }
77 
78 //----------------------------------------------------------------------
82 //----------------------------------------------------------------------
84 {
85  CString docNumber;
86  TCHAR tcharName[50];
87  MultiByteToWideChar( CP_UTF8, 0, mDocNumber.c_str(), -1, tcharName, 50 );
88  docNumber.SetString( tcharName );
89 
90  return docNumber;
91 }
92 
93 //----------------------------------------------------------------------
97 //----------------------------------------------------------------------
99 {
100  CString commodity;
101  TCHAR tcharName[50];
102  MultiByteToWideChar( CP_UTF8, 0, mCommodity.c_str(), -1, tcharName, 50 );
103  commodity.SetString( tcharName );
104 
105  return commodity;
106 }
107 
108 //----------------------------------------------------------------------
113 //----------------------------------------------------------------------
115  (
116  std::istream &aStream
117  )
118 {
119  char temp;
120 
121  aStream >> mServerTimestamp;
122  aStream.get(); // consume the separator
123 
124  aStream >> mServerStartTime;
125  aStream.get(); // consume the separator
126 
127  aStream >> mServerEndTime;
128  aStream.get(); // consume the separator
129 
130  mShipperName.clear();
131  while( aStream.peek() != '\0' && !aStream.eof() )
132  {
133  aStream.read( &temp, 1 );
134  mShipperName.append( 1, temp );
135  }
136 
137  aStream.get(); // consume the '\0' inserted between shipper name and doc number
138 
139  mDocNumber.clear();
140  while( aStream.peek() != '\0' && !aStream.eof() )
141  {
142  aStream.read( &temp, 1 );
143  mDocNumber.append( 1, temp );
144  }
145 
146  aStream.get(); // consume the '\0' inserted between doc number and commodity
147 
148  mCommodity.clear();
149  while( aStream.peek() != '\0' && !aStream.eof() )
150  {
151  aStream.read( &temp, 1 );
152  mCommodity.append( 1, temp );
153  }
154 
155  aStream.get(); // consume the '\0'
156  aStream.get(); // consume the '\n'
157 
158  if( !aStream.eof() )
159  {
160  //mIsValid = TRUE;
161  }
162 }
163 
164 //----------------------------------------------------------------------
168 //----------------------------------------------------------------------
169 void AobrdShipment::setShipperName( const string & aShipperName )
170 {
171  mShipperName = aShipperName;
172 }
173 
174 //----------------------------------------------------------------------
178 //----------------------------------------------------------------------
179 void AobrdShipment::setDocNumber( const string & aDocNumber )
180 {
181  mDocNumber = aDocNumber;
182 }
183 
184 //----------------------------------------------------------------------
188 //----------------------------------------------------------------------
189 void AobrdShipment::setCommodity( const string & aCommodity )
190 {
191  mCommodity = aCommodity;
192 }
193 
194 //----------------------------------------------------------------------
198 //----------------------------------------------------------------------
200 {
201  mServerTimestamp = aTimestamp;
202 }
203 
204 //----------------------------------------------------------------------
208 //----------------------------------------------------------------------
210 {
211  mServerStartTime = aTimestamp;
212 }
213 
214 //----------------------------------------------------------------------
218 //----------------------------------------------------------------------
219 void AobrdShipment::setServerEndTime( const time_type & aTimestamp )
220 {
221  mServerEndTime = aTimestamp;
222 }
223 
224 //----------------------------------------------------------------------
228 //----------------------------------------------------------------------
230  (
231  std::ofstream &aStream
232  ) const
233 {
234  aStream << mServerTimestamp << '\0' << mServerStartTime << '\0' << mServerEndTime << '\0'
235  << mShipperName << '\0' << mDocNumber << '\0' << mCommodity << '\0' << '\n';
236 }
void setServerEndTime(const time_type &aTimestamp)
Set the Server End Time for this item.
void setDocNumber(const std::string &aDocNumber)
Set the Document Number for this item.
void setServerTimestamp(const time_type &aTimestamp)
Set the Server Timestamp for this item.
std::string mCommodity
The commodity, UTF8 encoded.
Definition: AobrdShipment.h:55
time_type getServerTimestamp() const
Get item&#39;s server timestamp.
void setCommodity(const std::string &aCommodity)
Set the Commodity for this item.
time_type mServerStartTime
The server start time.
Definition: AobrdShipment.h:61
STL namespace.
time_type mServerTimestamp
The server timestamp.
Definition: AobrdShipment.h:58
time_type mServerEndTime
The server end time.
Definition: AobrdShipment.h:64
std::string mShipperName
The shipper name, UTF8 encoded.
Definition: AobrdShipment.h:49
void writeToStream(std::ofstream &aStream) const
Write a AobrdShipment to an output stream.
time_type getServerStartTime() const
Get item&#39;s server start time.
std::string mDocNumber
The document number, UTF8 encoded.
Definition: AobrdShipment.h:52
virtual ~AobrdShipment()
Destructor.
CString getShipperName() const
Get item&#39;s shipper name.
void setServerStartTime(const time_type &aTimestamp)
Set the Server Start Time for this item.
CString getCommodity() const
Get item&#39;s commodity.
AobrdShipment()
Constructor.
void setShipperName(const std::string &aShipperName)
Set the Shipper Name for this item.
time_type getServerEndTime() const
Get item&#39;s server end time.
uint32 time_type
Absolute time (number of seconds since 12/31/1989 12:00 am UTC)
Definition: garmin_types.h:97
void readFromStream(std::istream &aStream)
Read a AobrdShipment from an input stream.
CString getDocNumber() const
Get item&#39;s document number.