diff --git a/capture/CaptureTree.cpp b/capture/CaptureTree.cpp new file mode 100644 index 00000000..54d681a1 --- /dev/null +++ b/capture/CaptureTree.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include + +#include +#include + +namespace facebook::yoga { + +void captureTree(YGNodeRef node, const std::filesystem::path& path) { + std::string str; + nodeToString(str, node, YGPrintOptionsStyle | YGPrintOptionsChildren); + std::ofstream file(path); + file << str; +} + +} // namespace facebook::yoga diff --git a/capture/CaptureTree.h b/capture/CaptureTree.h new file mode 100644 index 00000000..5d809859 --- /dev/null +++ b/capture/CaptureTree.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include + +#include + +namespace facebook::yoga { + +void captureTree(YGNodeRef node, const std::filesystem::path& path); + +} // namespace facebook::yoga