1 /*************************************************************************
3 * Copyright 2016 Realm Inc.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 **************************************************************************/
19 #ifndef REALM_UTIL_INSPECT_HPP
20 #define REALM_UTIL_INSPECT_HPP
29 // Because these are templated functions, every combination of output stream
30 // type and value(s) type(s) generates a new function. This makes LCOV/GCOVR
31 // report over 70 functions in this file, with only 6.6% function coverage,
32 // even though line coverage is at 100%.
34 template <class OS, class T>
35 void inspect_value(OS& os, const T& value)
41 void inspect_value(OS& os, const std::string& value)
43 // FIXME: Escape the string.
44 os << "\"" << value << "\"";
48 void inspect_value(OS& os, const char* value)
50 // FIXME: Escape the string.
51 os << "\"" << value << "\"";
60 /// Convert all arguments to strings, and quote string arguments.
61 template <class OS, class First, class... Args>
62 void inspect_all(OS& os, First&& first, Args&&... args)
64 inspect_value(os, std::forward<First>(first));
65 if (sizeof...(Args) != 0) {
68 inspect_all(os, std::forward<Args>(args)...);
76 #endif // REALM_UTIL_INSPECT_HPP