OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_BASE_LOCATION_H_ | |
12 #define WEBRTC_BASE_LOCATION_H_ | |
13 | |
14 #include <string> | |
15 | |
16 namespace rtc { | |
17 | |
18 // Location provides basic info where of an object was constructed, or was | |
19 // significantly brought to life. | |
20 // This is a stripped down version of: | |
21 // https://code.google.com/p/chromium/codesearch#chromium/src/base/location.h | |
22 class Location { | |
23 public: | |
24 // Constructor should be called with a long-lived char*, such as __FILE__. | |
25 // It assumes the provided value will persist as a global constant, and it | |
26 // will not make a copy of it. | |
27 Location(const char* function_name, const char* file_name, int line_number); | |
28 Location(); | |
29 Location(const Location& other); | |
30 Location& operator=(const Location& other); | |
31 | |
32 const char* function_name() const { return function_name_; } | |
33 const char* file_name() const { return file_name_; } | |
34 int line_number() const { return line_number_; } | |
35 | |
36 std::string ToString() const; | |
37 | |
38 private: | |
39 const char* function_name_; | |
40 const char* file_name_; | |
41 int line_number_; | |
42 }; | |
43 | |
44 // Define a macro to record the current source location. | |
45 #define FROM_HERE FROM_HERE_WITH_EXPLICIT_FUNCTION(__FUNCTION__) | |
tommi
2016/05/31 19:56:27
Sorry I didn't think of this before, but I think w
Taylor Brandstetter
2016/06/02 22:38:41
Definitely agree; done.
| |
46 | |
47 #define FROM_HERE_WITH_EXPLICIT_FUNCTION(function_name) \ | |
tommi
2016/05/31 19:56:27
and this one as well I guess. You could also shor
Taylor Brandstetter
2016/06/02 22:38:41
Done.
| |
48 ::rtc::Location(function_name, __FILE__, __LINE__) | |
49 | |
50 } // namespace rtc | |
51 | |
52 #endif // WEBRTC_BASE_LOCATION_H_ | |
OLD | NEW |