* scribo/core/tag/component.hh,
* scribo/core/tag/line.hh: Here.
---
scribo/ChangeLog | 7 +++++++
scribo/scribo/core/tag/component.hh | 35 +++++++++++++++++++++++++++++++++++
scribo/scribo/core/tag/line.hh | 34 +++++++++++++++++++++++++++++++++-
3 files changed, 75 insertions(+), 1 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 2d66a58..f03eb97 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,12 @@
2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add new conversion routines from string to tag.
+
+ * scribo/core/tag/component.hh,
+ * scribo/core/tag/line.hh: Here.
+
+2011-02-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Various changes in scribo core structures.
* scribo/scribo/core/component_info.hh: Remove useless line_id.
diff --git a/scribo/scribo/core/tag/component.hh b/scribo/scribo/core/tag/component.hh
index f773932..10b86a6 100644
--- a/scribo/scribo/core/tag/component.hh
+++ b/scribo/scribo/core/tag/component.hh
@@ -61,6 +61,14 @@ namespace scribo
Image
};
+
+ std::ostream& operator<<(std::ostream& ostr, const Tag& tag);
+ Tag str2tag(const std::string& str);
+
+ std::ostream& operator<<(std::ostream& ostr, const Type& type);
+ Type str2type(const std::string& str);
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -85,6 +93,16 @@ namespace scribo
inline
+ Tag str2tag(const std::string& str)
+ {
+ if (str == "Ignored")
+ return Ignored;
+
+ return None;
+ }
+
+
+ inline
std::ostream&
operator<<(std::ostream& ostr, const Type& type)
{
@@ -116,6 +134,23 @@ namespace scribo
}
+ inline
+ Type str2type(const std::string& str)
+ {
+ if (str == "Character")
+ return Character;
+ else if (str == "Separator")
+ return Separator;
+ else if (str == "Noise")
+ return Noise;
+ else if (str == "Punctuation")
+ return Punctuation;
+ else if (str == "Image")
+ return Image;
+
+ return Undefined;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/scribo/scribo/core/tag/line.hh b/scribo/scribo/core/tag/line.hh
index 0444a11..3fb1fdf 100644
--- a/scribo/scribo/core/tag/line.hh
+++ b/scribo/scribo/core/tag/line.hh
@@ -96,7 +96,7 @@ namespace scribo
std::ostream&
operator<<(std::ostream& ostr, const Type& type);
-
+ Type str2type(const std::string& str);
# ifndef MLN_INCLUDE_ONLY
@@ -208,6 +208,38 @@ namespace scribo
return ostr << str;
}
+ inline
+ Type str2type(const std::string& str)
+ {
+ if (str == "caption")
+ return Caption;
+ else if (str == "credit")
+ return Credit;
+ else if (str == "drop-capital")
+ return DropCapital;
+ else if (str == "floating")
+ return Floating;
+ else if (str == "footer")
+ return Footer;
+ else if (str == "header")
+ return Header;
+ else if (str == "heading")
+ return Heading;
+ else if (str == "page-number")
+ return PageNumber;
+ else if (str == "paragraph")
+ return Paragraph;
+
+ // Values unsupported by the XSD
+ else if(str == "punctuation")
+ return Punctuation;
+ else if (str == "text")
+ return Text;
+
+ return Undefined;
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
Show replies by date