k1a  1.1
Accelerated functionalities for k1lib
utils.cpp
Go to the documentation of this file.
1 #include "utils.h"
2 
3 #ifndef _WIN32
4 #include <cxxabi.h>
5 #endif
6 
7 #include <fstream>
8 #include <iostream>
9 #include <memory>
10 #include <string>
11 
12 namespace k1a {
13 
14 bool debug = false;
15 
16 void log_clear() {
17  std::ofstream f;
18  f.open("/home/kelvin/repos/labs/k1a/logs.txt");
19  f << "";
20  f.close();
21 }
22 
23 PyObject *k1a_log_clear(PyObject *self, PyObject *args) {
24  log_clear();
25  Py_RETURN_NONE;
26 }
27 
34 #ifdef _WIN32
35 std::string demangle(const char *name) {
36  return std::string(name);
37 }
38 #else
39 std::string demangle(const char *name) {
40  int status = -4; // some arbitrary value to eliminate the compiler warning
41 
42  // enable c++11 by passing the flag -std=c++11 to g++
43  std::unique_ptr<char, void (*)(void *)> res{
44  abi::__cxa_demangle(name, NULL, NULL, &status),
45  std::free};
46 
47  return (status == 0) ? res.get() : name;
48 }
49 #endif
50 
51 } // namespace k1a
Definition: funcs.cpp:15
bool debug
Definition: utils.cpp:14
PyObject * k1a_log_clear(PyObject *self, PyObject *args)
Definition: utils.cpp:23
void log_clear()
Definition: utils.cpp:16
std::string demangle(const char *name)
Demangles C++ signatures.
Definition: utils.cpp:39