LCOV - code coverage report
Current view: top level - include/outputs/formatters - SyntaxFormatterInterface.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 5 5 100.0 %
Date: 2025-07-17 01:28:37 Functions: 5 6 83.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #pragma once
      11             : 
      12             : #include <string>
      13             : #include <ostream>
      14             : 
      15             : class InputParameters;
      16             : 
      17             : /**
      18             :  * This interface is for classes that want to be called to format InputParameters.  When the
      19             :  * syntax tree is traversed, each of these methods are called at the right points to build up
      20             :  * a formatted string that can meet a number of different needs.
      21             :  */
      22             : class SyntaxFormatterInterface
      23             : {
      24             : public:
      25       63306 :   SyntaxFormatterInterface() {}
      26       63306 :   virtual ~SyntaxFormatterInterface() = default;
      27             : 
      28             :   /**
      29             :    * This method is called once at the beginning of the tree traversal and can be used to build up
      30             :    * header information
      31             :    * @return - The formatted preamble string
      32             :    */
      33       31658 :   virtual std::string preamble() const { return std::string(); }
      34             : 
      35             :   /**
      36             :    * This method is called once at the end of the tree traversal and can be used to add any
      37             :    * necessary trailing information
      38             :    * to the final formatted string.
      39             :    * @return - The formatted postscript string
      40             :    */
      41       31658 :   virtual std::string postscript() const { return std::string(); }
      42             : 
      43             :   /**
      44             :    * This method is called once at each node in the syntax tree before traversing child nodes.
      45             :    * @return - The formatted pre-node traversal string
      46             :    */
      47      810028 :   virtual std::string preTraverse(short /*depth*/) const { return std::string(); }
      48             : 
      49             :   /**
      50             :    * This method is called at the beginning of each Node in the tree.  It is typically used to
      51             :    * provide formatting necessary
      52             :    * when opening new blocks.
      53             :    * @return - The formatted block open string
      54             :    */
      55             :   virtual std::string
      56             :   printBlockOpen(const std::string & name, short depth, const std::string & doc) = 0;
      57             : 
      58             :   /**
      59             :    * This method is called at the end of of each Node in the tree.  It is typically used to provide
      60             :    * formatting necessary
      61             :    * when closing blocks.
      62             :    * @return - The formatted block close string
      63             :    */
      64             :   virtual std::string printBlockClose(const std::string & name, short depth) const = 0;
      65             : 
      66             :   /**
      67             :    * This function is called for each InputParameters object stored at a particular node.  It is
      68             :    * responsible for formatting the parameters
      69             :    * for the current node.
      70             :    * @return - The formatted parameters string for a Node.
      71             :    */
      72             :   virtual std::string printParams(const std::string & prefix,
      73             :                                   const std::string & fully_qualified_name,
      74             :                                   InputParameters & params,
      75             :                                   short depth,
      76             :                                   const std::string & search_string,
      77             :                                   bool & found) = 0;
      78             : };

Generated by: LCOV version 1.14