How do I doxygen-document unnamed parameters of a function? - documentation

With doxygen, I'm used to write
/**
* #brief blah blah
*
* #param foo description of foo
* #param bar description of bar
* #return description of the return value
*/
int f(int foo, unsigned bar);
But what if I don't name one of the parameter? :
int f(int, unsigned bar);
How can I document this parameter when I can't refer to it by name?

Doxygen does not currently (July 2020) implement this functionality. However, a feature request has been opened on the Doxygen GitHub issues page for it:
#6926 Feature request: doc for unnamed parameters

Related

Add a VSA (Vendor Specific Attribute) to Access-Accept reply programmatically in FreeRADIUS C module

I have a FreeRADIUS C language module that implements MOD_AUTHENTICATE and MOD_AUTHORIZE methods for custom auth purpose. I need the ability to programmatically add VSAs to the Access-Accept reply.
I have toyed a bit with radius_pair_create() and fr_pair_add() methods (see snippet below) but that didn’t yield any change to the reply content, possibly because I specified ad-hoc values that don’t exist in a vendor-specific dictionary. Or because I didn’t use them correctly.
My FreeRADIUS version is 3_0_19
Any information, pointers and, especially, syntax samples will be highly appreciated.
void test_vsa(REQUEST *request)
{
VALUE_PAIR *vp = NULL;
vp = radius_pair_create(request->reply, NULL, 18, 0);
if (vp)
{
log("Created VALUE_PAIR");
vp->vp_integer = 96;
fr_pair_add(&request->reply->vps, vp);
}
else
{
log("Failed to create VALUE_PAIR");
}
}
So first off you're writing an integer value to a string attribute, which is wrong. The only reason why the server isn't SEGVing is because the length of the VP has been left at zero, so the RADIUS encoder doesn't bother dereferencing the char * inside the pair that's meant to contain the pair's value.
fr_pair_make is the easier function to use here, as it takes both the attribute name and value as strings, so you don't need to worry about the C types.
The code snippet below should do what you want.
void test_avp(REQUEST *request)
{
VALUE_PAIR *vp = NULL;
vp = fr_pair_make(request->reply, &request->reply->vps, "Reply-Message", "Hello from FreeRADIUS", T_OP_SET);
if (vp)
{
log("Created VALUE_PAIR");
}
else
{
log("Failed to create VALUE_PAIR");
}
}
For a bit more of an explanation, lets look at the doxygen header:
/** Create a VALUE_PAIR from ASCII strings
*
* Converts an attribute string identifier (with an optional tag qualifier)
* and value string into a VALUE_PAIR.
*
* The string value is parsed according to the type of VALUE_PAIR being created.
*
* #param[in] ctx for talloc
* #param[in] vps list where the attribute will be added (optional)
* #param[in] attribute name.
* #param[in] value attribute value (may be NULL if value will be set later).
* #param[in] op to assign to new VALUE_PAIR.
* #return a new VALUE_PAIR.
*/
VALUE_PAIR *fr_pair_make(TALLOC_CTX *ctx, VALUE_PAIR **vps,
char const *attribute, char const *value, FR_TOKEN op)
ctx - This is the packet or request that the vps will belong to. If you're adding attributes to the request it should be request->packet, reply would be request->reply, control would be request.
vps - If specified, this will be which list to insert the new VP into. If this is NULL fr_pair_make will just return the pair and let you insert it into a list.
attribute - The name of the attribute as a string.
value - The value of the attribute as a string. For non-string types, fr_pair_make will attempt to perform a conversion. So, for example, passing "12345" for an integer type, will result in the integer value 12345 being written to an int field in the attribute.
op - You'll usually want to us T_OP_SET which means overwrite existing instances of the same attribute. See the T_OP_* values of FR_TOKEN and the code that uses them, if you want to understand the different operators and what they do.

Passing array as function parameters in PHP7.0

I have a function as follows:
/**
* #param \string[] ...$whitelist
* #return Array
*/
public function whitelist(string ...$whitelist): Array
{
// code
}
How can I pass an array (e.g $arr = [$val1, $val2, ...]) to the function?
Note that I cannot change the function structure because it belongs to a third party class I am using in my code.
/**
* #param \string[] ...$whitelist
* #return Array
*/
public function whitelist(string ...$whitelist): Array
{
// code
}
You pass the arguments by separating them by comma, meaning the whitelist function takes n number of arguments. You are using the splat operator (https://lornajane.net/posts/2014/php-5-6-and-the-splat-operator). So, in your case it may be something like:
whitelist(...['Item 1', 'Item 2', 'Item 3']);

Auto-generated POKey object in Intershop 7 compilation errors

We are migrating site from Intershop 6.4 to Intershop 7.9.
As suggested by Intershop support, we are trying to recreate all the auto-generated classes from the EDL model.
Here is the interface EDL code:
import "enfinity:/core/edl/com/intershop/beehive/core/types.edl";
import "enfinity:/core/edl/com/intershop/beehive/core/capi/domain/PersistentObject.edl";
import "enfinity:/core/edl/com/intershop/beehive/core/capi/domain/PersistentObjectPO.edl";
external PromotionCollection type "java.util.Collection<A1Promotion>";
namespace hr.a1.core.capi.promotion
{
cartridge interface A1Promotion extends PersistentObject
{
/**
* Promotion TMCode.
*/
attribute tmCode: string required;
/**
* Siebel promotion id.
*/
attribute siebelID: string required;
/**
* Promotion name.
*/
attribute name: string required;
/**
* Promotion description / currently URL to CW.
*/
attribute description: string;
/**
* Defines promotion priority / lower values first.
*/
attribute priority: int;
/**
* Holds link to tariff.
*/
attribute tariffID: uuid;
/**
* Contract type (A, M, R).
*/
attribute contractType: string required;
/**
* Contract binding (0, 12, 24).
*/
attribute contractBinding: string required;
/**
* Discount type / MF - monthly fee, HW - hardware, FU - free unit (not used at the moment)
*/
attribute discountType: string required;
/**
* Discount mode / P - percentage or F - fixed amount
*/
attribute discountMode: string;
/**
* Discount amount / either money value or percentage value / stored internally as Money
*/
attribute discountAmount: Money;
/*
* Flag which if it set disables checkbox of current promotion so user can't deselect it.
*/
attribute preselected: boolean;
/**
* Promotion validity / from date.
*/
attribute activeFrom: datetime;
/**
* Promotion validity / to date.
*/
attribute activeTo: datetime;
/**
* Promotion group / D - default, N - personalized, S% - Special
*/
attribute promotionGroup: string required;
/**
* Promotion type / S - single, G - group
*/
attribute promotionType: string required;
/**
* Free units amount type (MB, GB, SMS..)
*/
attribute units: string;
/**
* Group rule defined for promotion if promotion is group promotion
*/
attribute groupRule: string;
/**
* Name of the coupon list for the coupon promotions
*/
attribute couponListName: string;
/**
* HW promotion discount id
*/
attribute discountId: int;
}
}
and this is the PO EDL code:
import "enfinity:/app_core_a1/edl/app_core_a1/capi/A1Promotion.edl";
import "enfinity:/xcs/edl/com/intershop/beehive/xcs/internal/product/ProductPO.edl";
import "enfinity:/core/edl/com/intershop/beehive/core/types.edl";
import "enfinity:/core/edl/com/intershop/beehive/core/capi/domain/PersistentObjectPO.edl";
namespace hr.a1.core.internal.promotion
{
/*
* #author dragisic
*/
orm class A1PromotionPO extends PersistentObjectPO implements A1Promotion table "A1Promotion"
{
/**
* Promotion id.
*/
attribute tmCode : string<25> required column "tm_code";
/**
* Siebel promotion id.
*/
attribute siebelID : string<25> required column "siebel_id";
/**
* Promotion name.
*/
attribute name : string<100> required column "name";
/**
* Promotion description / currently URL to CW.
*/
attribute description : string<255> column "description";
/**
* Defines promotion priority / lower values first.
*/
attribute priority : int column "priority";
/**
* Holds link to tariff.
*/
attribute tariffID : uuid;
/**
* Contract type (A, M, R).
*/
attribute contractType : string<1> required column "contract_type";
/**
* Contract binding (0, 12, 24).
*/
attribute contractBinding : string<4> required column "contract_binding";
/**
* Discount type / MF - monthly fee, HW - hardware, FU - free unit (not used at the moment)
*/
attribute discountType : string<2> required column "discount_type";
/**
* Discount mode / P - percentage or F - fixed amount
*/
attribute discountMode : string<1> column "discount_mode";
/**
* Discount amount / either money value or percentage value / stored internally as Money
*/
attribute discountAmount : Money column "discount_amount";
/**
* Flag which if it set disables checkbox of current promotion so user can't deselect it.
*/
attribute preselected : boolean column "is_preselected";
/**
* Promotion validity / from date.
*/
attribute activeFrom : datetime column "active_from";
/**
* Promotion validity / to date.
*/
attribute activeTo : datetime column "active_to";
/**
* Promotion group / D - default, N - personalized, S% - Special
*/
attribute promotionGroup : string<3> required column "promo_group";
/**
* Promotion type / S - single, G - group
*/
attribute promotionType : string<1> required column "promo_type";
/**
* Free units amount type (MB, SMS..)
*/
attribute units : string<4> column "units";
/**
* Group rule defined for promotion if promotion is group promotion
*/
attribute groupRule : string<10> column "group_rule";
/**
* Name of the coupon list for the coupon promotions
*/
attribute couponListName: string<100> column "coupon_list_name";
/**
* Defines HW promotion discount id.
*/
attribute discountId : int column "discount_id";
/**
* Declare index in search items.
*/
index (contractType, contractBinding);
}
}
However, when we generate the code with the "Code generator for Intershop version 7.2 and later" we get the following compilation errors in the auto-generated class A1PromotionPOKey.java:
"The constructor Object(String) is undefined"
"The hierarchy of the type A1PromotionPOKey is inconsistent"
The auto-generated class looks like this:
// =============================================================================
// File: A1PromotionPOKey.java
// Generated by JGen Code Generator from INTERSHOP Communications AG.
// Generator template: ORMKey.xpt(checksum: b5b09bf4e9329db7d7dafe870b159b0d)
// =============================================================================
// The JGen Code Generator software is the property of INTERSHOP Communications AG.
// Any rights to use are granted under the license agreement.
// =============================================================================
package hr.a1.core.internal.promotion;
import com.intershop.beehive.core.capi.domain.PersistentObjectPOKey;
/**
* This class represents the primary key for objects of type A1PromotionPO.
* The key objects can be used for lookup operations in the database.
*
* #author dragisic
* #generated
*/
public class A1PromotionPOKey extends PersistentObjectPOKey {
/**
* Useless constant to make compiler happy.
*
* #generated
*/
private static final long serialVersionUID = 1L;
/**
* Creates an empty primary key. After creation of a new key object
* you must call the corresponding set<i>Attribute</i> method(s) to
* set the value(s) of the primary key.
*
* #generated
*/
public A1PromotionPOKey() {
}
/**
* Creates a primary key with the specified value(s).
*
* #generated
*/
public A1PromotionPOKey(
String UUID) {
super(UUID);
}
}
We have checked the gradle dependencies and the PersistentObjectPOKey import looks fine and the containing jar is added in the cartridge. We have also tried restarting Studio and refreshing the project, but it doesn't help.
Same EDL model works fine and produces compilable auto-generated code in Enfinity Suite 6.4.
EDIT:
Also, Im attaching errors from the console log during gradle build of the project.
:app_core_a1:compileJavaC:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\internal\promotion\A1PromotionPOKey.java:20: error: cannot access CacheClearKey
public class A1PromotionPOKey extends
^
class file for com.intershop.beehive.cache.capi.common.CacheClearKey not found
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\capi\promotion\A1PromotionMgr.java:11: warning: [deprecation] Manager in com.intershop.beehive.core.capi.common has been deprecated
import com.intershop.beehive.core.capi.common.Manager;
^
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\internal\promotion\A1PromotionPOFactory.java:14: warning: [deprecation] UUIDMgr in com.intershop.beehive.core.capi.util has been deprecated
import com.intershop.beehive.core.capi.util.UUIDMgr;
^
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\capi\promotion\A1PromotionMgr.java:11: warning: [deprecation] Manager in com.intershop.beehive.core.capi.common has been deprecated
import com.intershop.beehive.core.capi.common.Manager;
^
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\internal\promotion\A1PromotionPOFactory.java:14: warning: [deprecation] UUIDMgr in com.intershop.beehive.core.capi.util has been deprecated
import com.intershop.beehive.core.capi.util.UUIDMgr;
^
warning: The following options were not recognized by any processor: '[componentName]'
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\capi\promotion\A1PromotionMgr.java:11: warning: [deprecation] Manager in com.intershop.beehive.core.capi.common has been deprecated
import com.intershop.beehive.core.capi.common.Manager;
^
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\internal\promotion\A1PromotionPOFactory.java:14: warning: [deprecation] UUIDMgr in com.intershop.beehive.core.capi.util has been deprecated
import com.intershop.beehive.core.capi.util.UUIDMgr;
^
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\capi\promotion\A1PromotionMgr.java:24: warning: [deprecation] Manager in com.intershop.beehive.core.capi.common has been deprecated
Manager {
^
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\internal\promotion\A1PromotionPO.java:120: error: incompatible types: A1PromotionPOKey cannot be converted to PersistentObjectPOKey
super(factory, key);
^
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\internal\promotion\A1PromotionPOFactory.java:82: error: incompatible types: A1PromotionPOKey cannot be converted to ORMObjectKey
A1PromotionPO instance = (A1PromotionPO) getEngine().getPersistenceManager().createObject(key, getClassDescription());
^
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\internal\promotion\A1PromotionPOFactory.java:110: warning: [deprecation] UUIDMgr in com.intershop.beehive.core.capi.util has been deprecated
UUIDMgr.getInstance().createUUIDString(), domain.getUUID(), tmCode, siebelID, name, contractType, contractBinding, discountType, promotionGroup, promotionType);
^
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\internal\promotion\A1PromotionPOFactory.java:110: warning: [deprecation] getInstance() in UUIDMgr has been deprecated
UUIDMgr.getInstance().createUUIDString(), domain.getUUID(), tmCode, siebelID, name, contractType, contractBinding, discountType, promotionGroup, promotionType);
^
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\internal\promotion\A1PromotionPOFactory.java:110: warning: [deprecation] createUUIDString() in UUIDMgr has been deprecated
UUIDMgr.getInstance().createUUIDString(), domain.getUUID(), tmCode, siebelID, name, contractType, contractBinding, discountType, promotionGroup, promotionType);
^
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\internal\promotion\A1PromotionPOFactory.java:149: error: incompatible types: A1PromotionPOKey cannot be converted to ORMObjectKey
return (A1PromotionPO) super.getObjectByPrimaryKeyObject(key);
^
C:\Work\VIPnet\a1webshop\app_core_a1\src\main\java\hr\a1\core\internal\promotion\A1PromotionPOFactory.java:178: error: incompatible types: A1PromotionPOKey cannot be converted to ORMObjectKey
return (A1PromotionPO) super.getObjectByPrimaryKeyObject(key, mode);

Doxygen fail to detect NS_ENUM in objective-c

I'm using Doxygen to document API written in Objective-C.
Doyxygen fail to understand NS_ENUM typedef.
I've found this solution but it did not work for me.
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
PREDEFINED = NS_ENUM(x,y)=y
Regards,
Dimitri
This is my input file:
/**
* Represent the possible states.
*/
typedef NS_ENUM(NSInteger, ABEnumType)
{
/**
* State A.
*/
StateA = 0,
/**
* State B.
*/
StateB
};
This is the output I get:
Preprocessing /src/ABEnumType.h...
error: /src/ABEnumType.h:17:17: error: C++ requires a type specifier for all declarations [clang]
error: /src/ABEnumType.h:17:28: error: unknown type name 'ABEnumType' [clang]
error: /src/ABEnumType.h:18:1: error: function definition is not allowed here [clang]
error: /src/ABEnumType.h:17:9: error: C++ requires a type specifier for all declarations [clang]
Parsing file /src/ABEnumType.h...
The following settings worked for us:
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
PREDEFINED = NS_ENUM(x,y)=enum y
With this we see all the NS_ENUM structures showing up in our doxygen generated documentation
If Doxygen fails, you can always try HeaderDocs.
EDIT: I tried headerdocs with a test class and I think it does provide good support of NS_ENUM.
//
// VLTTestClass.h
// VPNLoginTest
//
#import <Foundation/Foundation.h>
/*!
Test class type description.
*/
typedef NS_ENUM(NSInteger, VLTestClassType) {
/*!
Description for type 1.
*/
VLTestClassType1,
/*!
Description for type 2.
*/
VLTestClassType2
};
/*!
Description for test class
*/
#interface VLTTestClass : NSObject
#end
Here is the headerdoc2html:http://pastebin.com/q6RsR0tU
gyurisc's answer helped but we also needed to enable EXTRACT_ALL. So the following settings work for us:
EXTRACT_ALL = YES
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
PREDEFINED = NS_ENUM(x,y)=enum y

How to map a single char column in Doctrine 2

How can I map a single char column in Doctrine 2, using annotations? I would like to have a char type, instead a single char string.
You can always use the string type with the fixed option:
/**
* #Column(type="string", length=2, options={"fixed" = true})
*/
protected $country;
The above code snippet produces the following SQL:
`country` char(2) NOT NULL,
Doctrine doesn't have a CHAR type defined out of the box, however it does allow you to define custom types, which you could use to create a 'char' type to use in annotations.
The Doctrine documentation has an example of this: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html#custom-mapping-types
You might end up providing your own full-column definition:
/**
* #Column(type="string", columnDefinition="CHAR(2) NOT NULL")
*/
protected $country = null;