Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a Doxygen comment for variadic function, i.e., a function with undefined number of arguments?

I am trying to write a doxygen block comment for a function with unlimited number of parameters, then I couldn't find a right tag for it. Supplied parameters should all be strings, and they will be concatenated in the function to form a new string.

What is the right use of doxygen tags?

like image 790
Joon Avatar asked Apr 05 '11 09:04

Joon


People also ask

How do you write a variadic function?

The variadic function consists of at least one fixed variable and then an ellipsis(…) as the last parameter. This enables access to variadic function arguments. *argN* is the last fixed argument in the variadic function. This one accesses the next variadic function argument.

How do you declare a variadic function in C++?

Variadic functions are functions (e.g. std::printf) which take a variable number of arguments. To declare a variadic function, an ellipsis appears after the list of parameters, e.g. int printf(const char* format...);, which may be preceded by an optional comma.

How do you take the variable number of arguments in CPP?

Variable number of arguments in C++Define a function with its last parameter as ellipses and the one just before the ellipses is always an int which will represent the number of arguments. Create a va_list type variable in the function definition. This type is defined in stdarg. h header file.


2 Answers

A pattern I see frequently in phpdoc (the format of which doxygen understands) is:

/** 
 * Shortdesc.
 * Longdesc.  Longdesc.  Longdesc.  Longdesc.  
 * @param mixed $something Description
 * @param mixed ... Description
 */
    function foo() { ... }

Yes, literally ... as the variable name.

like image 174
Charles Avatar answered Sep 20 '22 19:09

Charles


Actually, the syntax on the phpDocumentor is $paramname,...

/**
 * Builds a file path with the appropriate directory separator.
 * @param string $segments,... unlimited number of path segments
 * @return string Path
 */
function file_build_path(...$segments) {
    return join(DIRECTORY_SEPARATOR, $segments);
}
like image 33
Fred Avatar answered Sep 23 '22 19:09

Fred