สมาชิก
CcInfo
CcInfo CcInfo(compilation_context=None, linking_context=None, debug_context=None)
CcInfo
พารามิเตอร์
| พารามิเตอร์ | คำอธิบาย |
|---|---|
compilation_context
|
CompilationContext หรือ None;
ค่าเริ่มต้นคือ NoneCompilationContext
|
linking_context
|
LinkingContext หรือ None;
ค่าเริ่มต้นคือ NoneLinkingContext
|
debug_context
|
DebugContext หรือ None
ค่าเริ่มต้นคือ NoneDebugContext
|
compilation_context
CompilationContext CcInfo.compilation_context
CompilationContext
linking_context
LinkingContext CcInfo.linking_context
LinkingContext
to_json
string CcInfo.to_json()
---incompatible_struct_has_no_methods จะปิดใช้ ใช้ฟีเจอร์นี้เพื่อยืนยันว่าโค้ดของคุณเข้ากันได้กับการนำออกที่กำลังจะเกิดขึ้น สร้างสตริง JSON จากพารามิเตอร์โครงสร้าง วิธีนี้จะใช้ได้ก็ต่อเมื่อองค์ประกอบ struct ทั้งหมด (แบบเรียกซ้ำ) เป็นสตริง, int, บูลีน, struct อื่นๆ, รายการของประเภทเหล่านี้ หรือพจนานุกรมที่มีคีย์สตริงและค่าของประเภทเหล่านี้ ระบบจะหลีกเลี่ยงเครื่องหมายคำพูดและบรรทัดใหม่ในสตริง ตัวอย่าง
struct(key=123).to_json()
# {"key":123}
struct(key=True).to_json()
# {"key":true}
struct(key=[1, 2, 3]).to_json()
# {"key":[1,2,3]}
struct(key='text').to_json()
# {"key":"text"}
struct(key=struct(inner_key='text')).to_json()
# {"key":{"inner_key":"text"}}
struct(key=[struct(inner_key=1), struct(inner_key=2)]).to_json()
# {"key":[{"inner_key":1},{"inner_key":2}]}
struct(key=struct(inner_key=struct(inner_inner_key='text'))).to_json()
# {"key":{"inner_key":{"inner_inner_key":"text"}}}
เลิกใช้งานแล้ว: ให้ใช้ json.encode(x) หรือ json.encode_indent(x) แทน ซึ่งใช้ได้กับค่าอื่นๆ ที่ไม่ใช่โครงสร้าง และไม่ทำให้เนมสเปซของฟิลด์โครงสร้างเสียหาย
to_proto
string CcInfo.to_proto()
---incompatible_struct_has_no_methods จะปิดใช้ ใช้ฟีเจอร์นี้เพื่อยืนยันว่าโค้ดของคุณเข้ากันได้กับการนำออกที่กำลังจะเกิดขึ้น สร้างข้อความจากพารามิเตอร์ struct วิธีนี้จะใช้ได้ก็ต่อเมื่อองค์ประกอบ struct ทั้งหมด (แบบเรียกซ้ำ) เป็นสตริง จำนวนเต็ม บูลีน struct อื่นๆ หรือพจนานุกรม หรือรายการของประเภทเหล่านี้ ระบบจะหลีกเลี่ยงเครื่องหมายคำพูดและบรรทัดใหม่ในสตริง ระบบจะวนซ้ำคีย์ Struct ตามลำดับที่จัดเรียง ตัวอย่าง
struct(key=123).to_proto()
# key: 123
struct(key=True).to_proto()
# key: true
struct(key=[1, 2, 3]).to_proto()
# key: 1
# key: 2
# key: 3
struct(key='text').to_proto()
# key: "text"
struct(key=struct(inner_key='text')).to_proto()
# key {
# inner_key: "text"
# }
struct(key=[struct(inner_key=1), struct(inner_key=2)]).to_proto()
# key {
# inner_key: 1
# }
# key {
# inner_key: 2
# }
struct(key=struct(inner_key=struct(inner_inner_key='text'))).to_proto()
# key {
# inner_key {
# inner_inner_key: "text"
# }
# }
struct(foo={4: 3, 2: 1}).to_proto()
# foo: {
# key: 4
# value: 3
# }
# foo: {
# key: 2
# value: 1
# }
เลิกใช้งานแล้ว: ใช้ proto.encode_text(x) แทน