aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstate.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-06-13 01:35:53 +0000
committerlloyd <[email protected]>2006-06-13 01:35:53 +0000
commit4bbacf4aae4b8b98d02ea887593492c1b9dacdc7 (patch)
tree873873f8b919a0bd8b54d086555c23c500537c56 /src/libstate.cpp
parent5b4ec650b1199578fcf1bd7fdc93ed0f48e7c5a3 (diff)
Add some initial support for centralized/user-pluggable character
set conversions, to replace the current hardcoded stuff.
Diffstat (limited to 'src/libstate.cpp')
-rw-r--r--src/libstate.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libstate.cpp b/src/libstate.cpp
index 456a4a8dd..581345f76 100644
--- a/src/libstate.cpp
+++ b/src/libstate.cpp
@@ -8,6 +8,7 @@
#include <botan/engine.h>
#include <botan/mutex.h>
#include <botan/timers.h>
+#include <botan/charset.h>
namespace Botan {
@@ -264,6 +265,29 @@ void Library_State::add_engine(Engine* engine)
}
/*************************************************
+* Set the character set transcoder object *
+*************************************************/
+void Library_State::set_transcoder(class Charset_Transcoder* transcoder)
+ {
+ if(this->transcoder)
+ delete this->transcoder;
+ this->transcoder = transcoder;
+ }
+
+/*************************************************
+* Transcode a string from one charset to another *
+*************************************************/
+std::string Library_State::transcode(const std::string str,
+ Character_Set to,
+ Character_Set from) const
+ {
+ if(!transcoder)
+ throw Invalid_State("Library_State::transcode: No transcoder set");
+
+ return transcoder->transcode(str, to, from);
+ }
+
+/*************************************************
* Library_State Constructor *
*************************************************/
Library_State::Library_State(Mutex_Factory* mutex_factory, Timer* timer)
@@ -275,6 +299,7 @@ Library_State::Library_State(Mutex_Factory* mutex_factory, Timer* timer)
this->mutex_factory = mutex_factory;
this->timer = timer;
+ this->transcoder = 0;
locks["settings"] = get_mutex();
locks["allocator"] = get_mutex();
@@ -307,6 +332,7 @@ Library_State::~Library_State()
delete j->second;
}
+ delete transcoder;
delete mutex_factory;
delete timer;