Message.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Protocol Buffers for Objective C
  2. //
  3. // Copyright 2010 Booyah Inc.
  4. // Copyright 2008 Cyrus Najmabadi
  5. //
  6. // Licensed under the Apache License, Version 2.0 (the "License");
  7. // you may not use this file except in compliance with the License.
  8. // You may obtain a copy of the License at
  9. //
  10. // http://www.apache.org/licenses/LICENSE-2.0
  11. //
  12. // Unless required by applicable law or agreed to in writing, software
  13. // distributed under the License is distributed on an "AS IS" BASIS,
  14. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. // See the License for the specific language governing permissions and
  16. // limitations under the License.
  17. @class PBCodedOutputStream;
  18. @class PBUnknownFieldSet;
  19. @protocol PBMessageBuilder;
  20. /**
  21. * Abstract interface implemented by Protocol Message objects.
  22. *
  23. * @author Cyrus Najmabadi
  24. */
  25. @protocol PBMessage<NSObject>
  26. /**
  27. * Get an instance of the type with all fields set to their default values.
  28. * This may or may not be a singleton. This differs from the
  29. * {@code getDefaultInstance()} method of generated message classes in that
  30. * this method is an abstract method of the {@code Message} interface
  31. * whereas {@code getDefaultInstance()} is a static method of a specific
  32. * class. They return the same thing.
  33. */
  34. - (id<PBMessage>) defaultInstance;
  35. /**
  36. * Get the {@code UnknownFieldSet}
  37. */
  38. - (PBUnknownFieldSet*) unknownFields;
  39. /**
  40. * Get the number of bytes required to encode this message. The result
  41. * is only computed on the first call and memoized after that.
  42. */
  43. - (SInt32) serializedSize;
  44. /**
  45. * Returns true if all required fields in the message and all embedded
  46. * messages are set, false otherwise.
  47. */
  48. - (BOOL) isInitialized;
  49. /**
  50. * Serializes the message and writes it to {@code output}. This does not
  51. * flush or close the stream.
  52. */
  53. - (void) writeToCodedOutputStream:(PBCodedOutputStream*) output;
  54. /**
  55. * Serializes the message and writes it to {@code output}.
  56. */
  57. - (void) writeToOutputStream:(NSOutputStream*) output;
  58. /**
  59. * Serializes the message to a {@code ByteString} and returns it. This is
  60. * just a trivial wrapper around
  61. * {@link #writeTo(CodedOutputStream)}.
  62. */
  63. - (NSData*) data;
  64. /**
  65. * Constructs a new builder for a message of the same type as this message.
  66. */
  67. - (id<PBMessageBuilder>) builder;
  68. /**
  69. * Constructs a builder initialized with the current message. Use this to
  70. * derive a new message from the current one.
  71. */
  72. - (id<PBMessageBuilder>) toBuilder;
  73. /**
  74. * Returns a string description of the message.
  75. */
  76. - (NSString*) description;
  77. @end