I have a SaleItem class that has a pointer of an another class Product Category as member function, the getter of the SaleItem class that returns the pointer to the ProductCategory is causing the error. The IDE does not give the error straightaway but when I build the the C++ codebase; the SWIG interface interprets the c++ code for me in the build process. We interface the C++ to Perl using SWIG when it is done, in that particular section the error is thrown.
- The first excerpt of code is from the SALEITEM class
- The second is the Command Line text the describes the ERRORS
- The third section is the Product Category Class summary
- Fourth and the final is the SWIG interpretation.
The Section of the code that is at the bottom of this question is where the Terminal refers the error. But I believe it is in my C++ code. I have done all that I know in my knowledge to fix this issue. Therefore seeking your help
/**
* @brief returns the saleItem's Product Category Details in a pointer
* @return ProductCategory*
*
*/
ProductCategory* SaleItem::getProductCategory(){
return m_productCategory.get();
}
private:
/**
* @brief load SaleItem object from pc_sale_item table.
*
* @param SaleItemId
*
* @return true
* @return false
*
*/
bool _load(const string& pId);
private:
std::vector<shared_ptr<SaleItemCommission>> vCommissions;
unique_ptr<Contract> pRetailerContract;
unique_ptr<Contract> pServiceContract;
std::vector<std::string> _vTags;
unique_ptr<ProductCategory> m_productCategory;
std::string m_groupNum;
};
}
The Above is the SaleItem Class, the error is throwing at the function getProductCategory()
/home/rrajan/public_html/cms/src/cms_xl/build/swig/CMakeFiles/sale.dir/salePERL_wrap.cxx: In function ‘void _wrap_SaleItem_getProductCategory(PerlInterpreter*, CV*)’:
/home/rrajan/public_html/cms/src/cms_xl/build/swig/CMakeFiles/sale.dir/salePERL_wrap.cxx:23133:5: error: ‘ProductCategory’ was not declared in this scope
ProductCategory *result = 0 ;
^~~~~~~~~~~~~~~
/home/rrajan/public_html/cms/src/cms_xl/build/swig/CMakeFiles/sale.dir/salePERL_wrap.cxx:23133:5: note: suggested alternative:
In file included from /home/rrajan/public_html/cms/src/cms_xl/swig/../src/../src/sale/SaleItem.h:19:0,
from /home/rrajan/public_html/cms/src/cms_xl/build/swig/CMakeFiles/sale.dir/salePERL_wrap.cxx:2119:
/home/rrajan/public_html/cms/src/cms_xl/swig/../src/../src/sale/../core/ProductCategory.h:33:8: note: ‘Cms::ProductCategory’
class ProductCategory: public Virtual::Base
^~~~~~~~~~~~~~~
/home/rrajan/public_html/cms/src/cms_xl/build/swig/CMakeFiles/sale.dir/salePERL_wrap.cxx:23133:22: error: ‘result’ was not declared in this scope
ProductCategory *result = 0 ;
^~~~~~
/home/rrajan/public_html/cms/src/cms_xl/build/swig/CMakeFiles/sale.dir/salePERL_wrap.cxx:23133:22: note: suggested alternative: ‘res1’
ProductCategory *result = 0 ;
^~~~~~
res1
/home/rrajan/public_html/cms/src/cms_xl/build/swig/CMakeFiles/sale.dir/salePERL_wrap.cxx:23146:36: error: expected primary-expression before ‘)’ token
result = (ProductCategory *)(arg1)->getProductCategory();
^
make[2]: *** [CMakeFiles/sale.dir/build.make:83: CMakeFiles/sale.dir/CMakeFiles/sale.dir/salePERL_wrap.cxx.o] Error 1
The above is the Command line Errors that are thrown Below is a the class Product Category
class ProductCategory: public Virtual::Base
{
public:
/**
* @brief Construct a new Product Category object
*
* @param sProductId
*/
ProductCategory(){}
/**
* @brief Construct a new Product Category object
* @param sProductId
*/
ProductCategory(string productID);
/**
* @brief Destructs a Product Category object
*
*/
~ProductCategory(){}
The SWIG Interpretation of the SaleITEM::getProductcategory() is the below code
XS(_wrap_SaleItem_getProductCategory) {
{
Cms::SaleItem *arg1 = (Cms::SaleItem *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
int argvi = 0;
ProductCategory *result = 0 ;
dXSARGS;
if ((items < 1) || (items > 1)) {
SWIG_croak("Usage: SaleItem_getProductCategory(self);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Cms__SaleItem, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SaleItem_getProductCategory" "', argument " "1"" of type '" "Cms::SaleItem *""'");
}
arg1 = reinterpret_cast< Cms::SaleItem * >(argp1);
{
try {
result = (ProductCategory *)(arg1)->getProductCategory();
}
catch (sql::SQLException &) {
croak("SQL exception");
}
}
ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ProductCategory, 0 | 0); argvi++ ;
XSRETURN(argvi);
fail:
SWIG_croak_null();
}