Javacpp-presets: writing my presets,how to write my InfoMap?

Created on 13 Jul 2020  ·  15Comments  ·  Source: bytedeco/javacpp-presets

my .h file like this:class ClassA: public std::unordered_multimap,how to write my InfoMap?
i add Info Like this: infoMap.put(new Info("std::unordered_multimap").pointerTypes("String").define());,but get error info:std::unordered_multimapstd::string,ClassB*,StructA,StructB.java:[18,127] expected

question

All 15 comments

Please start by reading this page: https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes
@saudet
yes,i hava saw this page.
as the below content:

Providing properties for each platform
Including multiple header files
Ignoring attributes and macros
Defining macros and controlling their blocks
Mapping macros to fields or methods
Skipping lines from header files
Specifying names to use in Java
Mapping a declaration to custom code
Redefining the code of a macro
Writing additional code in a helper class
Creating instances of C++ templates
Defining wrappers for basic C++ containers
Using adapters for C++ container types
Dealing with abstract classes and virtual methods

as i know,this page tell us how to map variable or method from c++ to java;
but my case is different,it is a class extends c++ containers, i don't know how to write my java configuration file.
please tell me how to do it.thanks!

Try this:
https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes#defining-wrappers-for-basic-c-containers

@saudet
yes,i have tried it.

infoMap.put(new Info("basic/containers").cppTypes("std::array", "std::bitset", "std::deque", "std::list", "std::map", "std::queue", "std::set", "std::stack", "std::vector", "std::valarray", "std::pair", "std::forward_list""std::priority_queue","std::unordered_map","std::unordered_multimap", "std::unordered_set"));

infoMap.put(new Info("std::unordered_multimap").pointerTypes("StringClassBStructAStructB").define());

as i know,std::unordered_multimap need to be mapped to StringClassBStructAStructB,
but get error as below:
[ERROR] std::unordered_multimap.java:[12,17] '{' expected

below is my .h file info :
class ClassA: public std::unordered_multimap

@saudet
What confuses me is,according to my configuration file,std::unordered_multimap need to be mapped to StringClassBStructAStruct,i should get a java file named StringClassBStructAStructB.java,not std::unordered_multimap.java

You'll need to remove spaces in the template parameters. The parser isn't too robust in that sense:
https://github.com/bytedeco/javacpp/wiki/Mapping-Recipes#creating-instances-of-c-templates

@saudet
i have removed whitespaces between template arguments as below:
infoMap.put(new Info("std::unordered_multimap").pointerTypes("StringClassBStructAStructB").define());

but also get error as below:
[ERROR] std::unordered_multimap.java:[12,17] '{' expected.

You'll need to put the template parameters inside < ... >

@saudet
sorry,i just omitted the '<' and '>'.

in fact,i have removed whitespaces between template arguments as below:
infoMap.put(new Info("std::unordered_multimap").pointerTypes("StringVariHashEqual").define());

and get error as below:
[ERROR] std::unordered_multimap.java:[12,17] '{' expected.

also generate the std::unordered_multimap.java file.

Well, you probably made a typo somewhere. It works with std::map right? If
you want me to debug your code, you'll need to give it to me...

@saudet
it also works with std::unordered_multimap in case of mapping variable.
.h file as below
class A : public std::unordered_multimap ClassB *, StructA, StructB> {

it contains line breaks,Will this affect?

if i want you to help me debug my code,i need to give you java configuration file,are there other files needed?

A simple header file that should work but doesn't work is probably the only thing I need to check this. Thanks

@saudet
header_file.zip
line 71,72

Well, VariableValue isn't defined, but if I give it a C++ class like this:

class VariableValue {
};

Then this works just fine:

infoMap.put(new Info("basic/containers").cppTypes("std::unordered_multimap"));
infoMap.put(new Info("std::unordered_multimap<std::string,modsecurity::VariableValue*,modsecurity::MyHash,modsecurity::MyEqual>").pointerTypes("MyMap").define());

@saudet
wow,it's ok!thank you very much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Neiko2002 picture Neiko2002  ·  32Comments

thunterdb picture thunterdb  ·  37Comments

archenroot picture archenroot  ·  56Comments

mmanco picture mmanco  ·  20Comments

archenroot picture archenroot  ·  29Comments