"Fossies" - the Fresh Open Source Software Archive

Member "protobuf-3.21.1/php/src/Google/Protobuf/Any.php" (27 May 2022, 10710 Bytes) of package /linux/misc/protobuf-all-3.21.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Any.php" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 3.19.4_vs_3.20.1.

    1 <?php
    2 # Generated by the protocol buffer compiler.  DO NOT EDIT!
    3 # source: google/protobuf/any.proto
    4 
    5 namespace Google\Protobuf;
    6 
    7 use Google\Protobuf\Internal\GPBType;
    8 use Google\Protobuf\Internal\RepeatedField;
    9 use Google\Protobuf\Internal\GPBUtil;
   10 
   11 /**
   12  * `Any` contains an arbitrary serialized protocol buffer message along with a
   13  * URL that describes the type of the serialized message.
   14  * Protobuf library provides support to pack/unpack Any values in the form
   15  * of utility functions or additional generated methods of the Any type.
   16  * Example 1: Pack and unpack a message in C++.
   17  *     Foo foo = ...;
   18  *     Any any;
   19  *     any.PackFrom(foo);
   20  *     ...
   21  *     if (any.UnpackTo(&foo)) {
   22  *       ...
   23  *     }
   24  * Example 2: Pack and unpack a message in Java.
   25  *     Foo foo = ...;
   26  *     Any any = Any.pack(foo);
   27  *     ...
   28  *     if (any.is(Foo.class)) {
   29  *       foo = any.unpack(Foo.class);
   30  *     }
   31  * Example 3: Pack and unpack a message in Python.
   32  *     foo = Foo(...)
   33  *     any = Any()
   34  *     any.Pack(foo)
   35  *     ...
   36  *     if any.Is(Foo.DESCRIPTOR):
   37  *       any.Unpack(foo)
   38  *       ...
   39  * Example 4: Pack and unpack a message in Go
   40  *      foo := &pb.Foo{...}
   41  *      any, err := anypb.New(foo)
   42  *      if err != nil {
   43  *        ...
   44  *      }
   45  *      ...
   46  *      foo := &pb.Foo{}
   47  *      if err := any.UnmarshalTo(foo); err != nil {
   48  *        ...
   49  *      }
   50  * The pack methods provided by protobuf library will by default use
   51  * 'type.googleapis.com/full.type.name' as the type URL and the unpack
   52  * methods only use the fully qualified type name after the last '/'
   53  * in the type URL, for example "foo.bar.com/x/y.z" will yield type
   54  * name "y.z".
   55  * JSON
   56  * The JSON representation of an `Any` value uses the regular
   57  * representation of the deserialized, embedded message, with an
   58  * additional field `&#64;type` which contains the type URL. Example:
   59  *     package google.profile;
   60  *     message Person {
   61  *       string first_name = 1;
   62  *       string last_name = 2;
   63  *     }
   64  *     {
   65  *       "&#64;type": "type.googleapis.com/google.profile.Person",
   66  *       "firstName": <string>,
   67  *       "lastName": <string>
   68  *     }
   69  * If the embedded message type is well-known and has a custom JSON
   70  * representation, that representation will be embedded adding a field
   71  * `value` which holds the custom JSON in addition to the `&#64;type`
   72  * field. Example (for message [google.protobuf.Duration][]):
   73  *     {
   74  *       "&#64;type": "type.googleapis.com/google.protobuf.Duration",
   75  *       "value": "1.212s"
   76  *     }
   77  *
   78  * Generated from protobuf message <code>google.protobuf.Any</code>
   79  */
   80 class Any extends \Google\Protobuf\Internal\AnyBase
   81 {
   82     /**
   83      * A URL/resource name that uniquely identifies the type of the serialized
   84      * protocol buffer message. This string must contain at least
   85      * one "/" character. The last segment of the URL's path must represent
   86      * the fully qualified name of the type (as in
   87      * `path/google.protobuf.Duration`). The name should be in a canonical form
   88      * (e.g., leading "." is not accepted).
   89      * In practice, teams usually precompile into the binary all types that they
   90      * expect it to use in the context of Any. However, for URLs which use the
   91      * scheme `http`, `https`, or no scheme, one can optionally set up a type
   92      * server that maps type URLs to message definitions as follows:
   93      * * If no scheme is provided, `https` is assumed.
   94      * * An HTTP GET on the URL must yield a [google.protobuf.Type][]
   95      *   value in binary format, or produce an error.
   96      * * Applications are allowed to cache lookup results based on the
   97      *   URL, or have them precompiled into a binary to avoid any
   98      *   lookup. Therefore, binary compatibility needs to be preserved
   99      *   on changes to types. (Use versioned type names to manage
  100      *   breaking changes.)
  101      * Note: this functionality is not currently available in the official
  102      * protobuf release, and it is not used for type URLs beginning with
  103      * type.googleapis.com.
  104      * Schemes other than `http`, `https` (or the empty scheme) might be
  105      * used with implementation specific semantics.
  106      *
  107      * Generated from protobuf field <code>string type_url = 1;</code>
  108      */
  109     protected $type_url = '';
  110     /**
  111      * Must be a valid serialized protocol buffer of the above specified type.
  112      *
  113      * Generated from protobuf field <code>bytes value = 2;</code>
  114      */
  115     protected $value = '';
  116 
  117     /**
  118      * Constructor.
  119      *
  120      * @param array $data {
  121      *     Optional. Data for populating the Message object.
  122      *
  123      *     @type string $type_url
  124      *           A URL/resource name that uniquely identifies the type of the serialized
  125      *           protocol buffer message. This string must contain at least
  126      *           one "/" character. The last segment of the URL's path must represent
  127      *           the fully qualified name of the type (as in
  128      *           `path/google.protobuf.Duration`). The name should be in a canonical form
  129      *           (e.g., leading "." is not accepted).
  130      *           In practice, teams usually precompile into the binary all types that they
  131      *           expect it to use in the context of Any. However, for URLs which use the
  132      *           scheme `http`, `https`, or no scheme, one can optionally set up a type
  133      *           server that maps type URLs to message definitions as follows:
  134      *           * If no scheme is provided, `https` is assumed.
  135      *           * An HTTP GET on the URL must yield a [google.protobuf.Type][]
  136      *             value in binary format, or produce an error.
  137      *           * Applications are allowed to cache lookup results based on the
  138      *             URL, or have them precompiled into a binary to avoid any
  139      *             lookup. Therefore, binary compatibility needs to be preserved
  140      *             on changes to types. (Use versioned type names to manage
  141      *             breaking changes.)
  142      *           Note: this functionality is not currently available in the official
  143      *           protobuf release, and it is not used for type URLs beginning with
  144      *           type.googleapis.com.
  145      *           Schemes other than `http`, `https` (or the empty scheme) might be
  146      *           used with implementation specific semantics.
  147      *     @type string $value
  148      *           Must be a valid serialized protocol buffer of the above specified type.
  149      * }
  150      */
  151     public function __construct($data = NULL) {
  152         \GPBMetadata\Google\Protobuf\Any::initOnce();
  153         parent::__construct($data);
  154     }
  155 
  156     /**
  157      * A URL/resource name that uniquely identifies the type of the serialized
  158      * protocol buffer message. This string must contain at least
  159      * one "/" character. The last segment of the URL's path must represent
  160      * the fully qualified name of the type (as in
  161      * `path/google.protobuf.Duration`). The name should be in a canonical form
  162      * (e.g., leading "." is not accepted).
  163      * In practice, teams usually precompile into the binary all types that they
  164      * expect it to use in the context of Any. However, for URLs which use the
  165      * scheme `http`, `https`, or no scheme, one can optionally set up a type
  166      * server that maps type URLs to message definitions as follows:
  167      * * If no scheme is provided, `https` is assumed.
  168      * * An HTTP GET on the URL must yield a [google.protobuf.Type][]
  169      *   value in binary format, or produce an error.
  170      * * Applications are allowed to cache lookup results based on the
  171      *   URL, or have them precompiled into a binary to avoid any
  172      *   lookup. Therefore, binary compatibility needs to be preserved
  173      *   on changes to types. (Use versioned type names to manage
  174      *   breaking changes.)
  175      * Note: this functionality is not currently available in the official
  176      * protobuf release, and it is not used for type URLs beginning with
  177      * type.googleapis.com.
  178      * Schemes other than `http`, `https` (or the empty scheme) might be
  179      * used with implementation specific semantics.
  180      *
  181      * Generated from protobuf field <code>string type_url = 1;</code>
  182      * @return string
  183      */
  184     public function getTypeUrl()
  185     {
  186         return $this->type_url;
  187     }
  188 
  189     /**
  190      * A URL/resource name that uniquely identifies the type of the serialized
  191      * protocol buffer message. This string must contain at least
  192      * one "/" character. The last segment of the URL's path must represent
  193      * the fully qualified name of the type (as in
  194      * `path/google.protobuf.Duration`). The name should be in a canonical form
  195      * (e.g., leading "." is not accepted).
  196      * In practice, teams usually precompile into the binary all types that they
  197      * expect it to use in the context of Any. However, for URLs which use the
  198      * scheme `http`, `https`, or no scheme, one can optionally set up a type
  199      * server that maps type URLs to message definitions as follows:
  200      * * If no scheme is provided, `https` is assumed.
  201      * * An HTTP GET on the URL must yield a [google.protobuf.Type][]
  202      *   value in binary format, or produce an error.
  203      * * Applications are allowed to cache lookup results based on the
  204      *   URL, or have them precompiled into a binary to avoid any
  205      *   lookup. Therefore, binary compatibility needs to be preserved
  206      *   on changes to types. (Use versioned type names to manage
  207      *   breaking changes.)
  208      * Note: this functionality is not currently available in the official
  209      * protobuf release, and it is not used for type URLs beginning with
  210      * type.googleapis.com.
  211      * Schemes other than `http`, `https` (or the empty scheme) might be
  212      * used with implementation specific semantics.
  213      *
  214      * Generated from protobuf field <code>string type_url = 1;</code>
  215      * @param string $var
  216      * @return $this
  217      */
  218     public function setTypeUrl($var)
  219     {
  220         GPBUtil::checkString($var, True);
  221         $this->type_url = $var;
  222 
  223         return $this;
  224     }
  225 
  226     /**
  227      * Must be a valid serialized protocol buffer of the above specified type.
  228      *
  229      * Generated from protobuf field <code>bytes value = 2;</code>
  230      * @return string
  231      */
  232     public function getValue()
  233     {
  234         return $this->value;
  235     }
  236 
  237     /**
  238      * Must be a valid serialized protocol buffer of the above specified type.
  239      *
  240      * Generated from protobuf field <code>bytes value = 2;</code>
  241      * @param string $var
  242      * @return $this
  243      */
  244     public function setValue($var)
  245     {
  246         GPBUtil::checkString($var, False);
  247         $this->value = $var;
  248 
  249         return $this;
  250     }
  251 
  252 }
  253