aboutsummaryrefslogtreecommitdiff
path: root/misc/make_se.bash
diff options
context:
space:
mode:
Diffstat (limited to 'misc/make_se.bash')
-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 4fa2b9b29..e081ab591 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