~ubuntu-branches/debian/stretch/protobuf/stretch

« back to all changes in this revision

Viewing changes to src/google/protobuf/generated_message_util.h

  • Committer: Package Import Robot
  • Author(s): Robert S. Edmonds
  • Date: 2014-09-11 22:50:10 UTC
  • mfrom: (10.1.9 experimental)
  • Revision ID: package-import@ubuntu.com-20140911225010-wt4yo9dpc1fzuq5g
Tags: 2.6.0-3
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__
39
39
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__
40
40
 
 
41
#include <assert.h>
41
42
#include <string>
42
43
 
 
44
#include <google/protobuf/stubs/once.h>
 
45
 
43
46
#include <google/protobuf/stubs/common.h>
44
47
namespace google {
 
48
 
45
49
namespace protobuf {
46
50
namespace internal {
47
51
 
 
52
 
48
53
// Annotation for the compiler to emit a deprecation message if a field marked
49
54
// with option 'deprecated=true' is used in the code, or for other things in
50
55
// generated code which are deprecated.
59
64
LIBPROTOBUF_EXPORT double Infinity();
60
65
LIBPROTOBUF_EXPORT double NaN();
61
66
 
62
 
// Constant used for empty default strings.
63
 
LIBPROTOBUF_EXPORT extern const ::std::string kEmptyString;
 
67
// TODO(jieluo): Change to template. We have tried to use template,
 
68
// but it causes net/rpc/python:rpcutil_test fail (the empty string will
 
69
// init twice). It may related to swig. Change to template after we
 
70
// found the solution.
 
71
 
 
72
// Default empty string object. Don't use the pointer directly. Instead, call
 
73
// GetEmptyString() to get the reference.
 
74
LIBPROTOBUF_EXPORT extern const ::std::string* empty_string_;
 
75
LIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_;
 
76
LIBPROTOBUF_EXPORT void InitEmptyString();
 
77
 
 
78
 
 
79
LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() {
 
80
  assert(empty_string_ != NULL);
 
81
  return *empty_string_;
 
82
}
 
83
LIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyString() {
 
84
  ::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString);
 
85
  return GetEmptyStringAlreadyInited();
 
86
}
64
87
 
65
88
// Defined in generated_message_reflection.cc -- not actually part of the lite
66
89
// library.
70
93
// get the declaration from this file.
71
94
LIBPROTOBUF_EXPORT int StringSpaceUsedExcludingSelf(const string& str);
72
95
 
 
96
 
 
97
// True if IsInitialized() is true for all elements of t.  Type is expected
 
98
// to be a RepeatedPtrField<some message type>.  It's useful to have this
 
99
// helper here to keep the protobuf compiler from ever having to emit loops in
 
100
// IsInitialized() methods.  We want the C++ compiler to inline this or not
 
101
// as it sees fit.
 
102
template <class Type> bool AllAreInitialized(const Type& t) {
 
103
  for (int i = t.size(); --i >= 0; ) {
 
104
    if (!t.Get(i).IsInitialized()) return false;
 
105
  }
 
106
  return true;
 
107
}
 
108
 
73
109
}  // namespace internal
74
110
}  // namespace protobuf
75
111