error_stack.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * \author
3  * Erwin Aertbelien, Div. PMA, Dep. of Mech. Eng., K.U.Leuven
4  *
5  * \version
6  * ORO_Geometry V0.2
7  *
8  * \par History
9  * - $log$
10  *
11  * \par Release
12  * $Id: error_stack.cpp,v 1.1.1.1.2.1 2003/02/24 13:13:06 psoetens Exp $
13  * $Name: $
14  ****************************************************************************/
15 
16 
17 #include "error_stack.h"
18 #include <stack>
19 #include <vector>
20 #include <string>
21 #include <cstring>
22 
23 namespace KDL {
24 
25 // Trace of the call stack of the I/O routines to help user
26 // interpret error messages from I/O
27 typedef std::stack<std::string> ErrorStack;
28 
29 // should be in Thread Local Storage if this gets multithreaded one day...
30 static ErrorStack errorstack;
31 
32 
33 void IOTrace(const std::string& description) {
34  errorstack.push(description);
35 }
36 
37 
38 void IOTracePop() {
39  errorstack.pop();
40 }
41 
42 void IOTraceOutput(std::ostream& os) {
43  while (!errorstack.empty()) {
44  os << errorstack.top().c_str() << std::endl;
45  errorstack.pop();
46  }
47 }
48 
49 
50 void IOTracePopStr(char* buffer,int size) {
51  if (size <= 0)
52  {
53  // TODO: all sizes everywhere should be of size_t!
54  return;
55  }
56  if (errorstack.empty()) {
57  *buffer = 0;
58  return;
59  }
60 #if defined(_WIN32)
61  strncpy_s(buffer,size,errorstack.top().c_str(),size);
62 #else
63  strncpy(buffer,errorstack.top().c_str(),size);
64 #endif
65  buffer[size - 1] = '\0';
66  errorstack.pop();
67 }
68 
69 }
void IOTracePop()
pops a description of the IO-stack
Definition: error_stack.cxx:38
void IOTraceOutput(std::ostream &os)
outputs the IO-stack to a stream to provide a better errormessage.
Definition: error_stack.cxx:42
void IOTracePopStr(char *buffer, int size)
Definition: error_stack.cxx:50
std::stack< std::string > ErrorStack
Definition: error_stack.cxx:27
static ErrorStack errorstack
Definition: error_stack.cxx:30
void IOTrace(const std::string &description)
Definition: error_stack.cxx:33


orocos_kdl
Author(s):
autogenerated on Thu Apr 13 2023 02:19:14