orocos_kdl
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
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 }
KDL::errorstack
static ErrorStack errorstack
Definition: error_stack.cxx:43
std::string
cstring
vector
stack
KDL
Definition: kukaLWR_DHnew.cpp:25
std::ostream
KDL::IOTrace
void IOTrace(const std::string &description)
Definition: error_stack.cxx:46
std::stack::pop
T pop(T... args)
std::stack::top
T top(T... args)
KDL::IOTracePopStr
void IOTracePopStr(char *buffer, int size)
Definition: error_stack.cxx:63
std::endl
T endl(T... args)
KDL::IOTracePop
void IOTracePop()
pops a description of the IO-stack
Definition: error_stack.cxx:51
error_stack.h
std::stack::empty
T empty(T... args)
std::stack::push
T push(T... args)
KDL::ErrorStack
std::stack< std::string > ErrorStack
Definition: error_stack.cxx:40
KDL::IOTraceOutput
void IOTraceOutput(std::ostream &os)
outputs the IO-stack to a stream to provide a better errormessage.
Definition: error_stack.cxx:55
string