Welcome to mirror list, hosted at ThFree Co, Russian Federation.

error_stack.cpp « utilities « kdl « itasc « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a8585681266ef2ce397f311c9339caceaa247d00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/** \file itasc/kdl/utilities/error_stack.cpp
 * \ingroup itasc
 */
/*****************************************************************************
 *  	Erwin Aertbelien, Div. PMA, Dep. of Mech. Eng., K.U.Leuven
 *
 * \version 
 *		ORO_Geometry V0.2
 *
 *	\par History
 *		- $log$
 *
 *	\par Release
 *		$Name:  $ 
 ****************************************************************************/


#include "error_stack.h"
#include <stack>
#include <vector>
#include <string>
#include <cstring>

namespace KDL {

// Trace of the call stack of the I/O routines to help user
// interprete error messages from I/O
typedef std::stack<std::string>  ErrorStack;

ErrorStack errorstack;
// should be in Thread Local Storage if this gets multithreaded one day...


void IOTrace(const std::string& description) {
    errorstack.push(description);   
}


void IOTracePop() {
    errorstack.pop();
}

void IOTraceOutput(std::ostream& os) {
    while (!errorstack.empty()) {
        os << errorstack.top().c_str() << std::endl;
        errorstack.pop();
    }
}


void IOTracePopStr(char* buffer,int size) {
    if (errorstack.empty()) {
        *buffer = 0;
        return;
    }
    strncpy(buffer,errorstack.top().c_str(),size);
    errorstack.pop();
}

}