File: parser.cc

package info (click to toggle)
sinfo 0.0.48-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 3,332 kB
  • sloc: sh: 11,213; cpp: 6,722; makefile: 271; xml: 151; perl: 149
file content (32 lines) | stat: -rw-r--r-- 812 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include "parser.h"
#include "messagebasictypes.h"
using namespace std;
using namespace Msg;


void CompositeParser::addParser(int requestID, int replyID, Parser::SPtr sPtr)
{
  myMap.insert(pair<int, ParsingEntry>(requestID, ParsingEntry(requestID,replyID,sPtr)));
}


void CompositeParser::parse(Message & returnMessage, Message & message)
{
  uint8 messageID;
  popFrontuint8(message, messageID);

  // find will return an iterator to the matching element if it is found
  // or to the end of the map if the key is not found
  mapType::const_iterator iter = myMap.find(messageID);
  if ( iter != myMap.end() )
  {
    iter->second.sPtr->parse(returnMessage, message);
    pushFrontuint8(returnMessage,iter->second.replyID);
  }
  else
  {
    cout << "Key is not in myMap" << '\n';
  }
}