mongo/buildscripts/idl/sample/sample.idl

123 lines
4.3 KiB
YAML

# Copyright (C) 2018-present MongoDB, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the Server Side Public License, version 1,
# as published by MongoDB, Inc.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# Server Side Public License for more details.
#
# You should have received a copy of the Server Side Public License
# along with this program. If not, see
# <http://www.mongodb.com/licensing/server-side-public-license>.
#
# As a special exception, the copyright holders give permission to link the
# code of portions of this program with the OpenSSL library under certain
# conditions as described in each individual source file and distribute
# linked combinations including the program with the OpenSSL library. You
# must comply with the Server Side Public License in all respects for
# all of the code used other than as permitted herein. If you modify file(s)
# with this exception, you may extend this exception to your version of the
# file(s), but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version. If you delete this
# exception statement from all source files in the program, then also delete
# it in the license file.
#
# Sample idl
# Demonstrates a subset of features
# 1. string types
# 2. int types
# 3. a custom type, NamespaceString
# 4. Nested structs
# 5. Optional fields
# 6. Default values
global:
cpp_namespace: "mongo"
cpp_includes:
- "mongo/db/namespace_string.h"
types:
string:
bson_serialization_type: string
description: "A BSON UTF-8 string"
cpp_type: "std::string"
deserializer: "mongo::BSONElement::str"
is_view: false
int:
bson_serialization_type: int
description: "A BSON 32-bit integer"
cpp_type: "std::int32_t"
deserializer: "mongo::BSONElement::_numberInt"
is_view: false
namespacestring:
bson_serialization_type: string
description: "A MongoDB NamespaceString"
cpp_type: "mongo::NamespaceString"
serializer: mongo::NamespaceString::toString
deserializer: mongo::NamespaceString
is_view: false
safeInt32:
description: Accepts any numerical type within int32 range
cpp_type: std::int64_t
bson_serialization_type:
- long
- int
- decimal
- double
deserializer: "mongo::BSONElement::numberInt"
is_view: false
bindata_generic:
bson_serialization_type: bindata
bindata_subtype: generic
description: "A BSON bindata of "
cpp_type: "std::vector<std::uint8_t>"
deserializer: "mongo::BSONElement::_binDataVector"
is_view: false
bindata_uuid:
bson_serialization_type: bindata
bindata_subtype: uuid
description: "A BSON bindata of uuid sub type"
cpp_type: "std::array<std::uint8_t, 16>"
deserializer: "mongo::BSONElement::uuid"
is_view: false
structs:
default_values:
description: UnitTest for a single safeInt32
fields:
stringfield:
type: string
default: '"a default"'
description: "An example string field with default value"
intfield:
type: int
default: 42
description: "An example int field with default value"
numericfield:
type: safeInt32
description: "A numeric type that supports multiple types"
nsfield:
type: namespacestring
description: "A namespace string type"
optionalField:
type: string
optional: true
description: "An optional string"
vectorField:
type: array<int>
description: "An example int array field with default value"
binDataField:
type: bindata_generic
description: "A binData of generic subtype"
uuidField:
type: bindata_uuid
description: "A binData of uuid subtype"