Changeset 1016
- Timestamp:
- Jun 8, 2008, 4:48:01 PM (16 years ago)
- Location:
- trunk/src2/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src2/core/Outcome.cpp
r592 r1016 12 12 #include "Outcome.h" 13 13 14 #include <stdarg.h> 15 14 16 using namespace Rappture; 15 17 … … 17 19 * Create a negative outcome, with the given error message. 18 20 */ 19 Outcome::Outcome(const char *errmsg) 20 :_status(0),21 Outcome::Outcome(const char *errmsg) : 22 _status(0), 21 23 _remarkPtr(NULL), 22 24 _contextPtr(NULL) … … 28 30 29 31 /// Copy constructor 30 Outcome::Outcome(const Outcome& oc) 31 :_status(oc._status),32 Outcome::Outcome(const Outcome& oc) : 33 _status(oc._status), 32 34 _remarkPtr(oc._remarkPtr), 33 35 _contextPtr(oc._contextPtr) … … 58 60 _remarkPtr = Ptr<std::string>(new std::string(errmsg)); 59 61 _contextPtr.clear(); 62 return *this; 63 } 64 65 Outcome& 66 Outcome::AddError(const char* format, ...) 67 { 68 char stackSpace[1024]; 69 va_list lst; 70 size_t n; 71 char *bufPtr; 72 73 va_start(lst, format); 74 bufPtr = stackSpace; 75 n = vsnprintf(bufPtr, 1024, format, lst); 76 if (n >= 1024) { 77 bufPtr = (char *)malloc(n); 78 vsnprintf(bufPtr, n, format, lst); 79 } 80 if (_remarkPtr.isNull()) { 81 _remarkPtr = Ptr<std::string>(new std::string(bufPtr)); 82 } else { 83 _remarkPtr->append("\n"); 84 _remarkPtr->append(bufPtr); 85 } 86 _contextPtr.clear(); 87 _status = 1; /* Set to error */ 88 if (bufPtr != stackSpace) { 89 free(bufPtr); 90 } 60 91 return *this; 61 92 } -
trunk/src2/core/Outcome.h
r592 r1016 30 30 virtual ~Outcome(); 31 31 32 Outcome& AddError(const char* format, ...); 32 33 virtual Outcome& error(const char* errmsg, int status=1); 33 34 virtual Outcome& clear();
Note: See TracChangeset
for help on using the changeset viewer.