店播爬取Python脚本

repeated_composite_container.h 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. // Author: anuraag@google.com (Anuraag Agrawal)
  31. // Author: tibell@google.com (Johan Tibell)
  32. #ifndef GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_COMPOSITE_CONTAINER_H__
  33. #define GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_COMPOSITE_CONTAINER_H__
  34. #include <Python.h>
  35. #include <memory>
  36. #include <string>
  37. #include <vector>
  38. #include <google/protobuf/pyext/message.h>
  39. namespace google {
  40. namespace protobuf {
  41. class FieldDescriptor;
  42. class Message;
  43. namespace python {
  44. struct CMessageClass;
  45. // A RepeatedCompositeContainer always has a parent message.
  46. // The parent message also caches reference to items of the container.
  47. typedef struct RepeatedCompositeContainer : public ContainerBase {
  48. // The type used to create new child messages.
  49. CMessageClass* child_message_class;
  50. } RepeatedCompositeContainer;
  51. extern PyTypeObject RepeatedCompositeContainer_Type;
  52. namespace repeated_composite_container {
  53. // Builds a RepeatedCompositeContainer object, from a parent message and a
  54. // field descriptor.
  55. RepeatedCompositeContainer* NewContainer(
  56. CMessage* parent,
  57. const FieldDescriptor* parent_field_descriptor,
  58. CMessageClass *child_message_class);
  59. // Appends a new CMessage to the container and returns it. The
  60. // CMessage is initialized using the content of kwargs.
  61. //
  62. // Returns a new reference if successful; returns NULL and sets an
  63. // exception if unsuccessful.
  64. PyObject* Add(RepeatedCompositeContainer* self,
  65. PyObject* args,
  66. PyObject* kwargs);
  67. // Appends all the CMessages in the input iterator to the container.
  68. //
  69. // Returns None if successful; returns NULL and sets an exception if
  70. // unsuccessful.
  71. PyObject* Extend(RepeatedCompositeContainer* self, PyObject* value);
  72. // Appends a new message to the container for each message in the
  73. // input iterator, merging each data element in. Equivalent to extend.
  74. //
  75. // Returns None if successful; returns NULL and sets an exception if
  76. // unsuccessful.
  77. PyObject* MergeFrom(RepeatedCompositeContainer* self, PyObject* other);
  78. // Accesses messages in the container.
  79. //
  80. // Returns a new reference to the message for an integer parameter.
  81. // Returns a new reference to a list of messages for a slice.
  82. PyObject* Subscript(RepeatedCompositeContainer* self, PyObject* slice);
  83. // Deletes items from the container (cannot be used for assignment).
  84. //
  85. // Returns 0 on success, -1 on failure.
  86. int AssignSubscript(RepeatedCompositeContainer* self,
  87. PyObject* slice,
  88. PyObject* value);
  89. } // namespace repeated_composite_container
  90. } // namespace python
  91. } // namespace protobuf
  92. } // namespace google
  93. #endif // GOOGLE_PROTOBUF_PYTHON_CPP_REPEATED_COMPOSITE_CONTAINER_H__