<commit_before>/* -*- mode: c++; indent-tabs-mode: nil; tab-width: 2 -*-
 *
 *  $Id: Assert.h,v 1.2 2006/10/13 06:53:29 <NAME> Exp $
 *
 *  Copyright 2005-2006 FLWOR Foundation.
 *
 */

// ZORBA_ASSERT (and the deprecated Assert) survive in release mode
// and raise errors via the Zorba error API

#ifndef ZORBA_ASSERT_H
#define ZORBA_ASSERT_H

#include <string>
#include "common/config/config.h"

#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#include <stdlib.h>
#endif

#include "errors/errors.h"
#include "errors/error_manager.h"

namespace zorba {

class StackTracePrinter {
  public:
    StackTracePrinter()
    {
#ifdef HAVE_EXECINFO_H
#define TRACE_SIZE 25
      void *trace[TRACE_SIZE];
      int sz = backtrace(trace, TRACE_SIZE);
      char **syms = backtrace_symbols(trace, sz);
      for(int i = 0; i < sz; ++i) {
        std::cerr << syms[i] << std::endl;
      }
      free(syms);
#undef TRACE_SIZE
#endif
    }
};

#define __ZORBA_ASSERT_aux3( line ) #line
#define __ZORBA_ASSERT_aux2( line ) __ZORBA_ASSERT_aux3( line )
#define __ZORBA_ASSERT_aux1( cond, line )                               \
  do {                                                                  \
    if (! (cond)) {                                                     \
      StackTracePrinter p;                                              \
      ZORBA_ERROR_PARAM(::zorba::ZorbaError::XQP0005_SYSTEM_ASSERT_FAILED, #cond, __FILE__ ":" __ZORBA_ASSERT_aux2 (line)); \
    }                                                                   \
  } while(0)
  
#define ZORBA_ASSERT( cond ) __ZORBA_ASSERT_aux1 (cond, __LINE__)


}	/* namespace zorba */
#endif	/* ZORBA_ASSERT_H */<commit_msg>StackTracePrinter takes on ostream argument<commit_after>/* -*- mode: c++; indent-tabs-mode: nil; tab-width: 2 -*-
 *
 *  $Id: Assert.h,v 1.2 2006/10/13 06:53:29 <NAME> Exp $
 *
 *  Copyright 2005-2006 FLWOR Foundation.
 *
 */

// ZORBA_ASSERT (and the deprecated Assert) survive in release mode
// and raise errors via the Zorba error API

#ifndef ZORBA_ASSERT_H
#define ZORBA_ASSERT_H

#include <string>
#include <iostream>
#include "common/config/config.h"

#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#include <stdlib.h>
#endif

#include "errors/errors.h"
#include "errors/error_manager.h"

namespace zorba {

class StackTracePrinter {
public:
  StackTracePrinter(std::ostream *is)
  {
#ifdef HAVE_EXECINFO_H
#define TRACE_SIZE 25
    void *trace[TRACE_SIZE];
    int sz = backtrace(trace, TRACE_SIZE);
    char **syms = backtrace_symbols(trace, sz);
    for(int i = 0; i < sz; ++i)
      *is << syms[i] << std::endl;
    free(syms);
#undef TRACE_SIZE
#endif
  }
};

#define __ZORBA_ASSERT_aux3( line ) #line
#define __ZORBA_ASSERT_aux2( line ) __ZORBA_ASSERT_aux3( line )
#define __ZORBA_ASSERT_aux1( cond, line )                               \
  do {                                                                  \
    if (! (cond)) {                                                     \
      StackTracePrinter p (&std::cerr);                                 \
      ZORBA_ERROR_PARAM(::zorba::ZorbaError::XQP0005_SYSTEM_ASSERT_FAILED, #cond, __FILE__ ":" __ZORBA_ASSERT_aux2 (line)); \
    }                                                                   \
  } while(0)
  
#define ZORBA_ASSERT( cond ) __ZORBA_ASSERT_aux1 (cond, __LINE__)


}	/* namespace zorba */
#endif	/* ZORBA_ASSERT_H */
{'fraction_non_alphanumeric': 0.1180637544273908, 'fraction_numerical': 0.023022432113341203, 'mean_word_length': 2.080909090909091, 'pattern_counts': {'":': 2, '<': 22, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '761441', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1112, 'n_words': 252}