metaSMT git

metaSMT/Comment.hpp

Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include "Features.hpp"
00004 
00005 #include <boost/mpl/assert.hpp>
00006 
00007 namespace metaSMT {
00008 
00009   namespace features {
00010     struct comment_api {};
00011   } /* features */
00012 
00013   struct write_comment { typedef void result_type; };
00014 
00037   template <typename Context > 
00038   struct IgnoreComments : Context {
00039       void command ( write_comment const &, std::string const & message) {
00040         /* ignored */
00041       }
00042 
00043       using Context::command;
00044   };
00045 
00046   namespace features {
00047     /* IgnoreComments supports comment api (by ignoring it) */
00048     template<typename Context>
00049     struct supports< IgnoreComments<Context>, features::comment_api>
00050     : boost::mpl::true_ {};
00051 
00052     /* Forward all other supported operations */
00053     template<typename Context, typename Feature>
00054     struct supports< IgnoreComments<Context>, Feature>
00055     : supports<Context, Feature>::type {};
00056   }
00057 
00058 
00067   template <typename Context >
00068   void comment( Context & ctx, std::string const &  message) {
00069     BOOST_MPL_ASSERT_MSG(( features::supports<Context, features::comment_api>::value ),
00070         context_does_not_support_comment_api, (Context) );
00071     ctx.command(write_comment(), message);
00072   }
00073 
00076 } /* metaSMT */
00077 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines