PhoenixProtocolBuffer  1.0.1
Set of tools to decode offset from protocol buffer
Loading...
Searching...
No Matches
main.cpp File Reference
#include "data_all.h"
#include "OptionParser.h"
#include "phoenix_protocol_buffer.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

OptionParser createOptionParser ()
 Create the OptionParser of this program.
 
int main (int argc, char **argv)
 
bool printProtocolBufferMessage (const PPath &inputFile, size_t nbMessage, size_t firstMessageIndex, size_t offset)
 Print the messages of the given input file.
 

Function Documentation

◆ createOptionParser()

OptionParser createOptionParser ( )

Create the OptionParser of this program.

Returns
OptionParser of this program

Definition at line 15 of file main.cpp.

15 {
16 OptionParser parser(true, __PROGRAM_VERSION__);
17 parser.setExampleLongOption("phoenix_protocol_buffer_print --input=stream.pzmq --nbmessage=100");
18 parser.setExampleShortOption("phoenix_protocol_buffer_print -i stream.pzmq -n 100");
19
20 parser.addOption("input", "i", OptionType::FILENAME, true, false, "input stream recorded with phoenix_debug_zmq which contains protocol buffer data to be printed");
21 parser.addOption("nbmessage", "n", "1", OptionType::UINT, "Number of messages to be printed");
22 parser.addOption("firstmessage", "f", "0", OptionType::UINT, "Index of the first message to be printed");
23 parser.addOption("offset", "o", "0", OptionType::UINT, "offset of sub-field to be printed");
24 return parser;
25}

Referenced by main().

+ Here is the caller graph for this function:

◆ main()

int main ( int argc,
char ** argv )

Definition at line 50 of file main.cpp.

50 {
51 OptionParser parser = createOptionParser();
52 parser.parseArgument(argc, argv);
53 const OptionMode & defaultMode = parser.getDefaultMode();
54
55 PPath fileName("");
56 defaultMode.getValue(fileName, "input");
57 size_t nbMessage(1lu), firstMessageIndex(0lu);
58 defaultMode.getValue(nbMessage, "nbmessage");
59 defaultMode.getValue(firstMessageIndex, "firstmessage");
60 size_t offset(0lu);
61 defaultMode.getValue(offset, "offset");
62
63 bool b(printProtocolBufferMessage(fileName, nbMessage, firstMessageIndex, offset));
64 return b - 1;
65}
bool printProtocolBufferMessage(const PPath &inputFile, size_t nbMessage, size_t firstMessageIndex, size_t offset)
Print the messages of the given input file.
Definition main.cpp:34
OptionParser createOptionParser()
Create the OptionParser of this program.
Definition main.cpp:15

References createOptionParser(), and printProtocolBufferMessage().

+ Here is the call graph for this function:

◆ printProtocolBufferMessage()

bool printProtocolBufferMessage ( const PPath & inputFile,
size_t nbMessage,
size_t firstMessageIndex,
size_t offset )

Print the messages of the given input file.

Parameters
inputFile: name of the input file to be printed
nbMessage: number of messages to be printed
firstMessageIndex: Index of the first message to be printed
offset: offset of field to be printed
Returns
true on success, false otherwise

Definition at line 34 of file main.cpp.

34 {
35 std::vector<std::vector<char> > vecMessage;
36 if(!data_load(inputFile, vecMessage)){
37 std::cerr << "printProtocolBufferMessage : cannot load file '"<<inputFile<<"'" << std::endl;
38 return false;
39 }
40 std::cout << "Nb Messages loaded = " << vecMessage.size() << std::endl;
41 size_t nbMessageToPrint(std::min(vecMessage.size(), firstMessageIndex + nbMessage));
42 for(size_t i(firstMessageIndex); i < nbMessageToPrint; ++i){
43 std::vector<char> & message = vecMessage[i];
44 std::cout << "["<<i<<", size = "<<message.size()<<"] ";
45 phoenix_printFieldMessage(message.data(), message.size(), offset);
46 }
47 return true;
48}
void phoenix_printFieldMessage(const char *message, size_t nbByte, size_t offset)
Print the Fields in a message.

References phoenix_printFieldMessage().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: