aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-01 17:38:33 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-01 17:38:33 +0100
commit5376efe7e63ef3c848a971ea845a16c7e030d153 (patch)
tree14681fae031222cd2b4bfc6686ae5b8e876f7fc0
parentb20f46c15dce8b196dbb8890890978947745e094 (diff)
move Exception to backend
-rw-r--r--backend/CMakeLists.txt1
-rw-r--r--backend/Exception.cpp (renamed from frontend/Exception.cpp)4
-rw-r--r--backend/Exception.h (renamed from frontend/Exception.h)7
-rw-r--r--frontend/CMakeLists.txt1
-rw-r--r--frontend/DB.cpp3
-rw-r--r--frontend/GameController.cpp2
-rw-r--r--frontend/cmd/equip.cpp2
-rw-r--r--frontend/cmd/get.cpp2
-rw-r--r--frontend/cmd/go.cpp2
-rw-r--r--frontend/cmd/hit.cpp2
-rw-r--r--frontend/cmd/put.cpp2
-rw-r--r--frontend/cmd/view.cpp2
-rw-r--r--frontend/generate_dungeon.cpp2
-rw-r--r--frontend/load_dungeon.cpp2
-rw-r--r--frontend/main.cpp2
15 files changed, 18 insertions, 18 deletions
diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt
index e0c377b..b7e8996 100644
--- a/backend/CMakeLists.txt
+++ b/backend/CMakeLists.txt
@@ -15,5 +15,6 @@ target_sources(main PUBLIC
String.cpp
print.cpp
Player.cpp
+ Exception.cpp
)
diff --git a/frontend/Exception.cpp b/backend/Exception.cpp
index c852f0a..4044d6a 100644
--- a/frontend/Exception.cpp
+++ b/backend/Exception.cpp
@@ -10,13 +10,13 @@
using namespace std;
const char * Exception::what() {
- return this->error.get();
+ return this->error.c_str();
}
Exception::Exception(const char * fmt, ...) {
va_list args;
va_start(args, fmt);
- this->error = unique_ptr<char>(strdup(String::va_fmt(args, fmt).c_str()));
+ this->error = String::va_fmt(args, fmt);
va_end(args);
}
diff --git a/frontend/Exception.h b/backend/Exception.h
index 3bbced2..bc65aa0 100644
--- a/frontend/Exception.h
+++ b/backend/Exception.h
@@ -1,15 +1,14 @@
#pragma once
-#include <exception>
-#include <memory>
+#include "backend/String.h"
-class Exception : public std::exception {
+class Exception {
public:
Exception(const char * fmt, ...);
const char * what();
protected:
Exception() = default;
- std::unique_ptr<char> error;
+ String error;
};
diff --git a/frontend/CMakeLists.txt b/frontend/CMakeLists.txt
index 4248eb5..8f086d3 100644
--- a/frontend/CMakeLists.txt
+++ b/frontend/CMakeLists.txt
@@ -5,7 +5,6 @@ target_sources(main PUBLIC
GameController.cpp
load_dungeon.cpp
generate_dungeon.cpp
- Exception.cpp
DB.cpp
GameData.cpp
)
diff --git a/frontend/DB.cpp b/frontend/DB.cpp
index d51315b..f40a9fd 100644
--- a/frontend/DB.cpp
+++ b/frontend/DB.cpp
@@ -1,5 +1,6 @@
+#include "backend/Exception.h"
+
#include "DB.h"
-#include "Exception.h"
using namespace std;
diff --git a/frontend/GameController.cpp b/frontend/GameController.cpp
index bbdd0c1..f160006 100644
--- a/frontend/GameController.cpp
+++ b/frontend/GameController.cpp
@@ -4,8 +4,8 @@
#include "GameData.h"
#include "strings.h"
#include "GameController.h"
-#include "Exception.h"
+#include "backend/Exception.h"
#include "backend/print.h"
#include "backend/WeaponObject.h"
#include "backend/Dungeon.h"
diff --git a/frontend/cmd/equip.cpp b/frontend/cmd/equip.cpp
index 578db0e..238d287 100644
--- a/frontend/cmd/equip.cpp
+++ b/frontend/cmd/equip.cpp
@@ -1,9 +1,9 @@
#include "backend/ListIterator.h"
#include "backend/Dungeon.h"
+#include "backend/Exception.h"
#include "../GameController.h"
#include "../strings.h"
-#include "../Exception.h"
using namespace std;
diff --git a/frontend/cmd/get.cpp b/frontend/cmd/get.cpp
index 358bf1f..dd098d1 100644
--- a/frontend/cmd/get.cpp
+++ b/frontend/cmd/get.cpp
@@ -2,8 +2,8 @@
#include "../GameController.h"
#include "../strings.h"
-#include "../Exception.h"
+#include "backend/Exception.h"
#include "backend/print.h"
#include "backend/GoldObject.h"
#include "backend/Location.h"
diff --git a/frontend/cmd/go.cpp b/frontend/cmd/go.cpp
index 5fd7c93..185d727 100644
--- a/frontend/cmd/go.cpp
+++ b/frontend/cmd/go.cpp
@@ -1,10 +1,10 @@
#include "backend/Location.h"
#include "backend/print.h"
#include "backend/Dungeon.h"
+#include "backend/Exception.h"
#include "../GameController.h"
#include "../strings.h"
-#include "../Exception.h"
using namespace std;
diff --git a/frontend/cmd/hit.cpp b/frontend/cmd/hit.cpp
index 677bf4e..8491758 100644
--- a/frontend/cmd/hit.cpp
+++ b/frontend/cmd/hit.cpp
@@ -3,10 +3,10 @@
#include "backend/RNG.h"
#include "backend/print.h"
#include "backend/Dungeon.h"
+#include "backend/Exception.h"
#include "../GameController.h"
#include "../strings.h"
-#include "../Exception.h"
using namespace std;
diff --git a/frontend/cmd/put.cpp b/frontend/cmd/put.cpp
index 35de352..be3bcca 100644
--- a/frontend/cmd/put.cpp
+++ b/frontend/cmd/put.cpp
@@ -1,7 +1,7 @@
#include "../GameController.h"
#include "../strings.h"
-#include "../Exception.h"
+#include "backend/Exception.h"
#include "backend/print.h"
#include "backend/Location.h"
#include "backend/Dungeon.h"
diff --git a/frontend/cmd/view.cpp b/frontend/cmd/view.cpp
index 0f4f3d1..bd9e99b 100644
--- a/frontend/cmd/view.cpp
+++ b/frontend/cmd/view.cpp
@@ -1,7 +1,7 @@
#include "../GameController.h"
#include "../strings.h"
-#include "../Exception.h"
+#include "backend/Exception.h"
#include "backend/print.h"
#include "backend/Location.h"
#include "backend/Dungeon.h"
diff --git a/frontend/generate_dungeon.cpp b/frontend/generate_dungeon.cpp
index 868fe43..6e34673 100644
--- a/frontend/generate_dungeon.cpp
+++ b/frontend/generate_dungeon.cpp
@@ -2,11 +2,11 @@
#include "backend/Dungeon.h"
#include "backend/print.h"
+#include "backend/Exception.h"
#include "rl.h"
#include "generate_dungeon.h"
#include "GameData.h"
-#include "Exception.h"
using namespace std;
diff --git a/frontend/load_dungeon.cpp b/frontend/load_dungeon.cpp
index c671fe7..0388387 100644
--- a/frontend/load_dungeon.cpp
+++ b/frontend/load_dungeon.cpp
@@ -6,10 +6,10 @@
#include "backend/Location.h"
#include "backend/LocationFactory.h"
+#include "backend/Exception.h"
#include "backend/Dungeon.h"
#include "load_dungeon.h"
-#include "Exception.h"
#include "GameData.h"
#include "backend/Object.h"
#include "strings.h"
diff --git a/frontend/main.cpp b/frontend/main.cpp
index 64b4474..94e60c3 100644
--- a/frontend/main.cpp
+++ b/frontend/main.cpp
@@ -1,7 +1,7 @@
#include "backend/print.h"
+#include "backend/Exception.h"
#include "GameController.h"
-#include "Exception.h"
using namespace std;