|
| 1 | +/**************************************************************************/ |
| 2 | +/* print_string.hpp */ |
| 3 | +/**************************************************************************/ |
| 4 | +/* This file is part of: */ |
| 5 | +/* GODOT ENGINE */ |
| 6 | +/* https://godotengine.org */ |
| 7 | +/**************************************************************************/ |
| 8 | +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | +/* */ |
| 11 | +/* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | +/* a copy of this software and associated documentation files (the */ |
| 13 | +/* "Software"), to deal in the Software without restriction, including */ |
| 14 | +/* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | +/* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | +/* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | +/* the following conditions: */ |
| 18 | +/* */ |
| 19 | +/* The above copyright notice and this permission notice shall be */ |
| 20 | +/* included in all copies or substantial portions of the Software. */ |
| 21 | +/* */ |
| 22 | +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | +/**************************************************************************/ |
| 30 | + |
| 31 | +#ifndef GODOT_PRINT_STRING_HPP |
| 32 | +#define GODOT_PRINT_STRING_HPP |
| 33 | + |
| 34 | +#include <godot_cpp/variant/utility_functions.hpp> |
| 35 | + |
| 36 | +namespace godot { |
| 37 | +inline void print_error(const Variant &p_variant) { |
| 38 | + UtilityFunctions::printerr(p_variant); |
| 39 | +} |
| 40 | + |
| 41 | +inline void print_line(const Variant &p_variant) { |
| 42 | + UtilityFunctions::print(p_variant); |
| 43 | +} |
| 44 | + |
| 45 | +inline void print_line_rich(const Variant &p_variant) { |
| 46 | + UtilityFunctions::print_rich(p_variant); |
| 47 | +} |
| 48 | + |
| 49 | +template <typename... Args> |
| 50 | +void print_error(const Variant &p_variant, Args... p_args) { |
| 51 | + UtilityFunctions::printerr(p_variant, p_args...); |
| 52 | +} |
| 53 | + |
| 54 | +template <typename... Args> |
| 55 | +void print_line(const Variant &p_variant, Args... p_args) { |
| 56 | + UtilityFunctions::print(p_variant, p_args...); |
| 57 | +} |
| 58 | + |
| 59 | +template <typename... Args> |
| 60 | +void print_line_rich(const Variant &p_variant, Args... p_args) { |
| 61 | + UtilityFunctions::print_rich(p_variant, p_args...); |
| 62 | +} |
| 63 | + |
| 64 | +bool is_print_verbose_enabled(); |
| 65 | + |
| 66 | +// Checking the condition before evaluating the text to be printed avoids processing unless it actually has to be printed, saving some CPU usage. |
| 67 | +#define print_verbose(m_variant) \ |
| 68 | + { \ |
| 69 | + if (is_print_verbose_enabled()) { \ |
| 70 | + print_line(m_variant); \ |
| 71 | + } \ |
| 72 | + } |
| 73 | +} // namespace godot |
| 74 | + |
| 75 | +#endif // GODOT_PRINT_STRING_HPP |
0 commit comments