本文整理汇总了C++中CFunction::getNumInputParameters方法的典型用法代码示例。如果您正苦于以下问题:C++ CFunction::getNumInputParameters方法的具体用法?C++ CFunction::getNumInputParameters怎么用?C++ CFunction::getNumInputParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFunction
的用法示例。
在下文中一共展示了CFunction::getNumInputParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}