1//
2// Formatter.h
3//
4// Library: Foundation
5// Package: Logging
6// Module: Formatter
7//
8// Definition of the Formatter class.
9//
10// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef Foundation_Formatter_INCLUDED
18#define Foundation_Formatter_INCLUDED
19
20
21#include "Poco/Foundation.h"
22#include "Poco/Configurable.h"
23#include "Poco/RefCountedObject.h"
24
25
26namespace Poco {
27
28
29class Message;
30
31
32class Foundation_API Formatter: public Configurable, public RefCountedObject
33 /// The base class for all Formatter classes.
34 ///
35 /// A formatter basically takes a Message object
36 /// and formats it into a string. How the formatting
37 /// is exactly done is up to the implementation of
38 /// Formatter. For example, a very simple implementation
39 /// might simply take the message's Text (see Message::getText()).
40 /// A useful implementation should at least take the Message's
41 /// Time, Priority and Text fields and put them into a string.
42 ///
43 /// The Formatter class supports the Configurable
44 /// interface, so the behaviour of certain formatters
45 /// is configurable.
46 ///
47 /// Trivial implementations of of getProperty() and
48 /// setProperty() are provided.
49 ///
50 /// Subclasses must at least provide a format() method.
51{
52public:
53 Formatter();
54 /// Creates the formatter.
55
56 virtual ~Formatter();
57 /// Destroys the formatter.
58
59 virtual void format(const Message& msg, std::string& text) = 0;
60 /// Formats the message and places the result in text.
61 /// Subclasses must override this method.
62
63 void setProperty(const std::string& name, const std::string& value);
64 /// Throws a PropertyNotSupportedException.
65
66 std::string getProperty(const std::string& name) const;
67 /// Throws a PropertyNotSupportedException.
68};
69
70
71} // namespace Poco
72
73
74#endif // Foundation_Formatter_INCLUDED
75