aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-28 08:35:59 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-28 08:35:59 +0000
commitffcd9571f4ccf6f976d8a8f7d3538e7bd9ad57e9 (patch)
treeaaef7c1e02c296de51157da0cabbcdc23025090c
parentc16b4c134eb93a0b4b1e7e0598838881be3fb9b7 (diff)
downloadpaludis-ffcd9571f4ccf6f976d8a8f7d3538e7bd9ad57e9.tar.gz
paludis-ffcd9571f4ccf6f976d8a8f7d3538e7bd9ad57e9.tar.xz
Allow destringifiable SEs
-rwxr-xr-xmisc/make_se.bash45
1 files changed, 45 insertions, 0 deletions
diff --git a/misc/make_se.bash b/misc/make_se.bash
index 4fa2b9b..e081ab5 100755
--- a/misc/make_se.bash
+++ b/misc/make_se.bash
@@ -28,6 +28,7 @@ while read a ; do
want_key_descriptions=( )
want_prefix_key=
want_namespace=paludis
+ want_destringify=
key()
{
@@ -50,6 +51,11 @@ while read a ; do
:
}
+ want_destringify()
+ {
+ want_destringify=yes
+ }
+
make_enum_${a}
if [[ -z "${want_prefix_key}" ]] ; then
echo "no prefix key set for ${a}" 1>&2
@@ -71,6 +77,11 @@ while read a ; do
:
}
+ want_destringify()
+ {
+ :
+ }
+
if [[ "${what_to_make}" == "--header" ]] ; then
echo "#ifdef DOXYGEN"
@@ -105,6 +116,15 @@ while read a ; do
echo "operator<< (std::ostream &, const $a &) PALUDIS_VISIBLE;"
echo
+ if [[ -n "${want_destringify}" ]] ; then
+ echo "/**"
+ echo " * Read a ${a} from a stream."
+ echo " */"
+ echo "std::istream &"
+ echo "operator>> (std::istream &, $a &) PALUDIS_VISIBLE;"
+ echo
+ fi
+
echo "#ifdef DOXYGEN"
echo "// end namespace for doxygen"
echo "}"
@@ -138,6 +158,31 @@ while read a ; do
echo "}"
echo
+ if [[ -n "${want_destringify}" ]] ; then
+ echo "std::istream &"
+ echo "${want_namespace}::operator>> (std::istream & s, $a & a)"
+ echo "{"
+ echo " std::string value;"
+ echo " s >> value;"
+ echo
+ echo " do"
+ echo " {"
+ for (( k = 0 ; k < ${#want_keys[@]} ; k++ )) ; do
+ echo " if (value == \"${want_keys[${k}]#${want_prefix_key}_}\")"
+ echo " {"
+ echo " a = ${want_keys[${k}]};"
+ echo " break;"
+ echo " }"
+ echo
+ done
+ echo " s.setstate(std::ios::badbit);"
+ echo " } while (false);"
+ echo
+ echo " return s;"
+ echo "}"
+ echo
+ fi
+
else
echo "bad argument (expected --header or --source)" 1>&2
exit 1