PLearn 0.1
RemoteMethodDoc.cc
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // RemoteMethodDoc.cc
00004 // Copyright (c) 2006 Pascal Vincent
00005 
00006 // Redistribution and use in source and binary forms, with or without
00007 // modification, are permitted provided that the following conditions are met:
00008 // 
00009 //  1. Redistributions of source code must retain the above copyright
00010 //     notice, this list of conditions and the following disclaimer.
00011 // 
00012 //  2. Redistributions in binary form must reproduce the above copyright
00013 //     notice, this list of conditions and the following disclaimer in the
00014 //     documentation and/or other materials provided with the distribution.
00015 // 
00016 //  3. The name of the authors may not be used to endorse or promote
00017 //     products derived from this software without specific prior written
00018 //     permission.
00019 // 
00020 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
00021 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00022 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
00023 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00024 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00025 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00026 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00027 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00028 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 // 
00031 // This file is part of the PLearn library. For more information on the PLearn
00032 // library, go to the PLearn Web site at www.plearn.org
00033 
00034 
00035 #include "RemoteMethodDoc.h"
00036 // #include "stringutils.h"    //!< For addprefix.
00037 
00038 namespace PLearn {
00039 using namespace std;
00040 
00041 void RemoteMethodDoc::checkConsistency() const
00042 {
00043     int argdocsize = m_args_doc.size();
00044     int argtypesize = m_args_type.size();
00045     if(argdocsize != argtypesize)
00046         PLERROR("For function '%s', number of ArgDoc (%d) inconsistent with number of arguments (%d)",
00047                 m_name.c_str(), argdocsize, argtypesize);
00048 }
00049     
00052 string RemoteMethodDoc::getPrototypeString(string argsep) const
00053 {
00054     string txt = returnType()+" "+name()+"(";
00055     list<ArgDoc>::const_iterator arg;
00056     list<ArgDoc>::const_iterator argbegin = argListDoc().begin();        
00057     list<ArgDoc>::const_iterator argend = argListDoc().end();
00058     list<string>::const_iterator argtype = argListType().begin();
00059     for(arg=argbegin; arg!=argend; ++arg, ++argtype)
00060     {
00061         if(arg!=argbegin)
00062             txt += argsep;
00063         txt += *argtype+" "+arg->m_argument_name;
00064     }
00065     txt += ")";
00066     return txt;
00067 }
00068 
00069 string RemoteMethodDoc::getFullHelpText() const
00070 {
00071     int nargs = nArgs();
00072     string txt = getPrototypeString() + "\n";
00073     txt += bodyDoc() + "\n";
00074     if(nargs==0)
00075         txt += "TAKES NO ARGUMENTS.\n";
00076     else
00077     {
00078         list<ArgDoc>::const_iterator arg = argListDoc().begin();        
00079         list<ArgDoc>::const_iterator argend = argListDoc().end();
00080         list<string>::const_iterator argtype = argListType().begin();
00081         txt += "ARGUMENTS: \n";
00082         for(; arg!=argend; ++arg, ++argtype)
00083         {
00084             txt += arg->m_argument_name + " : " 
00085                 +  *argtype + "\n"
00086                 +  '\t' + arg->m_doc + "\n";
00087         }
00088     }
00089     txt += "RETURNS: ";
00090     txt += returnType() + "\n";
00091     txt += returnDoc() + "\n";
00092     return txt;
00093 }
00094 
00095 } // end of namespace PLearn
00096 
00097 
00098 /*
00099   Local Variables:
00100   mode:c++
00101   c-basic-offset:4
00102   c-file-style:"stroustrup"
00103   c-file-offsets:((innamespace . 0)(inline-open . 0))
00104   indent-tabs-mode:nil
00105   fill-column:79
00106   End:
00107 */
00108 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines