gpt4 book ai didi

thrift - 如何使用带有多个生成器选项的 Thrift Java 代码生成器

转载 作者:行者123 更新时间:2023-12-02 09:03:18 27 4
gpt4 key购买 nike

我正在查看 thirft 代码生成器的文档。它是这样开始的:

Usage: thrift [options] file
Options:
-version Print the compiler version
-o dir Set the output directory for gen-* packages
(default: current directory)
-out dir Set the ouput location for generated files.
(no gen-* folder will be created)
-I dir Add a directory to the list of directories
searched for include directives
-nowarn Suppress all compiler warnings (BAD!)
-strict Strict compiler warnings on
-v[erbose] Verbose mode
-r[ecurse] Also generate included files
-debug Parse debug trace to stdout
--allow-neg-keys Allow negative field keys (Used to preserve protocol
compatibility with older .thrift files)
--allow-64bit-consts Do not print warnings about using 64-bit constants
--gen STR Generate code with a dynamically-registered generator.
STR has the form language[:key1=val1[,key2,[key3=val3]]].
Keys and values are options passed to the generator.
Many options will not require values.

再往下是这样的:

  java (Java):
beans: Members will be private, and setter methods will return void.
private-members: Members will be private, but setter methods will return 'this' like usual.
nocamel: Do not use CamelCase field accessors with beans.
hashcode: Generate quality hashCode methods.
android_legacy: Do not use java.io.IOException(throwable) (available for Android 2.3 and above).
java5: Generate Java 1.5 compliant code (includes android_legacy flag).
sorted_containers:
Use TreeSet/TreeMap instead of HashSet/HashMap as a implementation of set/map.

我得到了这个工作:--gen java:beans,但我不知道如何包含多个选项。我不明白这意味着什么:语言[:key1=val1[,key2,[key3=val3]]]

我尝试过以下方法:“java[:beans,[:hashcode]]”、“java:[beans,hashcode]”“java[:beans,:hashcode]”“java:beans java:hashcode”“java[:beans[,hashcode]]"等

最佳答案

那就是 standard notation ,您会发现大多数命令行实用程序都具有这种功能,甚至是跨平台的。 [ 括号 ] 包含可选参数,括号本身不在命令行中键入。

所以在你的情况下,你想要这样做(示例):

thrift -gen java:beans,private-members,nocamel,java5,sorted_containers  yourfile.thrift

为 java 生成器指定五个附加选项。一些罕见的选项也有值,在这种情况下它将是(编造的例子,不是真实的):

thrift -gen java:option1=foo,option2,option3=bar  yourfile.thrift

它传递三个选项,其中两个具有关联的值。

关于thrift - 如何使用带有多个生成器选项的 Thrift Java 代码生成器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23121808/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com