<commit_before>//--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// version: $Id$
// author:  <NAME> <<EMAIL>>
//------------------------------------------------------------------------------

#ifndef CLING_VALUEPRINTER_H
#define CLING_VALUEPRINTER_H

#include "cling/Interpreter/ValuePrinterInfo.h"
#include <string>

namespace llvm {
  class raw_ostream;
}

namespace cling {
  class StoredValueRef;

  // Can be re-implemented to print type-specific details, e.g. as
  //   template <typename POSSIBLYDERIVED>
  //   std::string printValue(const MyClass* const p, POSSIBLYDERIVED* ac,
  //                          const ValuePrinterInfo& VPI);
  template <typename TY>
  std::string printValue(const void* const p, TY* const u,
                         const ValuePrinterInfo& VPI);

  // Can be re-implemented to print a user type differently, e.g. as
  //   template <typename POSSIBLYDERIVED>
  //   std::string printType(const MyClass* const p, POSSIBLYDERIVED* ac,
  //                         const ValuePrinterInfo& VPI);
  template <typename TY>
  std::string printType(const void* const p, TY* const u,
                        const ValuePrinterInfo& VPI);

  namespace valuePrinterInternal {

    std::string printValue_Default(const void* const p,
                                   const ValuePrinterInfo& PVI);
    std::string printType_Default(const ValuePrinterInfo& PVI);

    void StreamStoredValueRef(llvm::raw_ostream& o, const StoredValueRef* VR,
                              clang::ASTContext& C);

    void flushToStream(llvm::raw_ostream& o, const std::string& s);

    template <typename T>
    const T& Select(llvm::raw_ostream* o, clang::Expr* E,
                    clang::ASTContext* C, const T& value) {
      ValuePrinterInfo VPI(E, C);
      // Only because we don't want to include llvm::raw_ostream in the header
      flushToStream(*o, printType(&value, &value, VPI)
                    + printValue(&value, &value, VPI) + '\n');
      return value;
    }

    template <typename T>
    const T* Select(llvm::raw_ostream* o, clang::Expr* E,
                    clang::ASTContext* C, const T* value) {
      ValuePrinterInfo VPI(E, C);
      // Only because we don't want to include llvm::raw_ostream in the header
      flushToStream(*o, printType((const void*) value, value, VPI)
                    + printValue((const void*) value, value, VPI) + '\n');
      return value;
    }

    template <typename T>
    const T* Select(llvm::raw_ostream* o, clang::Expr* E,
                    clang::ASTContext* C, T* value) {
      ValuePrinterInfo VPI(E, C);
      // Only because we don't want to include llvm::raw_ostream in the header
      flushToStream(*o, printType((const void*) value, value, VPI)
                    + printValue((const void*) value, value, VPI) + '\n');
      return value;
    }

  } // namespace valuePrinterInternal

  template <typename TY>
  std::string  printValue(const void* const p, TY* const /*u*/,
                          const ValuePrinterInfo& PVI) {
    return valuePrinterInternal::printValue_Default(p, PVI);
  }
  template <typename TY>
  std::string  printType(const void* const p, TY* const /*u*/,
                         const ValuePrinterInfo& PVI) {
    return valuePrinterInternal::printType_Default(PVI);
  }
<commit_msg>Add documentation.<commit_after>//--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// version: $Id$
// author:  <NAME> <<EMAIL>>
//------------------------------------------------------------------------------

#ifndef CLING_VALUEPRINTER_H
#define CLING_VALUEPRINTER_H

#include "cling/Interpreter/ValuePrinterInfo.h"
#include <string>

namespace llvm {
  class raw_ostream;
}

namespace cling {
  class StoredValueRef;

  ///\brief Generic interface to value printing.
  ///
  /// Can be re-implemented to print type-specific details, e.g. as
  ///\code
  ///   template <typename POSSIBLYDERIVED>
  ///   std::string printValue(const MyClass* const p, POSSIBLYDERIVED* ac,
  ///                          const ValuePrinterInfo& VPI);
  ///\endcode
  template <typename TY>
  std::string printValue(const void* const p, TY* const u,
                         const ValuePrinterInfo& VPI);

  ///\brief Generic interface to type printing.
  ///
  /// Can be re-implemented to print a user type differently, e.g. as
  ///\code
  ///   template <typename POSSIBLYDERIVED>
  ///   std::string printType(const MyClass* const p, POSSIBLYDERIVED* ac,
  ///                         const ValuePrinterInfo& VPI);
  ///\endcode
  template <typename TY>
  std::string printType(const void* const p, TY* const u,
                        const ValuePrinterInfo& VPI);

  namespace valuePrinterInternal {

    std::string printValue_Default(const void* const p,
                                   const ValuePrinterInfo& PVI);
    std::string printType_Default(const ValuePrinterInfo& PVI);

    void StreamStoredValueRef(llvm::raw_ostream& o, const StoredValueRef* VR,
                              clang::ASTContext& C);

    void flushToStream(llvm::raw_ostream& o, const std::string& s);

    template <typename T>
    const T& Select(llvm::raw_ostream* o, clang::Expr* E,
                    clang::ASTContext* C, const T& value) {
      ValuePrinterInfo VPI(E, C);
      // Only because we don't want to include llvm::raw_ostream in the header
      flushToStream(*o, printType(&value, &value, VPI)
                    + printValue(&value, &value, VPI) + '\n');
      return value;
    }

    template <typename T>
    const T* Select(llvm::raw_ostream* o, clang::Expr* E,
                    clang::ASTContext* C, const T* value) {
      ValuePrinterInfo VPI(E, C);
      // Only because we don't want to include llvm::raw_ostream in the header
      flushToStream(*o, printType((const void*) value, value, VPI)
                    + printValue((const void*) value, value, VPI) + '\n');
      return value;
    }

    template <typename T>
    const T* Select(llvm::raw_ostream* o, clang::Expr* E,
                    clang::ASTContext* C, T* value) {
      ValuePrinterInfo VPI(E, C);
      // Only because we don't want to include llvm::raw_ostream in the header
      flushToStream(*o, printType((const void*) value, value, VPI)
                    + printValue((const void*) value, value, VPI) + '\n');
      return value;
    }

  } // namespace valuePrinterInternal

  ///\brief Catch-all implementation for value printing.
  template <typename TY>
  std::string printValue(const void* const p, TY* const /*u*/,
                         const ValuePrinterInfo& PVI) {
    return valuePrinterInternal::printValue_Default(p, PVI);
  }
  ///\brief Catch-all implementation for type printing.
  template <typename TY>
  std::string printType(const void* const p, TY* const /*u*/,
                        const ValuePrinterInfo& PVI) {
    return valuePrinterInternal::printType_Default(PVI);
  }

{'fraction_non_alphanumeric': 0.1538352474124486, 'fraction_numerical': 0.0, 'mean_word_length': 2.164647824136384, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6984835', 'n_tokens_mistral': 2092, 'n_tokens_neox': 2038, 'n_words': 601}