Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d720bbe5e6dfcbf4d7f82dbfaf1ec9162a0976c8 (plain) (blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*******************************************************************************
 * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * CONTRIBUTORS:
 * 		Peter Karlitschek (initial contribution)
 *
 *******************************************************************************/

#include "MSCFilter.h"

namespace etRuntime {

MSCFilter::MSCFilter() :
		filterList() {
}
MSCFilter::~MSCFilter() {
}

void MSCFilter::addFilter(FilterItem filter) {
	filterList.push_back(filter);
}

bool MSCFilter::applyTo(const std::string& text) {
	if (filterList.empty())
		return true; // no filters -> all messages will be logged
	std::list<FilterItem>::iterator it = filterList.begin();
	for ( ; it != filterList.end(); ++it) {
		if (text.compare((*it).filter) == 0)
			return !(*it).exclude;
	}
	return false;
}

std::string MSCFilter::reduceString(const std::string& string) {
	if (filterList.size() == 1)
		//TODO: filtering with regular expression
		// return string.replaceFirst(filterList.front().filter, "");
		return string;
	else
		return string;
}

} /* namespace etRuntime */

Back to the top