| 
									
										
										
										
											2023-08-19 13:56:36 +02:00
										 |  |  | // Copyright 2020 Arthur Sonzogni. All rights reserved.
 | 
					
						
							|  |  |  | // Use of this source code is governed by the MIT license that can be found in
 | 
					
						
							|  |  |  | // the LICENSE file.
 | 
					
						
							| 
									
										
										
										
											2022-03-31 02:17:43 +02:00
										 |  |  | #ifndef FTXUI_DOM_TAKE_ANY_ARGS_HPP
 | 
					
						
							|  |  |  | #define FTXUI_DOM_TAKE_ANY_ARGS_HPP
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-01 20:40:35 +02:00
										 |  |  | // IWYU pragma: private, include "ftxui/dom/elements.hpp"
 | 
					
						
							| 
									
										
										
										
											2024-05-01 11:40:49 +02:00
										 |  |  | #include <ftxui/dom/node.hpp>
 | 
					
						
							| 
									
										
										
										
											2019-01-06 16:14:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-10 14:23:46 +02:00
										 |  |  | namespace ftxui { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-23 02:16:00 +01:00
										 |  |  | template <class T> | 
					
						
							| 
									
										
										
										
											2022-03-31 02:17:43 +02:00
										 |  |  | void Merge(Elements& /*container*/, T /*element*/) {} | 
					
						
							| 
									
										
										
										
											2019-01-23 02:16:00 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | template <> | 
					
						
							|  |  |  | inline void Merge(Elements& container, Element element) { | 
					
						
							|  |  |  |   container.push_back(std::move(element)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template <> | 
					
						
							|  |  |  | inline void Merge(Elements& container, Elements elements) { | 
					
						
							| 
									
										
										
										
											2024-05-01 11:40:49 +02:00
										 |  |  |   for (auto& element : elements) { | 
					
						
							| 
									
										
										
										
											2019-01-23 02:16:00 +01:00
										 |  |  |     container.push_back(std::move(element)); | 
					
						
							| 
									
										
										
										
											2024-05-01 11:40:49 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-01-23 02:16:00 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-06 16:14:19 +01:00
										 |  |  | // Turn a set of arguments into a vector.
 | 
					
						
							|  |  |  | template <class... Args> | 
					
						
							| 
									
										
										
										
											2019-01-12 18:24:46 +01:00
										 |  |  | Elements unpack(Args... args) { | 
					
						
							| 
									
										
										
										
											2019-01-23 02:16:00 +01:00
										 |  |  |   std::vector<Element> vec; | 
					
						
							|  |  |  |   (Merge(vec, std::move(args)), ...); | 
					
						
							| 
									
										
										
										
											2019-01-06 16:14:19 +01:00
										 |  |  |   return vec; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Make |container| able to take any number of argments.
 | 
					
						
							| 
									
										
										
										
											2020-03-23 21:26:00 +01:00
										 |  |  | #define TAKE_ANY_ARGS(container)                               \
 | 
					
						
							|  |  |  |   template <class... Args>                                     \ | 
					
						
							|  |  |  |   Element container(Args... children) {                        \ | 
					
						
							|  |  |  |     return container(unpack(std::forward<Args>(children)...)); \ | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-08-16 00:24:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-10 14:23:46 +02:00
										 |  |  | TAKE_ANY_ARGS(vbox) | 
					
						
							|  |  |  | TAKE_ANY_ARGS(hbox) | 
					
						
							|  |  |  | TAKE_ANY_ARGS(dbox) | 
					
						
							|  |  |  | TAKE_ANY_ARGS(hflow) | 
					
						
							|  |  |  | }  // namespace ftxui
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-31 02:17:43 +02:00
										 |  |  | #endif  // FTXUI_DOM_TAKE_ANY_ARGS_HPP
 |