Debian Codegraph @

bson/bsonoptions/map_codec_options.go

raw symbols SCIP
1 // Copyright (C) MongoDB, Inc. 2017-present.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may
4 // not use this file except in compliance with the License. You may obtain
5 // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
7 package bsonoptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/
8
9 // MapCodecOptions represents all possible options for map encoding and decoding.
10 //
11 // Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal
12 // and unmarshal behavior instead.
13 type MapCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions# struct {
14 DecodeZerosMapscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#DecodeZerosMap. *bool // Specifies if the map should be zeroed before decoding into it. Defaults to false.
15 EncodeNilAsEmptyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#EncodeNilAsEmpty. *bool // Specifies if a nil map should encode as an empty document instead of null. Defaults to false.
16 // Specifies how keys should be handled. If false, the behavior matches encoding/json, where the encoding key type must
17 // either be a string, an integer type, or implement bsoncodec.KeyMarshaler and the decoding key type must either be a
18 // string, an integer type, or implement bsoncodec.KeyUnmarshaler. If true, keys are encoded with fmt.Sprint() and the
19 // encoding key type must be a string, an integer type, or a float. If true, the use of Stringer will override
20 // TextMarshaler/TextUnmarshaler. Defaults to false.
21 EncodeKeysWithStringerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#EncodeKeysWithStringer. *bool
22 }
23
24 // MapCodec creates a new *MapCodecOptions
25 //
26 // Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal
27 // and unmarshal behavior instead.
28 func MapCodecscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodec().() *MapCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions# {
29 return &MapCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#{}
30 }
31
32 // SetDecodeZerosMap specifies if the map should be zeroed before decoding into it. Defaults to false.
33 //
34 // Deprecated: Use [go.mongodb.org/mongo-driver/bson.Decoder.ZeroMaps] instead.
35 func (t *MapCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#) SetDecodeZerosMapscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#SetDecodeZerosMap().(b bool) *MapCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions# {
36 t.DecodeZerosMapscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#DecodeZerosMap. = &b
37 return t
38 }
39
40 // SetEncodeNilAsEmpty specifies if a nil map should encode as an empty document instead of null. Defaults to false.
41 //
42 // Deprecated: Use [go.mongodb.org/mongo-driver/bson.Encoder.NilMapAsEmpty] instead.
43 func (t *MapCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#) SetEncodeNilAsEmptyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#SetEncodeNilAsEmpty().(b bool) *MapCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions# {
44 t.EncodeNilAsEmptyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#EncodeNilAsEmpty. = &b
45 return t
46 }
47
48 // SetEncodeKeysWithStringer specifies how keys should be handled. If false, the behavior matches encoding/json, where the
49 // encoding key type must either be a string, an integer type, or implement bsoncodec.KeyMarshaler and the decoding key
50 // type must either be a string, an integer type, or implement bsoncodec.KeyUnmarshaler. If true, keys are encoded with
51 // fmt.Sprint() and the encoding key type must be a string, an integer type, or a float. If true, the use of Stringer
52 // will override TextMarshaler/TextUnmarshaler. Defaults to false.
53 //
54 // Deprecated: Use [go.mongodb.org/mongo-driver/bson.Encoder.StringifyMapKeysWithFmt] instead.
55 func (t *MapCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#) SetEncodeKeysWithStringerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#SetEncodeKeysWithStringer().(b bool) *MapCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions# {
56 t.EncodeKeysWithStringerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#EncodeKeysWithStringer. = &b
57 return t
58 }
59
60 // MergeMapCodecOptions combines the given *MapCodecOptions into a single *MapCodecOptions in a last one wins fashion.
61 //
62 // Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a
63 // single options struct instead.
64 func MergeMapCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MergeMapCodecOptions().(opts ...*MapCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#) *MapCodecOptionsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions# {
65 s := MapCodecscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodec().()
66 for _, opt := range opts {
67 if opt == nil {
68 continue
69 }
70 if opt.DecodeZerosMapscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#DecodeZerosMap. != nil {
71 s.DecodeZerosMapscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#DecodeZerosMap. = opt.DecodeZerosMapscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#DecodeZerosMap.
72 }
73 if opt.EncodeNilAsEmptyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#EncodeNilAsEmpty. != nil {
74 s.EncodeNilAsEmptyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#EncodeNilAsEmpty. = opt.EncodeNilAsEmptyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#EncodeNilAsEmpty.
75 }
76 if opt.EncodeKeysWithStringerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#EncodeKeysWithStringer. != nil {
77 s.EncodeKeysWithStringerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#EncodeKeysWithStringer. = opt.EncodeKeysWithStringerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/bson/bsonoptions`/MapCodecOptions#EncodeKeysWithStringer.
78 }
79 }
80
81 return s
82 }