Directory: | ./ |
---|---|
File: | pdserv-1.1.0/src/Event.cpp |
Date: | 2024-11-17 04:08:36 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 5 | 6 | 83.3% |
Branches: | 2 | 4 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /***************************************************************************** | ||
2 | * | ||
3 | * $Id$ | ||
4 | * | ||
5 | * Copyright 2010 Richard Hacker (lerichi at gmx dot net) | ||
6 | * | ||
7 | * This file is part of the pdserv library. | ||
8 | * | ||
9 | * The pdserv library is free software: you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU Lesser General Public License as published | ||
11 | * by the Free Software Foundation, either version 3 of the License, or (at | ||
12 | * your option) any later version. | ||
13 | * | ||
14 | * The pdserv library is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
16 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | ||
17 | * License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public License | ||
20 | * along with the pdserv library. If not, see <http://www.gnu.org/licenses/>. | ||
21 | * | ||
22 | *****************************************************************************/ | ||
23 | |||
24 | #include "Event.h" | ||
25 | #include "Config.h" | ||
26 | |||
27 | #include <sstream> | ||
28 | |||
29 | using namespace PdServ; | ||
30 | |||
31 | //////////////////////////////////////////////////////////////////////////// | ||
32 | 20 | Event::Event(const char *path, const Priority& prio, | |
33 | 20 | size_t nelem, const char **messages): | |
34 | path(path), | ||
35 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
|
20 | priority(prio), |
36 | nelem(nelem), | ||
37 |
1/2✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
40 | message(messages) |
38 | { | ||
39 | 20 | } | |
40 | |||
41 | //////////////////////////////////////////////////////////////////////////// | ||
42 | ✗ | Event::~Event() | |
43 | { | ||
44 | } | ||
45 | |||
46 | // //////////////////////////////////////////////////////////////////////////// | ||
47 | // std::string Event::formatMessage(size_t index) const | ||
48 | // { | ||
49 | // std::string message = this->message; | ||
50 | // | ||
51 | // // Replace occurrances of %m with messages from 'indexmapping' | ||
52 | // size_t i = message.find("%m"); | ||
53 | // if (i != message.npos) { | ||
54 | // IndexMap::const_iterator it = indexMap.find(index); | ||
55 | // | ||
56 | // if (it != indexMap.end()) | ||
57 | // message.replace(i, 2, it->second); | ||
58 | // } | ||
59 | // | ||
60 | // // Replace occurrances of %i with index, possibly offset by 'indexoffset' | ||
61 | // i = message.find("%i"); | ||
62 | // if (i != message.npos) { | ||
63 | // std::ostringstream os; | ||
64 | // os << (int)index + indexOffset; | ||
65 | // message.replace(i, 2, os.str()); | ||
66 | // } | ||
67 | // | ||
68 | // return message; | ||
69 | // } | ||
70 | |||
71 | // //////////////////////////////////////////////////////////////////////////// | ||
72 | // std::string Event::formatMessage(const Config& config, size_t index) const | ||
73 | // { | ||
74 | // std::string message = config["message"].toString(); | ||
75 | // | ||
76 | // // Replace occurrances of %m with messages from 'indexmapping' | ||
77 | // size_t i = message.find("%m"); | ||
78 | // if (i != message.npos) { | ||
79 | // std::ostringstream os; | ||
80 | // os << index; | ||
81 | // std::string mapping = config["indexmapping"][os.str()].toString(); | ||
82 | // | ||
83 | // if (!message.empty()) | ||
84 | // message.replace(i, 2, mapping); | ||
85 | // } | ||
86 | // | ||
87 | // // Replace occurrances of %i with index, possibly offset by 'indexoffset' | ||
88 | // i = message.find("%i"); | ||
89 | // if (i != message.npos) { | ||
90 | // std::ostringstream os; | ||
91 | // os << index + config["indexoffset"].toInt(); | ||
92 | // message.replace(i, 2, os.str()); | ||
93 | // } | ||
94 | // | ||
95 | // return message; | ||
96 | // } | ||
97 |