本文整理汇总了C++中Method::extractNamespace方法的典型用法代码示例。如果您正苦于以下问题:C++ Method::extractNamespace方法的具体用法?C++ Method::extractNamespace怎么用?C++ Method::extractNamespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Method
的用法示例。
在下文中一共展示了Method::extractNamespace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generate_CPP_USER
void GenerateServerMethods::generate_CPP_USER(const std::string &destdir, const std::string &name)
{
const std::string h_name = theClass.getBaseName() + "_ulxr_server.h";
std::string cpp_name = destdir + theClass.getBaseName() + "_ulxr_server_user.cpp";
struct stat statbuf;
if (stat(cpp_name.c_str(), &statbuf) >= 0)
{
std::cout << "User file already exists: " << cpp_name << std::endl;
cpp_name += ".new";
std::cout << "New template will be created: " << cpp_name << std::endl;
}
std::ofstream cpp_file(cpp_name.c_str());
std::cout << "User file will be created: " << cpp_name << std::endl;
generateUserSourceHead(cpp_file, h_name);
cpp_file << "#include <ulxmlrpcpp/ulxr_response.h>\n";
cpp_file << "#include <ulxmlrpcpp/ulxr_method_adder.h>\n";
cpp_file << "#include <ulxmlrpcpp/ulxr_signature.h>\n\n";
cpp_file << "#include \"" << theClass.getSource() << "\"\n";
cpp_file << "#include \"" << name + "_ulxr_names.h" << "\"\n\n";
cpp_file <<
"\nvoid " << name << "Server::setupServerMethods()\n"
"{\n";
for (unsigned i = 0; i < theClass.numMethods(); ++i)
{
if (i != 0)
cpp_file << "\n";
Method method = theClass.getMethod(i);
method.extractNamespace();
cpp_file << " // mapped to: " << method.getCppString(0, false, "");
if (method.getName() != method.getOverloadName())
cpp_file << " (there are overloaded methods)";
cpp_file <<
"\n"
" method_adder.addMethod(ulxr::make_method(*this, &" << method.getOverloadName(true, "Server") << "),\n"
" " << method.getType().getRpcName() << "::getValueName(),\n"
" ULXR_CALLTO_" << method.getOverloadName(true, "", "_") << ",\n"
" ulxr::Signature()";
for (unsigned p = 0; p < method.numArgs(); ++p)
cpp_file << "\n << " << method.getArg(p).getType().getRpcName() << "::getValueName()";
cpp_file <<
",\n"
" ulxr_i18n(ULXR_PCHAR(\"Some descriptive comment about '" << method.getCppString(0, true, "") << "'.\"))); // TODO adjust comment\n";
}
cpp_file <<
"}\n\n";
}
示例2: generateHeaderVariables
void GenerateServerMethods::generateHeaderVariables(std::ostream & h_file)
{
h_file << " private:\n\n";
for (unsigned i = 0; i < theClass.numMethods(); ++i)
{
Method method = theClass.getMethod(i);
method.extractNamespace();
const bool reftype = method.getType().isReference();
if (reftype)
h_file << " mutable " << method.getType().getName() << " ulxr_refFor_" << method.getOverloadName() << ";\n";
}
h_file << " " << theClass.getName() << " &server;\n"
<< " ulxr::MethodAdder &method_adder;\n";
}
示例3: generateHeaderMethods
void GenerateServerMethods::generateHeaderMethods(std::ostream & h_file)
{
for (unsigned i = 0; i < theClass.numMethods(); ++i)
{
Method method = theClass.getMethod(i);
method.extractNamespace();
h_file << " // mapped to: " << method.getCppString(0, false, "");
if (method.getName() != method.getOverloadName())
h_file << " (there are overloaded methods)";
h_file << "\n"
<< " ulxr::MethodResponse " << method.getOverloadName() << " (const ulxr::MethodCall &calldata);\n\n";
}
h_file << " private:\n\n";
h_file << " void setupServerMethods();\n";
h_file << " void removeServerMethods();\n\n";
}
示例4: generateSourceMethods
void GenerateServerMethods::generateSourceMethods(std::ostream & cpp_file)
{
for (unsigned i = 0; i < theClass.numMethods(); ++i)
{
Method method = theClass.getMethod(i);
method.extractNamespace();
cpp_file << "// mapped to: " << method.getCppString(0, false, "");
if (method.getName() != method.getOverloadName())
cpp_file << " (there are overloaded methods)";
cpp_file << "\nulxr::MethodResponse\n "
<< method.getOverloadName(true, "Server") << " (const ulxr::MethodCall &calldata)\n"
<< "{\n"
<< " try\n"
<< " {\n";
for (unsigned iarg = 0; iarg < method.numArgs(); ++iarg)
{
std::string adap = method.getArg(iarg).getType().getTypeAdapter();
std::string adap2;
if (adap.length() != 0)
{
adap += "(";
adap2 = ")";
}
cpp_file << " " << method.getArg(iarg).getType().getName() << " p" << iarg << " = "
<< "(" << method.getArg(iarg).getType().getName() << ") "
<< adap + method.getArg(iarg).getType().getRpcName() << "(calldata.getParam(" << iarg << "))." << method.getArg(iarg).getType().getRpcAccessor()
<< "()" << adap2 << ";\n";
}
bool have_retval = false;
if (method.getType().getName() != "void" || method.getType().getLeft() != "" || method.getType().getRight() != "")
have_retval = true;
if (have_retval)
{
cpp_file << " " << method.getType().getProxyType() << " retval = "
<< method.getType().getTypeDereference();
}
else
cpp_file << " ";
cpp_file << "server." << method.getName() << "(";
for (unsigned iarg = 0; iarg < method.numArgs(); ++iarg)
{
if (iarg != 0)
cpp_file << ", ";
// cpp_file << "(" << method.getArg(iarg).getType().getCppString() << ")";
if(method.getArg(iarg).getType().isPointer())
cpp_file << "&";
cpp_file << "p" << iarg;
}
cpp_file << ");\n";
std::string adap = method.getType().getInversTypeAdapter();
std::string adap2;
if (adap.length() != 0)
{
adap += "(";
adap2 = ")";
}
if (have_retval)
cpp_file << " return ulxr::MethodResponse ("<< method.getType().getRpcName() << " (" << adap << "retval" << adap2 << "));\n";
else
cpp_file << " return ulxr::MethodResponse (ulxr::Void());\n";
cpp_file << " }\n"
<< " catch(std::exception &ex)\n"
<< " {\n"
<< " ulxr::CppString s = ULXR_PCHAR(\"C++ exception caught when invoking '" << method.getCppString(0, false, "") << "'\\n \");\n"
<< " s += ULXR_GET_STRING(ex.what());\n"
<< " return ulxr::MethodResponse(ulxr::ApplicationError, s);\n"
<< " }\n"
<< " catch(...)\n"
<< " {\n"
<< " ulxr::CppString s = ULXR_PCHAR(\"Unknown exception caught when invoking '" << method.getCppString(0, false, "") << "'\");\n"
<< " return ulxr::MethodResponse(ulxr::ApplicationError, s);\n"
<< " }\n";
cpp_file << "}\n\n\n";
}
// ------------------------------------
cpp_file <<
"\nvoid " << theClass.getBaseName() << "Server::removeServerMethods()\n"
"{\n";
for (unsigned i = 0; i < theClass.numMethods(); ++i)
{
//.........这里部分代码省略.........