added 'write_query' free function

.. which write a viennamaterials::query to a std::ostream (cout by
default) -> useful for debugging
added query exception,write_query(),has_entry()+outsourced generate_query_string()

updated example to reflect the new API extensions