Garmin Fleet Management Controller  2.19.0
InboxListItem.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * MODULE NAME:
4 * InboxListItem.cpp
5 *
6 * Copyright 2008-2011 by Garmin Ltd. or its subsidiaries.
7 *---------------------------------------------------------------------
8 * $NoKeywords$
9 *********************************************************************/
10 
11 #include "InboxListItem.h"
12 
13 //----------------------------------------------------------------------
16 //----------------------------------------------------------------------
18  (
19  const key_type & aId
20  )
21 {
22  messageId = aId;
23 }
24 
25 //----------------------------------------------------------------------
28 //----------------------------------------------------------------------
30 {
31  return messageId;
32 }
33 
34 //----------------------------------------------------------------------
37 //----------------------------------------------------------------------
39  (
41  )
42 {
43  mParent = aParent;
44 }
45 
46 //----------------------------------------------------------------------
49 //----------------------------------------------------------------------
51  (
52  std::istream &aStream
53  )
54 {
55  int i;
56  uint8 num;
57  char dummy;
58  uint8 idSize;
59  uint8 id[16];
60 
61  i = 0;
62  aStream >> num;
63  idSize = num;
64  aStream >> dummy; // ignore '-' inserted between id size and id
65  memset( id, 0, 16 );
66  while( aStream.peek() != '\n' && !aStream.eof() )
67  {
68  aStream >> num;
69  aStream >> dummy; //ignore',' inserted between chars of id
70  if( i < 16 )
71  id[i++] = num;
72  }
73  aStream >> dummy; // ignore '\n' inserted after item
74  messageId = MessageId( idSize, id );
75  mIsValid = TRUE;
76 }
77 
78 //----------------------------------------------------------------------
81 //----------------------------------------------------------------------
83  (
84  std::ofstream & aStream
85  )
86 {
87  const uint8 * id = messageId.getId();
88 
89  aStream << messageId.getIdSize() << '-';
90  for( int i = 0; i < messageId.getIdSize(); i++ )
91  {
92  aStream << id[i] << ',';
93  }
94  aStream << '\n';
95 }
void setParent(FileBackedMap< InboxListItem > *aParent)
Set the parent of this item.
void writeToStream(std::ofstream &aStream)
Write an InboxListItem to an output stream.
#define TRUE
Definition: garmin_types.h:45
void readFromStream(std::istream &aStream)
Read an InboxListItem from an istream.
FileBackedMap< InboxListItem > * mParent
Definition: InboxListItem.h:38
void setId(const key_type &aId)
Set the ID associated with this item.
BOOL mIsValid
True if this list item is mIsValid.
const key_type & getId() const
Get the ID associated with this item.
const uint8 * getId() const
Return a reference to the bytes of the message ID.
Definition: MessageId.cpp:144
unsigned char uint8
8-bit unsigned integer
Definition: garmin_types.h:62
uint8 getIdSize() const
Return the size of the message ID.
Definition: MessageId.cpp:152
Encapsulation of a message ID.
Definition: MessageId.h:26
MessageId messageId
Definition: InboxListItem.h:39