40 #include <google/protobuf/compiler/csharp/csharp_helpers.h>
41 #include <google/protobuf/compiler/csharp/csharp_names.h>
42 #include <google/protobuf/descriptor.pb.h>
43 #include <google/protobuf/io/printer.h>
44 #include <google/protobuf/wire_format.h>
45 #include <google/protobuf/stubs/strutil.h>
47 #include <google/protobuf/compiler/csharp/csharp_field_base.h>
48 #include <google/protobuf/compiler/csharp/csharp_enum_field.h>
49 #include <google/protobuf/compiler/csharp/csharp_map_field.h>
50 #include <google/protobuf/compiler/csharp/csharp_message_field.h>
51 #include <google/protobuf/compiler/csharp/csharp_options.h>
52 #include <google/protobuf/compiler/csharp/csharp_primitive_field.h>
53 #include <google/protobuf/compiler/csharp/csharp_repeated_enum_field.h>
54 #include <google/protobuf/compiler/csharp/csharp_repeated_message_field.h>
55 #include <google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h>
56 #include <google/protobuf/compiler/csharp/csharp_wrapper_field.h>
110 int lastindex = proto_file.find_last_of(
".");
111 return proto_file.substr(0, lastindex);
115 if (
descriptor->options().has_csharp_namespace()) {
116 return descriptor->options().csharp_namespace();
125 int lastslash = proto_file.find_last_of(
"/");
144 bool cap_next_letter,
145 bool preserve_period) {
148 for (
int i = 0;
i <
input.size();
i++) {
150 if (cap_next_letter) {
155 cap_next_letter =
false;
156 }
else if (
'A' <=
input[i] &&
input[i] <=
'Z') {
157 if (i == 0 && !cap_next_letter) {
165 cap_next_letter =
false;
166 }
else if (
'0' <=
input[i] &&
input[i] <=
'9') {
168 cap_next_letter =
true;
170 cap_next_letter =
true;
171 if (
input[i] ==
'.' && preserve_period) {
201 for (
int i = 0;
i <
input.size();
i++) {
230 for (
size_t i = 0;
i <
prefix.size();
i++) {
237 size_t prefix_index, value_index;
238 for (prefix_index = 0, value_index = 0;
239 prefix_index < prefix_to_match.size() && value_index <
value.size();
242 if (
value[value_index] ==
'_') {
252 if (prefix_index < prefix_to_match.size()) {
257 while (value_index <
value.size() &&
value[value_index] ==
'_') {
262 if (value_index ==
value.size()) {
266 return value.substr(value_index);
291 if (
field->type() == FieldDescriptor::Type::TYPE_GROUP &&
299 if (
field->type() == FieldDescriptor::Type::TYPE_GROUP &&
307 if (containing_file != NULL) {
309 for (
int i = 0;
i < containing_file->extension_count();
i++) {
310 field = containing_file->extension(i);
311 if (
field->type() == FieldDescriptor::Type::TYPE_GROUP &&
329 if (
file->package().empty()) {
337 return "global::" +
result;
346 return "global::" +
result;
388 if (property_name ==
descriptor->containing_type()->name()
389 || property_name ==
"Types"
390 || property_name ==
"Descriptor") {
391 property_name +=
"_";
393 return property_name;
398 const bool generate_directories,
402 if (!generate_directories) {
407 if (!base_namespace.empty()) {
413 if (extended_ns.find(base_namespace +
".") != 0) {
414 *
error =
"Namespace " +
ns +
" is not a prefix namespace of base namespace " + base_namespace;
417 namespace_suffix =
ns.substr(base_namespace.length());
418 if (namespace_suffix.find(
".") == 0) {
419 namespace_suffix = namespace_suffix.substr(1);
424 if (!namespace_dir.empty()) {
425 namespace_dir +=
"/";
464 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
468 size_t remaining =
input.size();
469 const unsigned char *src = (
const unsigned char*)
input.c_str();
470 while (remaining > 2) {
501 fdp.SerializeToString(&fdp_bytes);