本文整理汇总了C++中CFunction::getReturnDataType方法的典型用法代码示例。如果您正苦于以下问题:C++ CFunction::getReturnDataType方法的具体用法?C++ CFunction::getReturnDataType怎么用?C++ CFunction::getReturnDataType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFunction
的用法示例。
在下文中一共展示了CFunction::getReturnDataType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkFunction
void Map::checkFunction(CFunction& function) const
throw(InvalidProcessException) {
if (function.getInputParameters().size() == 1) {
if (function.getReturnDataType()->getFunctionReturnDataTypeString()
== "void") {
THROW_EXCEPTION(InvalidProcessException, string("Leaf \"")
+ getId()->getString() + "\" of type \""
+ type() + "\": function arguments with one input "
"parameter must return data (i.e. have return "
"data type other than \"void\")");
}
if (function.getReturnDataType()->isArray()) {
THROW_EXCEPTION(InvalidProcessException, string("Leaf \"")
+ getId()->getString() + "\" of type \""
+ type() + "\": return type of function arguments "
"with one input parameter must not be an array");
}
}
else if (function.getInputParameters().size() == 2) {
if (function.getReturnDataType()->getFunctionReturnDataTypeString()
!= "void") {
THROW_EXCEPTION(InvalidProcessException, string("Leaf \"")
+ getId()->getString() + "\" of type \""
+ type() + "\": function arguments with two input "
"parameters must not return data (i.e. have return "
"data type \"void\")");
}
}
else {
THROW_EXCEPTION(InvalidProcessException, string("Leaf \"")
+ getId()->getString() + "\" of type \""
+ type() + "\" must have a function argument with "
"one or two input parameters");
}
CDataType first_input_data_type =
*function.getInputParameters().front()->getDataType();
if (first_input_data_type.isArray() && !first_input_data_type.isConst()) {
THROW_EXCEPTION(InvalidProcessException, string("Leaf \"")
+ getId()->getString() + "\" of type \""
+ type() + "\": first input parameter is a "
"reference or array but not declared const");
}
}
示例2: findFunctionArraySizes
void GraphmlParser::findFunctionArraySizes(CFunction& function,
ticpp::Element* xml)
throw(InvalidArgumentException, ParseException, IOException,
RuntimeException) {
if (!xml) {
THROW_EXCEPTION(InvalidArgumentException, "\"xml\" must not be NULL");
}
list<Element*> elements = getElementsByName(xml, "port");
// If return data type or last input parameter is an array, find the array
// size by analyzing the out port XML elements
CDataType* output_data_type = NULL;
if (function.getReturnDataType()->isArray()) {
output_data_type = function.getReturnDataType();
logger_.logMessage(Logger::DEBUG, "Searching array size for return "
"data type...");
} else if (function.getNumInputParameters() > 1) {
output_data_type = function.getInputParameters().back()->getDataType();
// Reset to NULL if the parameter is not what we are looking for
if (output_data_type->isArray()) {
logger_.logMessage(Logger::DEBUG, "Searching array size for second "
"input parameter data type...");
}
else {
output_data_type = NULL;
}
}
if (output_data_type) {
list<Element*>::iterator it;
for (it = elements.begin(); it != elements.end(); ++it) {
logger_.logMessage(Logger::DEBUG,
string("Analyzing line "
+ tools::toString((*it)->Row()) + "..."));
string port_name = getName(*it);
if (isOutPort(port_name)) {
size_t array_size = findArraySize(*it);
if (array_size > 0) {
logger_.logMessage(Logger::DEBUG,
string("Found array size ")
+ tools::toString(array_size));
output_data_type->setArraySize(array_size);
}
break;
}
}
}
// Find array sizes for the input parameters which are arrays by analyzing
// the in port XML elements
list<CVariable*> parameters = function.getInputParameters();
list<CVariable*>::iterator param_it = parameters.begin();
list<CVariable*>::iterator param_stop_point;
list<Element*>::iterator xml_it = elements.begin();
if (function.getNumInputParameters() > 1) {
param_stop_point = --parameters.end();
}
else {
param_stop_point = parameters.end();
}
while (param_it != param_stop_point && xml_it != elements.end()) {
if (param_it == parameters.begin()) {
logger_.logMessage(Logger::DEBUG, "Searching array size for "
"input parameter data type...");
}
logger_.logMessage(Logger::DEBUG,
string("Analyzing line "
+ tools::toString((*xml_it)->Row())
+ "..."));
if (!isInPort(getName(*xml_it))) {
logger_.logMessage(Logger::DEBUG, "Not an in port, moving to next");
++xml_it;
continue;
}
if ((*param_it)->getDataType()->isArray()) {
size_t array_size = findArraySize(*xml_it);
if (array_size > 0) {
logger_.logMessage(Logger::DEBUG,
string("Found array size ")
+ tools::toString(array_size));
(*param_it)->getDataType()->setArraySize(array_size);
}
else {
logger_.logMessage(Logger::DEBUG, "No array size key");
}
}
++param_it;
++xml_it;
}
}