aboutsummaryrefslogtreecommitdiff
path: root/libxsde/xsde/cxx/serializer/validating/string.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libxsde/xsde/cxx/serializer/validating/string.cxx')
-rw-r--r--libxsde/xsde/cxx/serializer/validating/string.cxx27
1 files changed, 27 insertions, 0 deletions
diff --git a/libxsde/xsde/cxx/serializer/validating/string.cxx b/libxsde/xsde/cxx/serializer/validating/string.cxx
index 8082baa..0def094 100644
--- a/libxsde/xsde/cxx/serializer/validating/string.cxx
+++ b/libxsde/xsde/cxx/serializer/validating/string.cxx
@@ -3,6 +3,7 @@
// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+#include <string.h> // strlen
#include <xsde/cxx/serializer/validating/string.hxx>
namespace xsde
@@ -29,6 +30,32 @@ namespace xsde
void string_simpl::
_serialize_content ()
{
+ // Check facets.
+ //
+ if (length_set_ || min_length_set_ || max_length_set_)
+ {
+ size_t n = strlen (value_);
+ const facets& f = _facets ();
+
+ if (f.length_set_ && n != f.length_)
+ {
+ _schema_error (schema_error::length_not_equal_prescribed);
+ return;
+ }
+
+ if (f.min_length_set_ && n < f.min_length_)
+ {
+ _schema_error (schema_error::length_less_than_min);
+ return;
+ }
+
+ if (f.max_length_set_ && n > f.max_length_)
+ {
+ _schema_error (schema_error::length_greater_than_max);
+ return;
+ }
+ }
+
_characters (value_);
if (free_)