LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/util - result.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 7 100.0 %
Date: 2026-02-09 12:26:33 Functions: 4 4 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * Top contributors (to current version):
       3                 :            :  *   Andrew Reynolds, Morgan Deters, Aina Niemetz
       4                 :            :  *
       5                 :            :  * This file is part of the cvc5 project.
       6                 :            :  *
       7                 :            :  * Copyright (c) 2009-2025 by the authors listed in the file AUTHORS
       8                 :            :  * in the top-level source directory and their institutional affiliations.
       9                 :            :  * All rights reserved.  See the file COPYING in the top-level source
      10                 :            :  * directory for licensing information.
      11                 :            :  * ****************************************************************************
      12                 :            :  *
      13                 :            :  * Encapsulation of the result of a query.
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "cvc5_public.h"
      17                 :            : 
      18                 :            : #ifndef CVC5__UTIL__RESULT_H
      19                 :            : #define CVC5__UTIL__RESULT_H
      20                 :            : 
      21                 :            : #include <cvc5/cvc5_types.h>
      22                 :            : 
      23                 :            : #include <iosfwd>
      24                 :            : #include <string>
      25                 :            : 
      26                 :            : #include "options/language.h"
      27                 :            : 
      28                 :            : namespace cvc5::internal {
      29                 :            : 
      30                 :            : class Result;
      31                 :            : 
      32                 :            : std::ostream& operator<<(std::ostream& out, const Result& r);
      33                 :            : 
      34                 :            : /**
      35                 :            :  * Three-valued SMT result, with optional explanation.
      36                 :            :  */
      37                 :            : class Result
      38                 :            : {
      39                 :            :  public:
      40                 :            :   enum Status
      41                 :            :   {
      42                 :            :     // the status has not been set
      43                 :            :     NONE,
      44                 :            :     // the status is "unsat"
      45                 :            :     UNSAT,
      46                 :            :     // the status is "sat"
      47                 :            :     SAT,
      48                 :            :     // the status is "unknown"
      49                 :            :     UNKNOWN
      50                 :            :   };
      51                 :            : 
      52                 :            :  public:
      53                 :            :   Result();
      54                 :            : 
      55                 :            :   Result(Status s, std::string inputName = "");
      56                 :            : 
      57                 :            :   Result(Status s,
      58                 :            :          enum UnknownExplanation unknownExplanation,
      59                 :            :          std::string inputName = "");
      60                 :            : 
      61                 :            :   Result(const std::string& s, std::string inputName = "");
      62                 :            : 
      63                 :      48587 :   Result(const Result& r, std::string inputName) {
      64                 :      48587 :     *this = r;
      65                 :      48587 :     d_inputName = inputName;
      66                 :      48587 :   }
      67                 :            : 
      68                 :     308967 :   Status getStatus() const { return d_status; }
      69                 :            : 
      70                 :         12 :   bool isNull() const { return d_status == NONE; }
      71                 :      30621 :   bool isUnknown() const { return d_status == UNKNOWN; }
      72                 :            : 
      73                 :            :   UnknownExplanation getUnknownExplanation() const;
      74                 :            : 
      75                 :            :   /**
      76                 :            :    * Operator overloading for equality of two results.
      77                 :            :    * @param r The result to compare to for equality.
      78                 :            :    * @return True if the results are equal.
      79                 :            :    */
      80                 :            :   bool operator==(const Result& r) const;
      81                 :            :   /**
      82                 :            :    * Operator overloading for disequality of two results.
      83                 :            :    * @param r The result to compare to for disequality.
      84                 :            :    * @return True if the results are disequal.
      85                 :            :    */
      86                 :            :   bool operator!=(const Result& r) const;
      87                 :            : 
      88                 :            :   std::string toString() const;
      89                 :            : 
      90                 :            :   std::string getInputName() const { return d_inputName; }
      91                 :            : 
      92                 :            :   /**
      93                 :            :    * This is mostly the same the default
      94                 :            :    * If getType() == Result::TYPE_SAT && getStatus() == Result::UNKNOWN,
      95                 :            :    *
      96                 :            :    */
      97                 :            :   void toStreamSmt2(std::ostream& out) const;
      98                 :            : 
      99                 :            :   /**
     100                 :            :    * Write a Result out to a stream.
     101                 :            :    *
     102                 :            :    * The default implementation writes a reasonable string in lowercase
     103                 :            :    * for sat, unsat, entailed, not entailed, or unknown results.  This behavior
     104                 :            :    * is overridable by each Printer, since sometimes an output language
     105                 :            :    * has a particular preference for how results should appear.
     106                 :            :    */
     107                 :            :   void toStreamDefault(std::ostream& out) const;
     108                 :            : 
     109                 :            :  private:
     110                 :            :   /** The result */
     111                 :            :   Status d_status;
     112                 :            :   /** The unknown explanation */
     113                 :            :   UnknownExplanation d_unknownExplanation;
     114                 :            :   /** The input name */
     115                 :            :   std::string d_inputName;
     116                 :            : }; /* class Result */
     117                 :            : 
     118                 :            : std::ostream& operator<<(std::ostream& out, enum Result::Status s);
     119                 :            : 
     120                 :            : }  // namespace cvc5::internal
     121                 :            : 
     122                 :            : #endif /* CVC5__RESULT_H */

Generated by: LCOV version 1.14