skip unit tests for handling child errors in pipestream with ancient boost
[libi2ncommon] / src / source_track_basics.hpp
CommitLineData
0e23f538
TJ
1/*
2The software in this package is distributed under the GNU General
3Public License version 2 (with a special exception described below).
4
5A copy of GNU General Public License (GPL) is included in this distribution,
6in the file COPYING.GPL.
7
8As a special exception, if other files instantiate templates or use macros
9or inline functions from this file, or you compile this file and link it
10with other works to produce a work based on this file, this file
11does not by itself cause the resulting work to be covered
12by the GNU General Public License.
13
14However the source code for this file must still be made available
15in accordance with section (3) of the GNU General Public License.
16
17This exception does not invalidate any other reasons why a work based
18on this file might be covered by the GNU General Public License.
19*/
b6fb82a2
RP
20/** @file
21 *
22 * @copyright © Copyright 2007-2008 by Intra2net AG
b6fb82a2
RP
23 */
24
25#ifndef __I2N_COMMON_SOURCE_TRACK_BASICS_HPP__
26#define __I2N_COMMON_SOURCE_TRACK_BASICS_HPP__
27
28#include <string>
29#include <boost/current_function.hpp>
30
31/*
32** some helper macros
33*/
34
35/**
36 * macro which encapsulates the construction of a source location.
37 */
38#define HERE ::I2n::SourceLocation(__FILE__,__LINE__,BOOST_CURRENT_FUNCTION)
39
40
41namespace I2n
42{
43
44
45/**
46 * (helper) struct for providing a source location.
47 * Construction should be done with appropriate macros (like @a HERE)
48 */
49struct SourceLocation
50{
51 std::string File;
52 long Line;
53 std::string FunctionName;
54
55 SourceLocation();
56
57 SourceLocation(
58 const std::string& file,
59 long line,
60 const std::string& funcname);
61
62 operator bool() const
63 {
64 return Line>0 and not File.empty() and not FunctionName.empty();
65 } // eo operator bool
66
67 std::string get_function_name() const { return FunctionName; }
68 std::string get_filename() const { return File; }
69 long get_line_number() const { return Line; }
70
71 std::string get_location_tag() const;
72
73 private:
74
75 mutable std::string LocationTag;
76
77}; // eo struct SourceLocation
78
79
80
81
82} // eo namepsace I2n
83
84#endif