Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
a7933e07
Commit
a7933e07
authored
Jun 03, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update docs to mention KJ.
parent
5e4ec0b2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
16 deletions
+19
-16
cxx.md
doc/cxx.md
+19
-16
No files found.
doc/cxx.md
View file @
a7933e07
...
@@ -153,6 +153,13 @@ will not crash. Your exception callback should set some sort of a flag indicati
...
@@ -153,6 +153,13 @@ will not crash. Your exception callback should set some sort of a flag indicati
occurred, and somewhere up the stack you should check for that flag and cancel the operation.
occurred, and somewhere up the stack you should check for that flag and cancel the operation.
See the header
`capnproto/exception.h`
for details on how to register an exception callback.
See the header
`capnproto/exception.h`
for details on how to register an exception callback.
## KJ Library
Cap'n Proto is built on top of a basic utility library called KJ. The two were actually developed
together -- KJ is simply the stuff which is not specific to Cap'n Proto serialization, and may be
useful to others independently of Cap'n Proto. For now, the the two are distributed together. The
name "KJ" has no particular meaning; it was chosen to be short and easy-to-type.
## Generating Code
## Generating Code
To generate C++ code from your
`.capnp`
[
interface definition
](
language.html
)
, run:
To generate C++ code from your
`.capnp`
[
interface definition
](
language.html
)
, run:
...
@@ -386,7 +393,6 @@ using capnproto::DynamicEnum;
...
@@ -386,7 +393,6 @@ using capnproto::DynamicEnum;
using capnproto::DynamicList;
using capnproto::DynamicList;
using capnproto::DynamicUnion;
using capnproto::DynamicUnion;
using capnproto::List;
using capnproto::List;
using capnproto::Maybe;
using capnproto::Schema;
using capnproto::Schema;
using capnproto::StructSchema;
using capnproto::StructSchema;
using capnproto::EnumSchema;
using capnproto::EnumSchema;
...
@@ -482,14 +488,12 @@ void dynamicPrintValue(DynamicValue::Reader value) {
...
@@ -482,14 +488,12 @@ void dynamicPrintValue(DynamicValue::Reader value) {
}
}
case DynamicValue::ENUM: {
case DynamicValue::ENUM: {
auto enumValue = value.as
<DynamicEnum>
();
auto enumValue = value.as
<DynamicEnum>
();
Maybe
<EnumSchema::Enumerant>
enumerant =
KJ_IF_MAYBE(enumerant, enumValue.getEnumerant()) {
enumValue.getEnumerant();
if (enumerant == nullptr) {
// Unknown enum value; output raw number.
std::cout << enumValue.getRaw();
} else {
std::cout <<
std::cout <<
enumerant->getProto().getName().c_str();
enumerant->getProto().getName().c_str();
} else {
// Unknown enum value; output raw number.
std::cout << enumValue.getRaw();
}
}
break;
break;
}
}
...
@@ -513,15 +517,14 @@ void dynamicPrintValue(DynamicValue::Reader value) {
...
@@ -513,15 +517,14 @@ void dynamicPrintValue(DynamicValue::Reader value) {
}
}
case DynamicValue::UNION: {
case DynamicValue::UNION: {
auto unionValue = value.as
<DynamicUnion>
();
auto unionValue = value.as
<DynamicUnion>
();
Maybe
<StructSchema::Member>
tag = unionValue.which();
KJ_IF_MAYBE(tag, unionValue.which()) {
if (tag == nullptr) {
// Unknown union member; must have come from newer
// version of the protocol.
std::cout << "?";
} else {
std::cout
<
<
tag-
>
getProto().getName() << "(";
std::cout
<
<
tag-
>
getProto().getName() << "(";
dynamicPrintValue(unionValue.get());
dynamicPrintValue(unionValue.get());
std::cout << ")";
std::cout << ")";
} else {
// Unknown union member; must have come from newer
// version of the protocol.
std::cout << "?";
}
}
break;
break;
}
}
...
@@ -562,11 +565,11 @@ best reference is the header files. See:
...
@@ -562,11 +565,11 @@ best reference is the header files. See:
capnproto/list.h
capnproto/list.h
capnproto/blob.h
capnproto/blob.h
capnproto/io.h
capnproto/message.h
capnproto/message.h
capnproto/serialize
d
.h
capnproto/serialize.h
capnproto/serialize
d
-packed.h
capnproto/serialize-packed.h
capnproto/schema.h
capnproto/schema.h
capnproto/schema-loader.h
capnproto/dynamic.h
capnproto/dynamic.h
## Lessons Learned from Protocol Buffers
## Lessons Learned from Protocol Buffers
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment