github.com/cloudwego/dynamicgo@v0.2.6-0.20240519101509-707f41b6b834/proto/generic/README.md (about)

     1  <!-- Code generated by gomarkdoc. DO NOT EDIT -->
     2  
     3  # generic
     4  
     5  ```go
     6  import "github.com/cloudwego/dynamicgo/proto/generic"
     7  ```
     8  
     9  ## Index
    10  
    11  - [generic](#generic)
    12    - [Index](#index)
    13    - [Variables](#variables)
    14    - [func FreeBytesToPool](#func-freebytestopool)
    15    - [func FreePathNode](#func-freepathnode)
    16    - [func NewBytesFromPool](#func-newbytesfrompool)
    17    - [type Node](#type-node)
    18      - [func NewComplexNode](#func-newcomplexnode)
    19      - [func NewNode](#func-newnode)
    20      - [func NewNodeBool](#func-newnodebool)
    21      - [func NewNodeByte](#func-newnodebyte)
    22      - [func NewNodeBytes](#func-newnodebytes)
    23      - [func NewNodeDouble](#func-newnodedouble)
    24      - [func NewNodeEnum](#func-newnodeenum)
    25      - [func NewNodeFixed32](#func-newnodefixed32)
    26      - [func NewNodeFixed64](#func-newnodefixed64)
    27      - [func NewNodeFloat](#func-newnodefloat)
    28      - [func NewNodeInt32](#func-newnodeint32)
    29      - [func NewNodeInt64](#func-newnodeint64)
    30      - [func NewNodeSfixed32](#func-newnodesfixed32)
    31      - [func NewNodeSfixed64](#func-newnodesfixed64)
    32      - [func NewNodeSint32](#func-newnodesint32)
    33      - [func NewNodeSint64](#func-newnodesint64)
    34      - [func NewNodeString](#func-newnodestring)
    35      - [func NewNodeUint32](#func-newnodeuint32)
    36      - [func NewNodeUint64](#func-newnodeuint64)
    37      - [func (Node) Binary](#func-node-binary)
    38      - [func (Node) Bool](#func-node-bool)
    39      - [func (\*Node) Check](#func-node-check)
    40      - [func (Node) Children](#func-node-children)
    41      - [func (Node) ElemType](#func-node-elemtype)
    42      - [func (Node) ErrCode](#func-node-errcode)
    43      - [func (Node) Error](#func-node-error)
    44      - [func (Node) Field](#func-node-field)
    45      - [func (Node) Fields](#func-node-fields)
    46      - [func (Node) Float64](#func-node-float64)
    47      - [func (Node) Fork](#func-node-fork)
    48      - [func (Node) GetByInt](#func-node-getbyint)
    49      - [func (Node) GetByStr](#func-node-getbystr)
    50      - [func (Node) Gets](#func-node-gets)
    51      - [func (Node) Index](#func-node-index)
    52      - [func (Node) Indexes](#func-node-indexes)
    53      - [func (Node) Int](#func-node-int)
    54      - [func (Node) IsErrNotFound](#func-node-iserrnotfound)
    55      - [func (Node) IsError](#func-node-iserror)
    56      - [func (Node) IsUnKnown](#func-node-isunknown)
    57      - [func (Node) KeyType](#func-node-keytype)
    58      - [func (Node) Len](#func-node-len)
    59      - [func (Node) Raw](#func-node-raw)
    60      - [func (\*Node) SetElemType](#func-node-setelemtype)
    61      - [func (\*Node) SetKeyType](#func-node-setkeytype)
    62      - [func (Node) String](#func-node-string)
    63      - [func (Node) Type](#func-node-type)
    64      - [func (Node) Uint](#func-node-uint)
    65    - [type Options](#type-options)
    66    - [type Path](#type-path)
    67      - [func NewPathFieldId](#func-newpathfieldid)
    68      - [func NewPathFieldName](#func-newpathfieldname)
    69      - [func NewPathIndex](#func-newpathindex)
    70      - [func NewPathIntKey](#func-newpathintkey)
    71      - [func NewPathStrKey](#func-newpathstrkey)
    72      - [func (Path) Id](#func-path-id)
    73      - [func (Path) Int](#func-path-int)
    74      - [func (Path) Str](#func-path-str)
    75      - [func (Path) ToRaw](#func-path-toraw)
    76      - [func (Path) Type](#func-path-type)
    77      - [func (Path) Value](#func-path-value)
    78    - [type PathNode](#type-pathnode)
    79      - [func NewPathNode](#func-newpathnode)
    80      - [func (PathNode) CopyTo](#func-pathnode-copyto)
    81      - [func (\*PathNode) Load](#func-pathnode-load)
    82      - [func (PathNode) Marshal](#func-pathnode-marshal)
    83      - [func (\*PathNode) ResetAll](#func-pathnode-resetall)
    84      - [func (\*PathNode) ResetValue](#func-pathnode-resetvalue)
    85    - [type PathType](#type-pathtype)
    86    - [type Value](#type-value)
    87      - [func NewComplexValue](#func-newcomplexvalue)
    88      - [func NewRootValue](#func-newrootvalue)
    89      - [func NewValue](#func-newvalue)
    90      - [func (Value) Field](#func-value-field)
    91      - [func (Value) FieldByName](#func-value-fieldbyname)
    92      - [func (Value) Fields](#func-value-fields)
    93      - [func (Value) Fork](#func-value-fork)
    94      - [func (Value) GetByInt](#func-value-getbyint)
    95      - [func (Value) GetByPath](#func-value-getbypath)
    96      - [func (Value) GetByPathWithAddress](#func-value-getbypathwithaddress)
    97      - [func (Value) GetByStr](#func-value-getbystr)
    98      - [func (Value) GetMany](#func-value-getmany)
    99      - [func (Value) Index](#func-value-index)
   100      - [func (Value) IntMap](#func-value-intmap)
   101      - [func (Value) Interface](#func-value-interface)
   102      - [func (Value) List](#func-value-list)
   103      - [func (Value) MarshalTo](#func-value-marshalto)
   104      - [func (\*Value) SetByPath](#func-value-setbypath)
   105      - [func (\*Value) SetMany](#func-value-setmany)
   106      - [func (Value) StrMap](#func-value-strmap)
   107      - [func (\*Value) UnsetByPath](#func-value-unsetbypath)
   108  
   109  
   110  ## Variables
   111  
   112  <a name="UseNativeSkipForGet"></a>
   113  
   114  ```go
   115  var (
   116      // UseNativeSkipForGet indicates to use native.Skip (instead of go.Skip) method to skip proto value
   117      // This only works for single-value searching API like GetByInt()/GetByRaw()/GetByStr()/Field()/Index()/GetByPath() methods.
   118      UseNativeSkipForGet = false
   119  
   120      // DefaultNodeSliceCap is the default capacity of a Node or NodePath slice
   121      // Usually, a Node or NodePath slice is used to store intermediate or consequential elements of a generic API like Children()|Interface()|SetMany()
   122      DefaultNodeSliceCap = 16
   123      DefaultTagSliceCap  = 8
   124  )
   125  ```
   126  
   127  <a name="StoreChildrenByIdShreshold"></a>
   128  
   129  ```go
   130  var (
   131      // StoreChildrenByIdShreshold is the maximum id to store children node by id.
   132      StoreChildrenByIdShreshold = 256
   133  
   134      // StoreChildrenByIdShreshold is the minimum id to store children node by hash.
   135      StoreChildrenByIntHashShreshold = DefaultNodeSliceCap
   136  )
   137  ```
   138  
   139  <a name="FreeBytesToPool"></a>
   140  ## func [FreeBytesToPool](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L42>)
   141  
   142  ```go
   143  func FreeBytesToPool(b []byte)
   144  ```
   145  
   146  
   147  
   148  <a name="FreePathNode"></a>
   149  ## func [FreePathNode](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L252>)
   150  
   151  ```go
   152  func FreePathNode(p *PathNode)
   153  ```
   154  
   155  FreePathNode put a PathNode back to memory pool
   156  
   157  <a name="NewBytesFromPool"></a>
   158  ## func [NewBytesFromPool](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L38>)
   159  
   160  ```go
   161  func NewBytesFromPool() []byte
   162  ```
   163  
   164  
   165  
   166  <a name="Node"></a>
   167  ## type [Node](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L14-L21>)
   168  
   169  
   170  
   171  ```go
   172  type Node struct {
   173      // contains filtered or unexported fields
   174  }
   175  ```
   176  
   177  <a name="NewComplexNode"></a>
   178  ### func [NewComplexNode](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L317>)
   179  
   180  ```go
   181  func NewComplexNode(t proto.Type, et proto.Type, kt proto.Type, src []byte) (ret Node)
   182  ```
   183  
   184  NewComplexNode can deal with all the types, only if the src is a valid byte slice
   185  
   186  <a name="NewNode"></a>
   187  ### func [NewNode](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L205>)
   188  
   189  ```go
   190  func NewNode(t proto.Type, src []byte) Node
   191  ```
   192  
   193  NewNode method: creates a new node from a byte slice
   194  
   195  <a name="NewNodeBool"></a>
   196  ### func [NewNodeBool](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L214>)
   197  
   198  ```go
   199  func NewNodeBool(val bool) Node
   200  ```
   201  
   202  
   203  
   204  <a name="NewNodeByte"></a>
   205  ### func [NewNodeByte](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L220>)
   206  
   207  ```go
   208  func NewNodeByte(val byte) Node
   209  ```
   210  
   211  
   212  
   213  <a name="NewNodeBytes"></a>
   214  ### func [NewNodeBytes](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L310>)
   215  
   216  ```go
   217  func NewNodeBytes(val []byte) Node
   218  ```
   219  
   220  
   221  
   222  <a name="NewNodeDouble"></a>
   223  ### func [NewNodeDouble](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L298>)
   224  
   225  ```go
   226  func NewNodeDouble(val float64) Node
   227  ```
   228  
   229  
   230  
   231  <a name="NewNodeEnum"></a>
   232  ### func [NewNodeEnum](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L226>)
   233  
   234  ```go
   235  func NewNodeEnum(val int32) Node
   236  ```
   237  
   238  
   239  
   240  <a name="NewNodeFixed32"></a>
   241  ### func [NewNodeFixed32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L250>)
   242  
   243  ```go
   244  func NewNodeFixed32(val uint32) Node
   245  ```
   246  
   247  
   248  
   249  <a name="NewNodeFixed64"></a>
   250  ### func [NewNodeFixed64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L280>)
   251  
   252  ```go
   253  func NewNodeFixed64(val uint64) Node
   254  ```
   255  
   256  
   257  
   258  <a name="NewNodeFloat"></a>
   259  ### func [NewNodeFloat](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L292>)
   260  
   261  ```go
   262  func NewNodeFloat(val float32) Node
   263  ```
   264  
   265  
   266  
   267  <a name="NewNodeInt32"></a>
   268  ### func [NewNodeInt32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L232>)
   269  
   270  ```go
   271  func NewNodeInt32(val int32) Node
   272  ```
   273  
   274  
   275  
   276  <a name="NewNodeInt64"></a>
   277  ### func [NewNodeInt64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L262>)
   278  
   279  ```go
   280  func NewNodeInt64(val int64) Node
   281  ```
   282  
   283  
   284  
   285  <a name="NewNodeSfixed32"></a>
   286  ### func [NewNodeSfixed32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L256>)
   287  
   288  ```go
   289  func NewNodeSfixed32(val int32) Node
   290  ```
   291  
   292  
   293  
   294  <a name="NewNodeSfixed64"></a>
   295  ### func [NewNodeSfixed64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L286>)
   296  
   297  ```go
   298  func NewNodeSfixed64(val int64) Node
   299  ```
   300  
   301  
   302  
   303  <a name="NewNodeSint32"></a>
   304  ### func [NewNodeSint32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L238>)
   305  
   306  ```go
   307  func NewNodeSint32(val int32) Node
   308  ```
   309  
   310  
   311  
   312  <a name="NewNodeSint64"></a>
   313  ### func [NewNodeSint64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L268>)
   314  
   315  ```go
   316  func NewNodeSint64(val int64) Node
   317  ```
   318  
   319  
   320  
   321  <a name="NewNodeString"></a>
   322  ### func [NewNodeString](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L304>)
   323  
   324  ```go
   325  func NewNodeString(val string) Node
   326  ```
   327  
   328  
   329  
   330  <a name="NewNodeUint32"></a>
   331  ### func [NewNodeUint32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L244>)
   332  
   333  ```go
   334  func NewNodeUint32(val uint32) Node
   335  ```
   336  
   337  
   338  
   339  <a name="NewNodeUint64"></a>
   340  ### func [NewNodeUint64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L274>)
   341  
   342  ```go
   343  func NewNodeUint64(val uint64) Node
   344  ```
   345  
   346  
   347  
   348  <a name="Node.Binary"></a>
   349  ### func (Node) [Binary](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/cast.go#L168>)
   350  
   351  ```go
   352  func (self Node) Binary() ([]byte, error)
   353  ```
   354  
   355  Binary returns the bytes value contained by a BYTE node
   356  
   357  <a name="Node.Bool"></a>
   358  ### func (Node) [Bool](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/cast.go#L52>)
   359  
   360  ```go
   361  func (self Node) Bool() (bool, error)
   362  ```
   363  
   364  Bool returns the bool value contained by a BOOL node
   365  
   366  <a name="Node.Check"></a>
   367  ### func (*Node) [Check](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/error.go#L136>)
   368  
   369  ```go
   370  func (self *Node) Check() error
   371  ```
   372  
   373  Check checks if it is a ERROR node and returns corresponding error
   374  
   375  <a name="Node.Children"></a>
   376  ### func (Node) [Children](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L348>)
   377  
   378  ```go
   379  func (self Node) Children(out *[]PathNode, recurse bool, opts *Options, desc *proto.TypeDescriptor) (err error)
   380  ```
   381  
   382  returns all the children of a node, when recurse is false, it switch to lazyload mode, only direct children are returned
   383  
   384  <a name="Node.ElemType"></a>
   385  ### func (Node) [ElemType](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L38>)
   386  
   387  ```go
   388  func (self Node) ElemType() proto.Type
   389  ```
   390  
   391  ElemType returns the thrift type of a LIST/MAP node's element
   392  
   393  <a name="Node.ErrCode"></a>
   394  ### func (Node) [ErrCode](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/error.go#L128>)
   395  
   396  ```go
   397  func (self Node) ErrCode() meta.ErrCode
   398  ```
   399  
   400  ErrCode return the meta.ErrCode of a ERROR node
   401  
   402  <a name="Node.Error"></a>
   403  ### func (Node) [Error](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/error.go#L147>)
   404  
   405  ```go
   406  func (self Node) Error() string
   407  ```
   408  
   409  Error return error message if it is a ERROR node
   410  
   411  <a name="Node.Field"></a>
   412  ### func (Node) [Field](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L481>)
   413  
   414  ```go
   415  func (self Node) Field(id proto.FieldNumber, rootLayer bool, msgDesc *proto.MessageDescriptor) (v Node, f *proto.FieldDescriptor)
   416  ```
   417  
   418  
   419  
   420  <a name="Node.Fields"></a>
   421  ### func (Node) [Fields](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L542>)
   422  
   423  ```go
   424  func (self Node) Fields(ids []PathNode, rootLayer bool, msgDesc *proto.MessageDescriptor, opts *Options) error
   425  ```
   426  
   427  
   428  
   429  <a name="Node.Float64"></a>
   430  ### func (Node) [Float64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/cast.go#L132>)
   431  
   432  ```go
   433  func (self Node) Float64() (float64, error)
   434  ```
   435  
   436  Float64 returns the float64 value contained by a DOUBLE node
   437  
   438  <a name="Node.Fork"></a>
   439  ### func (Node) [Fork](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L24>)
   440  
   441  ```go
   442  func (self Node) Fork() Node
   443  ```
   444  
   445  Fork forks the node to a new node, copy underlying data as well
   446  
   447  <a name="Node.GetByInt"></a>
   448  ### func (Node) [GetByInt](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L451>)
   449  
   450  ```go
   451  func (self Node) GetByInt(key int) (v Node)
   452  ```
   453  
   454  Get int key of a MAP node
   455  
   456  <a name="Node.GetByStr"></a>
   457  ### func (Node) [GetByStr](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L419>)
   458  
   459  ```go
   460  func (self Node) GetByStr(key string) (v Node)
   461  ```
   462  
   463  Get string key of a MAP node
   464  
   465  <a name="Node.Gets"></a>
   466  ### func (Node) [Gets](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L674>)
   467  
   468  ```go
   469  func (self Node) Gets(keys []PathNode, opts *Options) error
   470  ```
   471  
   472  
   473  
   474  <a name="Node.Index"></a>
   475  ### func (Node) [Index](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L373>)
   476  
   477  ```go
   478  func (self Node) Index(idx int) (v Node)
   479  ```
   480  
   481  Get idx element of a LIST node
   482  
   483  <a name="Node.Indexes"></a>
   484  ### func (Node) [Indexes](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L611>)
   485  
   486  ```go
   487  func (self Node) Indexes(ins []PathNode, opts *Options) error
   488  ```
   489  
   490  
   491  
   492  <a name="Node.Int"></a>
   493  ### func (Node) [Int](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/cast.go#L98>)
   494  
   495  ```go
   496  func (self Node) Int() (int, error)
   497  ```
   498  
   499  Int returns the int value contained by a INT32/SINT32/SFIX32/INT64/SINT64/SFIX64 node
   500  
   501  <a name="Node.IsErrNotFound"></a>
   502  ### func (Node) [IsErrNotFound](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/error.go#L119>)
   503  
   504  ```go
   505  func (self Node) IsErrNotFound() bool
   506  ```
   507  
   508  IsErrorNotFound tells if the node is not-found-data error
   509  
   510  <a name="Node.IsError"></a>
   511  ### func (Node) [IsError](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/error.go#L114>)
   512  
   513  ```go
   514  func (self Node) IsError() bool
   515  ```
   516  
   517  IsEmtpy tells if the node is PROTOBUF.ERROR
   518  
   519  <a name="Node.IsUnKnown"></a>
   520  ### func (Node) [IsUnKnown](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/error.go#L109>)
   521  
   522  ```go
   523  func (self Node) IsUnKnown() bool
   524  ```
   525  
   526  IsEmpty tells if the node is proto.UNKNOWN
   527  
   528  <a name="Node.KeyType"></a>
   529  ### func (Node) [KeyType](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L43>)
   530  
   531  ```go
   532  func (self Node) KeyType() proto.Type
   533  ```
   534  
   535  KeyType returns the thrift type of a MAP node's key
   536  
   537  <a name="Node.Len"></a>
   538  ### func (Node) [Len](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/cast.go#L23>)
   539  
   540  ```go
   541  func (self Node) Len() (int, error)
   542  ```
   543  
   544  Len returns the element count of container-kind type (LIST/MAP)
   545  
   546  <a name="Node.Raw"></a>
   547  ### func (Node) [Raw](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/cast.go#L40>)
   548  
   549  ```go
   550  func (self Node) Raw() []byte
   551  ```
   552  
   553  Return its underlying raw data
   554  
   555  <a name="Node.SetElemType"></a>
   556  ### func (*Node) [SetElemType](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L95>)
   557  
   558  ```go
   559  func (self *Node) SetElemType(et proto.Type)
   560  ```
   561  
   562  
   563  
   564  <a name="Node.SetKeyType"></a>
   565  ### func (*Node) [SetKeyType](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L99>)
   566  
   567  ```go
   568  func (self *Node) SetKeyType(kt proto.Type)
   569  ```
   570  
   571  
   572  
   573  <a name="Node.String"></a>
   574  ### func (Node) [String](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/cast.go#L150>)
   575  
   576  ```go
   577  func (self Node) String() (string, error)
   578  ```
   579  
   580  String returns the string value contianed by a STRING node
   581  
   582  <a name="Node.Type"></a>
   583  ### func (Node) [Type](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/node.go#L33>)
   584  
   585  ```go
   586  func (self Node) Type() proto.Type
   587  ```
   588  
   589  Type returns the proto type of the node
   590  
   591  <a name="Node.Uint"></a>
   592  ### func (Node) [Uint](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/cast.go#L70>)
   593  
   594  ```go
   595  func (self Node) Uint() (uint, error)
   596  ```
   597  
   598  Uint returns the uint value contained by a UINT32/UINT64/FIX32/FIX64 node
   599  
   600  <a name="Options"></a>
   601  ## type [Options](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/option.go#L37-L63>)
   602  
   603  Opions for generic.Node
   604  
   605  ```go
   606  type Options struct {
   607      // DisallowUnknown indicates to report error when read unknown fields.
   608      DisallowUnknown bool
   609  
   610      // MapStructById indicates to use FieldId instead of int as map key instead of when call Node.Interface() on STRUCT type.
   611      MapStructById bool
   612  
   613      // ClearDirtyValues indicates one multi-query (includeing
   614      // Fields()/GetMany()/Gets()/Indexies()) to clear out all nodes
   615      // in passed []PathNode first
   616      ClearDirtyValues bool
   617  
   618      // CastStringAsBinary indicates to cast STRING type to []byte when call Node.Interface()/Map().
   619      CastStringAsBinary bool
   620  
   621      WriteDefault bool // not implemented
   622  
   623      UseNativeSkip bool // not implemented
   624  
   625      NotScanParentNode bool // not implemented
   626  
   627      StoreChildrenById bool // not implemented
   628  
   629      StoreChildrenByHash bool // not implemented
   630  
   631      IterateStructByName bool // not implemented
   632  }
   633  ```
   634  
   635  <a name="Path"></a>
   636  ## type [Path](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L46-L50>)
   637  
   638  Path represents the relative position of a sub node in a complex parent node
   639  
   640  ```go
   641  type Path struct {
   642      // contains filtered or unexported fields
   643  }
   644  ```
   645  
   646  <a name="NewPathFieldId"></a>
   647  ### func [NewPathFieldId](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L161>)
   648  
   649  ```go
   650  func NewPathFieldId(id proto.FieldNumber) Path
   651  ```
   652  
   653  NewPathFieldId creates a PathFieldId path
   654  
   655  <a name="NewPathFieldName"></a>
   656  ### func [NewPathFieldName](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L169>)
   657  
   658  ```go
   659  func NewPathFieldName(name string) Path
   660  ```
   661  
   662  NewPathFieldName creates a PathFieldName path
   663  
   664  <a name="NewPathIndex"></a>
   665  ### func [NewPathIndex](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L178>)
   666  
   667  ```go
   668  func NewPathIndex(index int) Path
   669  ```
   670  
   671  NewPathIndex creates a PathIndex path
   672  
   673  <a name="NewPathIntKey"></a>
   674  ### func [NewPathIntKey](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L195>)
   675  
   676  ```go
   677  func NewPathIntKey(key int) Path
   678  ```
   679  
   680  NewPathIntKey creates a PathIntKey path
   681  
   682  <a name="NewPathStrKey"></a>
   683  ### func [NewPathStrKey](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L186>)
   684  
   685  ```go
   686  func NewPathStrKey(key string) Path
   687  ```
   688  
   689  NewPathStrKey creates a PathStrKey path
   690  
   691  <a name="Path.Id"></a>
   692  ### func (Path) [Id](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L81>)
   693  
   694  ```go
   695  func (self Path) Id() proto.FieldNumber
   696  ```
   697  
   698  Id returns the field id of a PathFieldId path
   699  
   700  <a name="Path.Int"></a>
   701  ### func (Path) [Int](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L67>)
   702  
   703  ```go
   704  func (self Path) Int() int
   705  ```
   706  
   707  Int returns the int value of a PathIndexPathIntKey path
   708  
   709  <a name="Path.Str"></a>
   710  ### func (Path) [Str](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L53>)
   711  
   712  ```go
   713  func (self Path) Str() string
   714  ```
   715  
   716  Str returns the string value of a PathFieldNamePathStrKey path
   717  
   718  <a name="Path.ToRaw"></a>
   719  ### func (Path) [ToRaw](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L114>)
   720  
   721  ```go
   722  func (self Path) ToRaw(t proto.Type) []byte
   723  ```
   724  
   725  ToRaw converts underlying value to protobuf-encoded bytes
   726  
   727  <a name="Path.Type"></a>
   728  ### func (Path) [Type](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L95>)
   729  
   730  ```go
   731  func (self Path) Type() PathType
   732  ```
   733  
   734  Type returns the type of a Path
   735  
   736  <a name="Path.Value"></a>
   737  ### func (Path) [Value](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L100>)
   738  
   739  ```go
   740  func (self Path) Value() interface{}
   741  ```
   742  
   743  Value returns the equivalent go interface of a Path
   744  
   745  <a name="PathNode"></a>
   746  ## type [PathNode](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L203-L207>)
   747  
   748  PathNode is a three node of DOM tree
   749  
   750  ```go
   751  type PathNode struct {
   752      Path
   753      Node
   754      Next []PathNode
   755  }
   756  ```
   757  
   758  <a name="NewPathNode"></a>
   759  ### func [NewPathNode](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L216>)
   760  
   761  ```go
   762  func NewPathNode() *PathNode
   763  ```
   764  
   765  NewPathNode get a new PathNode from memory pool
   766  
   767  <a name="PathNode.CopyTo"></a>
   768  ### func (PathNode) [CopyTo](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L221>)
   769  
   770  ```go
   771  func (self PathNode) CopyTo(to *PathNode)
   772  ```
   773  
   774  CopyTo deeply copy self and its children to a PathNode
   775  
   776  <a name="PathNode.Load"></a>
   777  ### func (*PathNode) [Load](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L563>)
   778  
   779  ```go
   780  func (self *PathNode) Load(recurse bool, opts *Options, desc *proto.TypeDescriptor) error
   781  ```
   782  
   783  Load loads self's all children ( and children's children if recurse is true) into self.Next, no matter whether self.Next is empty or set before (will be reset). NOTICE: if opts.NotScanParentNode is true, the parent nodes (PathNode.Node) of complex (map/list/struct) type won't be assgined data
   784  
   785  <a name="PathNode.Marshal"></a>
   786  ### func (PathNode) [Marshal](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L639>)
   787  
   788  ```go
   789  func (self PathNode) Marshal(opt *Options) (out []byte, err error)
   790  ```
   791  
   792  
   793  
   794  <a name="PathNode.ResetAll"></a>
   795  ### func (*PathNode) [ResetAll](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L242>)
   796  
   797  ```go
   798  func (self *PathNode) ResetAll()
   799  ```
   800  
   801  ResetAll resets self and its children, including path and node both
   802  
   803  <a name="PathNode.ResetValue"></a>
   804  ### func (*PathNode) [ResetValue](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L234>)
   805  
   806  ```go
   807  func (self *PathNode) ResetValue()
   808  ```
   809  
   810  ResetValue resets self's node and its children's node
   811  
   812  <a name="PathType"></a>
   813  ## type [PathType](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/path.go#L21>)
   814  
   815  PathType is the type of path
   816  
   817  ```go
   818  type PathType uint8
   819  ```
   820  
   821  <a name="PathFieldId"></a>
   822  
   823  ```go
   824  const (
   825      // PathFieldId represents a field id of MESSAGE type
   826      PathFieldId PathType = 1 + iota
   827  
   828      // PathFieldName represents a field name of MESSAGE type
   829      // NOTICE: it is only supported by Value
   830      PathFieldName
   831  
   832      // PathIndex represents a index of LIST type
   833      PathIndex
   834  
   835      // Path represents a string key of MAP type
   836      PathStrKey
   837  
   838      // Path represents a int key of MAP type
   839      PathIntKey
   840  
   841      // Path represents a raw-bytes key of MAP type
   842      // It is usually used for neither-string-nor-integer type key
   843      PathBinKey // not supported in protobuf MapKeyDescriptor
   844  )
   845  ```
   846  
   847  <a name="Value"></a>
   848  ## type [Value](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L17-L21>)
   849  
   850  
   851  
   852  ```go
   853  type Value struct {
   854      Node
   855      Desc   *proto.TypeDescriptor
   856      IsRoot bool
   857  }
   858  ```
   859  
   860  <details><summary>Example (-arshal All)</summary>
   861  <p>
   862  
   863  
   864  
   865  ```go
   866  desc := getExample2Desc()
   867  data := getExample2Data()
   868  v := NewRootValue(desc, data)
   869  p := PathNode{
   870  	Node: v.Node,
   871  }
   872  
   873  if err := p.Load(true, opts, desc); err != nil {
   874  	panic(err)
   875  }
   876  
   877  out, err := p.Marshal(opts)
   878  if err != nil {
   879  	panic(err)
   880  }
   881  
   882  msg, err := NewRootValue(desc, out).Interface(opts)
   883  if err != nil {
   884  	panic(err)
   885  }
   886  fmt.Printf("%#v", msg)
   887  ```
   888  
   889  </p>
   890  </details>
   891  
   892  <a name="NewComplexValue"></a>
   893  ### func [NewComplexValue](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L64>)
   894  
   895  ```go
   896  func NewComplexValue(desc *proto.TypeDescriptor, src []byte) Value
   897  ```
   898  
   899  only for LIST/MAP parent Node
   900  
   901  <a name="NewRootValue"></a>
   902  ### func [NewRootValue](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L47>)
   903  
   904  ```go
   905  func NewRootValue(desc *proto.TypeDescriptor, src []byte) Value
   906  ```
   907  
   908  
   909  
   910  <a name="NewValue"></a>
   911  ### func [NewValue](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L56>)
   912  
   913  ```go
   914  func NewValue(desc *proto.TypeDescriptor, src []byte) Value
   915  ```
   916  
   917  only for basic Node
   918  
   919  <a name="Value.Field"></a>
   920  ### func (Value) [Field](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L1006>)
   921  
   922  ```go
   923  func (self Value) Field(id proto.FieldNumber) (v Value)
   924  ```
   925  
   926  Field returns a sub node at the given field id from a MESSAGE value.
   927  
   928  <a name="Value.FieldByName"></a>
   929  ### func (Value) [FieldByName](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L948>)
   930  
   931  ```go
   932  func (self Value) FieldByName(name string) (v Value)
   933  ```
   934  
   935  FieldByName returns a sub node at the given field name from a MESSAGE value.
   936  
   937  <a name="Value.Fields"></a>
   938  ### func (Value) [Fields](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L1045>)
   939  
   940  ```go
   941  func (self Value) Fields(ids []PathNode, opts *Options) error
   942  ```
   943  
   944  
   945  
   946  <a name="Value.Fork"></a>
   947  ### func (Value) [Fork](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L86>)
   948  
   949  ```go
   950  func (self Value) Fork() Value
   951  ```
   952  
   953  NewValueFromNode copy both Node and TypeDescriptor from another Value.
   954  
   955  <a name="Value.GetByInt"></a>
   956  ### func (Value) [GetByInt](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L928>)
   957  
   958  ```go
   959  func (self Value) GetByInt(key int) (v Value)
   960  ```
   961  
   962  GetByInt returns a sub node at the given key from a MAP value.
   963  
   964  <a name="Value.GetByPath"></a>
   965  ### func (Value) [GetByPath](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L286>)
   966  
   967  ```go
   968  func (self Value) GetByPath(pathes ...Path) Value
   969  ```
   970  
   971  
   972  
   973  <a name="Value.GetByPathWithAddress"></a>
   974  ### func (Value) [GetByPathWithAddress](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L291>)
   975  
   976  ```go
   977  func (self Value) GetByPathWithAddress(pathes ...Path) (Value, []int)
   978  ```
   979  
   980  
   981  
   982  <a name="Value.GetByStr"></a>
   983  ### func (Value) [GetByStr](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L918>)
   984  
   985  ```go
   986  func (self Value) GetByStr(key string) (v Value)
   987  ```
   988  
   989  GetByInt returns a sub node at the given key from a MAP value.
   990  
   991  <a name="Value.GetMany"></a>
   992  ### func (Value) [GetMany](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L1019>)
   993  
   994  ```go
   995  func (self Value) GetMany(pathes []PathNode, opts *Options) error
   996  ```
   997  
   998  GetMany searches transversely and returns all the sub nodes along with the given pathes.
   999  
  1000  <details><summary>Example</summary>
  1001  <p>
  1002  
  1003  
  1004  
  1005  ```go
  1006  desc := getExample2Desc()
  1007  data := getExample2Data()
  1008  v := NewRootValue(desc, data)
  1009  
  1010  ps := []PathNode{
  1011  	{Path: NewPathFieldId(1)},
  1012  	{Path: NewPathFieldId(3)},
  1013  	{Path: NewPathFieldId(32767)},
  1014  }
  1015  
  1016  err := v.GetMany(ps, opts)
  1017  if err != nil {
  1018  	panic(err)
  1019  }
  1020  ```
  1021  
  1022  </p>
  1023  </details>
  1024  
  1025  <a name="Value.Index"></a>
  1026  ### func (Value) [Index](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L938>)
  1027  
  1028  ```go
  1029  func (self Value) Index(i int) (v Value)
  1030  ```
  1031  
  1032  Index returns a sub node at the given index from a LIST value.
  1033  
  1034  <a name="Value.IntMap"></a>
  1035  ### func (Value) [IntMap](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/cast.go#L239>)
  1036  
  1037  ```go
  1038  func (self Value) IntMap(opts *Options) (map[int]interface{}, error)
  1039  ```
  1040  
  1041  
  1042  
  1043  <a name="Value.Interface"></a>
  1044  ### func (Value) [Interface](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/cast.go#L320>)
  1045  
  1046  ```go
  1047  func (self Value) Interface(opts *Options) (interface{}, error)
  1048  ```
  1049  
  1050  Interface returns the go interface value contained by a node. If the node is a MESSAGE, it will return map[proto.FieldNumber]interface{} or map[int]interface{}. If it is a map, it will return map[int|string]interface{}, which depends on the key type
  1051  
  1052  <a name="Value.List"></a>
  1053  ### func (Value) [List](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/cast.go#L185>)
  1054  
  1055  ```go
  1056  func (self Value) List(opts *Options) ([]interface{}, error)
  1057  ```
  1058  
  1059  
  1060  
  1061  <a name="Value.MarshalTo"></a>
  1062  ### func (Value) [MarshalTo](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L834>)
  1063  
  1064  ```go
  1065  func (self Value) MarshalTo(to *proto.TypeDescriptor, opts *Options) ([]byte, error)
  1066  ```
  1067  
  1068  MarshalTo marshals self value into a sub value descripted by the to descriptor, alse called as "Cutting". Usually, the to descriptor is a subset of self descriptor.
  1069  
  1070  <a name="Value.SetByPath"></a>
  1071  ### func (*Value) [SetByPath](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L473>)
  1072  
  1073  ```go
  1074  func (self *Value) SetByPath(sub Node, path ...Path) (exist bool, err error)
  1075  ```
  1076  
  1077  SetByPath searches longitudinally and sets a sub value at the given path from the value. exist tells whether the node is already exists.
  1078  
  1079  <details><summary>Example</summary>
  1080  <p>
  1081  
  1082  
  1083  
  1084  ```go
  1085  desc := getExample2Desc()
  1086  data := getExample2Data()
  1087  v := NewRootValue(desc, data)
  1088  
  1089  p := binary.NewBinaryProtol([]byte{})
  1090  exp := "中文"
  1091  p.WriteString(exp)
  1092  buf := p.RawBuf()
  1093  vv := NewNode(proto.STRING, buf)
  1094  
  1095  ps := []Path{NewPathFieldName("InnerBase2"), NewPathFieldName("Base"), NewPathFieldName("Extra"), NewPathStrKey("b")}
  1096  exist, err2 := v.SetByPath(vv, ps...)
  1097  if err2 != nil {
  1098  	panic(err2)
  1099  }
  1100  fmt.Println(exist) // false
  1101  
  1102  // check inserted value
  1103  s2 := v.GetByPath(ps...)
  1104  if s2.Error() != "" {
  1105  	panic(s2.Error())
  1106  }
  1107  f2, _ := s2.String()
  1108  fmt.Println(f2) // 中文
  1109  ```
  1110  
  1111  </p>
  1112  </details>
  1113  
  1114  <a name="Value.SetMany"></a>
  1115  ### func (*Value) [SetMany](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L1058>)
  1116  
  1117  ```go
  1118  func (self *Value) SetMany(pathes []PathNode, opts *Options, root *Value, address []int, path ...Path) (err error)
  1119  ```
  1120  
  1121  SetMany: set a list of sub nodes at the given pathes from the value. root *Value: the root Node self *Value: the current Node (maybe root Node) address []int: the address from target Nodes to the root Node path ...Path: the path from root Node to target Nodes
  1122  
  1123  <a name="Value.StrMap"></a>
  1124  ### func (Value) [StrMap](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/cast.go#L278>)
  1125  
  1126  ```go
  1127  func (self Value) StrMap(opts *Options) (map[string]interface{}, error)
  1128  ```
  1129  
  1130  
  1131  
  1132  <a name="Value.UnsetByPath"></a>
  1133  ### func (*Value) [UnsetByPath](<https://github.com/khan-yin/dynamicgo/blob/main/proto/generic/value.go#L598>)
  1134  
  1135  ```go
  1136  func (self *Value) UnsetByPath(path ...Path) error
  1137  ```
  1138  
  1139  UnsetByPath searches longitudinally and unsets a sub value at the given path from the value.
  1140  
  1141  Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)