]> git.mxchange.org Git - simgear.git/blobdiff - simgear/structure/exception.cxx
Command-manager supports functors.
[simgear.git] / simgear / structure / exception.cxx
index c46a1c9636c25aac25b40dfca32469cf27385fd7..082d12e4ef782558b15c4e7c76f602f36b5f17a0 100644 (file)
@@ -6,10 +6,13 @@
 
 
 #include "exception.hxx"
+
 #include <stdio.h>
 #include <cstring>
 #include <sstream>
 
+#include <simgear/misc/sg_path.hxx>
+
 using std::string;
 \f
 ////////////////////////////////////////////////////////////////////////
@@ -24,7 +27,7 @@ sg_location::sg_location ()
     _path[0] = '\0';
 }
 
-sg_location::sg_location (const string& path, int line, int column)
+sg_location::sg_location (const std::string& path, int line, int column)
   : _line(line),
     _column(column),
     _byte(-1)
@@ -54,8 +57,8 @@ void
 sg_location::setPath (const char* path)
 {
   if (path) {
-    strncpy(_path, path, MAX_PATH);
-    _path[MAX_PATH -1] = '\0';
+    strncpy(_path, path, max_path);
+    _path[max_path -1] = '\0';
   } else {
     _path[0] = '\0';
   }
@@ -97,7 +100,7 @@ sg_location::setByte (int byte)
   _byte = byte;
 }
 
-string
+std::string
 sg_location::asString () const
 {
   std::ostringstream out;
@@ -260,6 +263,20 @@ sg_io_exception::sg_io_exception (const string& message, const string& origin)
 {
 }
 
+sg_io_exception::sg_io_exception (const string& message,
+                                 const sg_location &location,
+                                 const string& origin)
+  : sg_exception(message, origin),
+    _location(location)
+{
+}
+
+sg_io_exception::sg_io_exception (const string &message, const SGPath& origin)
+    : sg_exception(message, origin.str())
+{
+    
+}
+
 sg_io_exception::~sg_io_exception () throw ()
 {
 }
@@ -331,7 +348,7 @@ sg_format_exception::setText (const char* text)
 {
   if (text) {
     strncpy(_text, text, MAX_TEXT_LEN);
-    _text[MAX_TEXT_LEN] = '\0';
+    _text[MAX_TEXT_LEN-1] = '\0';
   } else {
     _text[0] = '\0';
   }