Update build system, documentation and delete temp files
[wave300.git] / tools / rtlogger / logcnv / LogEvt.h
blobe370f70ce020cbdca284f88d3728d655cc866b4a
1 /******************************************************************************
3 Copyright (c) 2012
4 Lantiq Deutschland GmbH
6 For licensing information, see the file 'LICENSE' in the root folder of
7 this software module.
9 ******************************************************************************/
10 #ifndef __LOGEVT_H__
11 #define __LOGEVT_H__
13 #include <string>
14 #include <istream>
15 #include <vector>
16 #include <sstream>
17 #include <iomanip>
19 using namespace std;
21 #include "LogFmtDB.h"
22 #include "aux_utils.h"
24 class CLogEvt
26 friend istream &operator>> (istream &is, CLogEvt &evt);
28 class exc_bad_evt_hdr : public exc_basic
30 public:
31 exc_bad_evt_hdr (uint32 info) {
32 ostringstream ss;
33 ss << "Incorrect LOG event header info:" << hex << showbase << setfill('0') << setw(8) << info ;
34 m_str = ss.str();
38 class exc_bad_data_type : public exc_basic
40 public:
41 exc_bad_data_type (uint8 dtype) {
42 ostringstream ss;
43 ss << "Unknown LOG event data type: " << dtype;
44 m_str = ss.str();
48 public:
49 CLogEvt();
50 virtual ~CLogEvt() {;}
52 string GetSrcString(const CLogFmtDB &fmt_db) const;
53 string GetDstString(const CLogFmtDB &fmt_db) const;
54 string GetMsgString(const CLogFmtDB &fmt_db) const;
55 uint32 GetTS(void) const {
56 return m_ts;
58 uint8 GetOID(void) const {
59 return m_oid;
61 uint8 GetGID(void) const {
62 return m_gid;
64 uint16 GetFID(void) const {
65 return m_fid;
67 uint16 GetLID(void) const {
68 return m_lid;
70 uint8 GetWLANIF(void) const {
71 return m_wlanif;
73 bool HasData(void) const {
74 return m_has_data;
77 protected:
78 void Read(istream &in_s);
80 bool m_has_data;
81 uint32 m_ts;
82 uint8 m_oid;
83 uint8 m_gid;
84 uint16 m_fid;
85 uint16 m_lid;
86 uint8 m_wlanif;
87 bool m_reversed;
89 mutable vector<int8> m_buffer;
92 istream &operator>> (istream &is, CLogEvt &evt);
94 class CLogEvtFmt
96 class exc_bad_format : public exc_basic
98 public:
99 exc_bad_format (string &fmt, size_t offs, uint32 param) {
100 ostringstream ss;
101 ss << "Invalid format string= '" << fmt << "' offset=" << offs <<" param=" << param;
102 m_str = ss.str();
104 exc_bad_format (string &fmt, size_t offs, const char *str) {
105 ostringstream ss;
106 ss << "Invalid format string= '" << fmt << "' offset=" << offs <<" param='" << str << "'";
107 m_str = ss.str();
109 exc_bad_format (string &fmt, size_t offs, const void *) {
110 ostringstream ss;
111 ss << "Invalid format string= '" << fmt << "' offset=" << offs <<" param is binary data";
112 m_str = ss.str();
115 public:
116 CLogEvtFmt(const CLogEvt &evt)
117 : m_evt(evt)
118 , m_in_progress(false)
119 , m_offset(0)
122 ~CLogEvtFmt()
125 void BeginFormat(const CLogFmtDB &fmt_db);
126 template<typename T>
127 void PutParam(const T& val);
128 void EndFormat(void);
130 string &GetFormatResult(void) {
131 return m_res;
134 protected:
135 bool TryProcessOwnExtension(const string& val_format, const int8 &val);
136 bool TryProcessOwnExtension(const string& val_format, const int32 &val);
137 bool TryProcessOwnExtension(const string& val_format, const int64 &val);
138 bool TryProcessOwnExtension(const string& val_format, const void *val);
140 const CLogEvt &m_evt;
141 string m_format;
142 bool m_in_progress;
143 size_t m_offset;
144 string m_res;
147 #endif // __LOGEVT_H__