2018-03-09 01:50:17 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-03-09 01:50:17 +00:00
|
|
|
*
|
|
|
|
* 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 <string>
|
2018-06-29 19:09:59 +00:00
|
|
|
#include <memory>
|
2018-03-09 01:50:17 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
|
|
|
class DebugStringConvertible;
|
|
|
|
|
|
|
|
using SharedDebugStringConvertible = std::shared_ptr<const DebugStringConvertible>;
|
2018-06-29 19:09:59 +00:00
|
|
|
using SharedDebugStringConvertibleList = std::vector<SharedDebugStringConvertible>;
|
2018-03-09 01:50:17 +00:00
|
|
|
|
2018-03-19 02:04:32 +00:00
|
|
|
struct DebugStringConvertibleOptions {
|
|
|
|
bool format {true};
|
|
|
|
int maximumDepth {INT_MAX};
|
|
|
|
};
|
|
|
|
|
2018-03-09 01:50:17 +00:00
|
|
|
// Abstract class describes conformance to DebugStringConvertible concept
|
|
|
|
// and implements basic recursive debug string assembly algorithm.
|
|
|
|
// Use this as a base class for providing a debugging textual representation
|
|
|
|
// of your class.
|
|
|
|
// TODO (#26770211): Clear up the naming.
|
|
|
|
class DebugStringConvertible {
|
|
|
|
|
|
|
|
public:
|
2018-03-19 21:23:24 +00:00
|
|
|
virtual ~DebugStringConvertible() = default;
|
|
|
|
|
2018-03-09 01:50:17 +00:00
|
|
|
// Returns a name of the object.
|
|
|
|
// Default implementation returns "Node".
|
|
|
|
virtual std::string getDebugName() const;
|
|
|
|
|
|
|
|
// Returns a value assosiate with the object.
|
|
|
|
// Default implementation returns an empty string.
|
|
|
|
virtual std::string getDebugValue() const;
|
|
|
|
|
|
|
|
// Returns a list of `DebugStringConvertible` objects which can be considered
|
|
|
|
// as *children* of the object.
|
|
|
|
// Default implementation returns an empty list.
|
|
|
|
virtual SharedDebugStringConvertibleList getDebugChildren() const;
|
|
|
|
|
|
|
|
// Returns a list of `DebugStringConvertible` objects which can be considered
|
|
|
|
// as *properties* of the object.
|
|
|
|
// Default implementation returns an empty list.
|
|
|
|
virtual SharedDebugStringConvertibleList getDebugProps() const;
|
|
|
|
|
|
|
|
// Returns a string which represents the object in a human-readable way.
|
|
|
|
// Default implementation returns a description of the subtree
|
|
|
|
// rooted at this node, represented in XML-like format.
|
2018-03-19 02:04:32 +00:00
|
|
|
virtual std::string getDebugDescription(DebugStringConvertibleOptions options = {}, int depth = 0) const;
|
2018-03-09 01:50:17 +00:00
|
|
|
|
|
|
|
// Do same as `getDebugDescription` but return only *children* and
|
|
|
|
// *properties* parts (which are used in `getDebugDescription`).
|
2018-03-19 02:04:32 +00:00
|
|
|
virtual std::string getDebugPropsDescription(DebugStringConvertibleOptions options = {}, int depth = 0) const;
|
|
|
|
virtual std::string getDebugChildrenDescription(DebugStringConvertibleOptions options = {}, int depth = 0) const;
|
2018-03-09 01:50:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|