Commit for release to 1.5.29.
[asdcplib.git] / src / KM_error.h
index a91d416ac7065cf12e332b18f70bbda2329f9a42..8c2f5fceb611e0584cdd99feb7df73be7de0f951 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2004-2006, John Hurst
+Copyright (c) 2004-2009, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -43,14 +43,15 @@ namespace Kumu
 
   class Result_t
     {
-      long value;
+      int value;
       const char* label;
       Result_t();
 
     public:
-      static const Result_t& Find(long);
+      static const Result_t& Find(int);
+      static Result_t Delete(int);
 
-      Result_t(long v, const char* l);
+      Result_t(int v, const char* l);
       ~Result_t();
 
       inline bool        operator==(const Result_t& rhs) const { return value == rhs.value; }
@@ -58,8 +59,8 @@ namespace Kumu
       inline bool        Success() const { return ( value >= 0 ); }
       inline bool        Failure() const { return ( value < 0 ); }
 
-      inline long        Value() const { return value; }
-      inline operator    long() const { return value; }
+      inline int         Value() const { return value; }
+      inline operator    int() const { return value; }
 
       inline const char* Label() const { return label; }
       inline operator    const char*() const { return label; }
@@ -86,6 +87,10 @@ namespace Kumu
   const Result_t RESULT_ENDOFFILE  (-17,  "Attempt to read past end of file.");
   const Result_t RESULT_FILEEXISTS (-18,  "Filename already exists.");
   const Result_t RESULT_NOTAFILE   (-19,  "Filename not found.");
+  const Result_t RESULT_UNKNOWN    (-20,  "Unknown result code.");
+  const Result_t RESULT_DIR_CREATE (-21,  "Unable to create directory.");
+  // -22 is reserved
 } // namespace Kumu
 
 //--------------------------------------------------------------------------------
@@ -114,6 +119,35 @@ namespace Kumu
     return Kumu::RESULT_NULL_STR; \
   }
 
+namespace Kumu
+{
+  // simple tracing mechanism
+  class DTrace_t
+  {
+    DTrace_t();
+    
+  protected:
+    const char* m_Label;
+    Result_t*   m_Watch;
+    int         m_Line;
+    const char* m_File;
+    int         m_Sequence;
+
+  public:
+    DTrace_t(const char* Label, Result_t* Watch, int Line, const char* File);
+    ~DTrace_t();
+  };
+}
+
+#ifdef KM_TRACE
+#define WDTRACE(l) DTrace_t __wl__Trace__((l), 0, __LINE__, __FILE__)
+#define WDTRACER(l,r) DTrace_t __wl__Trace__((l), &(r), __LINE__, __FILE__)
+#else
+#define WDTRACE(l)
+#define WDTRACER(l,r)
+#endif
+
+
 #endif // _KM_ERROR_H_
 
 //