aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-03-14 19:30:28 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-03-14 19:41:22 +0300
commit7417a62648ce654d84bb7a1cf178c300e81b5358 (patch)
treeb1afa0c28360f5bdcfd4e180cee6d44414676248
parent261e322cb6cabc8ee5b70d64adcf8cd84a5de97e (diff)
downloadydb-7417a62648ce654d84bb7a1cf178c300e81b5358.tar.gz
Intermediate changes
-rw-r--r--contrib/libs/flatbuffers/samples/monster.fbs33
-rw-r--r--contrib/libs/flatbuffers/samples/sample_binary.cpp104
-rw-r--r--contrib/libs/flatbuffers/samples/ya.make18
-rw-r--r--contrib/libs/flatbuffers/ya.make1
4 files changed, 0 insertions, 156 deletions
diff --git a/contrib/libs/flatbuffers/samples/monster.fbs b/contrib/libs/flatbuffers/samples/monster.fbs
deleted file mode 100644
index af224512ee..0000000000
--- a/contrib/libs/flatbuffers/samples/monster.fbs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Example IDL file for our monster's schema.
-
-namespace MyGame.Sample;
-
-enum Color:byte { Red = 0, Green, Blue = 2 }
-
-union Equipment { Weapon } // Optionally add more tables.
-
-struct Vec3 {
- x:float;
- y:float;
- z:float;
-}
-
-table Monster {
- pos:Vec3;
- mana:short = 150;
- hp:short = 100;
- name:string;
- friendly:bool = false (deprecated);
- inventory:[ubyte];
- color:Color = Blue;
- weapons:[Weapon];
- equipped:Equipment;
- path:[Vec3];
-}
-
-table Weapon {
- name:string;
- damage:short;
-}
-
-root_type Monster;
diff --git a/contrib/libs/flatbuffers/samples/sample_binary.cpp b/contrib/libs/flatbuffers/samples/sample_binary.cpp
deleted file mode 100644
index 6bd1cdcf43..0000000000
--- a/contrib/libs/flatbuffers/samples/sample_binary.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2015 Google Inc. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <contrib/libs/flatbuffers/samples/monster.fbs.h>
-
-using namespace MyGame::Sample;
-
-// Example how to use FlatBuffers to create and read binary buffers.
-
-int main(int /*argc*/, const char * /*argv*/[]) {
- // Build up a serialized buffer algorithmically:
- flatbuffers::FlatBufferBuilder builder;
-
- // First, lets serialize some weapons for the Monster: A 'sword' and an 'axe'.
- auto weapon_one_name = builder.CreateString("Sword");
- short weapon_one_damage = 3;
-
- auto weapon_two_name = builder.CreateString("Axe");
- short weapon_two_damage = 5;
-
- // Use the `CreateWeapon` shortcut to create Weapons with all fields set.
- auto sword = CreateWeapon(builder, weapon_one_name, weapon_one_damage);
- auto axe = CreateWeapon(builder, weapon_two_name, weapon_two_damage);
-
- // Create a FlatBuffer's `vector` from the `std::vector`.
- std::vector<flatbuffers::Offset<Weapon>> weapons_vector;
- weapons_vector.push_back(sword);
- weapons_vector.push_back(axe);
- auto weapons = builder.CreateVector(weapons_vector);
-
- // Second, serialize the rest of the objects needed by the Monster.
- auto position = Vec3(1.0f, 2.0f, 3.0f);
-
- auto name = builder.CreateString("MyMonster");
-
- unsigned char inv_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- auto inventory = builder.CreateVector(inv_data, 10);
-
- // Shortcut for creating monster with all fields set:
- auto orc = CreateMonster(builder, &position, 150, 80, name, inventory,
- Color_Red, weapons, Equipment_Weapon, axe.Union());
-
- builder.Finish(orc); // Serialize the root of the object.
-
- // We now have a FlatBuffer we can store on disk or send over a network.
-
- // ** file/network code goes here :) **
- // access builder.GetBufferPointer() for builder.GetSize() bytes
-
- // Instead, we're going to access it right away (as if we just received it).
-
- // Get access to the root:
- auto monster = GetMonster(builder.GetBufferPointer());
-
- // Get and test some scalar types from the FlatBuffer.
- assert(monster->hp() == 80);
- assert(monster->mana() == 150); // default
- assert(monster->name()->str() == "MyMonster");
-
- // Get and test a field of the FlatBuffer's `struct`.
- auto pos = monster->pos();
- assert(pos);
- assert(pos->z() == 3.0f);
- (void)pos;
-
- // Get a test an element from the `inventory` FlatBuffer's `vector`.
- auto inv = monster->inventory();
- assert(inv);
- assert(inv->Get(9) == 9);
- (void)inv;
-
- // Get and test the `weapons` FlatBuffers's `vector`.
- std::string expected_weapon_names[] = { "Sword", "Axe" };
- short expected_weapon_damages[] = { 3, 5 };
- auto weps = monster->weapons();
- for (unsigned int i = 0; i < weps->size(); i++) {
- assert(weps->Get(i)->name()->str() == expected_weapon_names[i]);
- assert(weps->Get(i)->damage() == expected_weapon_damages[i]);
- }
- (void)expected_weapon_names;
- (void)expected_weapon_damages;
-
- // Get and test the `Equipment` union (`equipped` field).
- assert(monster->equipped_type() == Equipment_Weapon);
- auto equipped = static_cast<const Weapon *>(monster->equipped());
- assert(equipped->name()->str() == "Axe");
- assert(equipped->damage() == 5);
- (void)equipped;
-
- printf("The FlatBuffer was successfully created and verified!\n");
-}
diff --git a/contrib/libs/flatbuffers/samples/ya.make b/contrib/libs/flatbuffers/samples/ya.make
deleted file mode 100644
index 7855f8f461..0000000000
--- a/contrib/libs/flatbuffers/samples/ya.make
+++ /dev/null
@@ -1,18 +0,0 @@
-PROGRAM()
-
-LICENSE(Apache-2.0)
-
-LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-
-NO_UTIL()
-
-SRCS(
- monster.fbs
- sample_binary.cpp
-)
-
-PEERDIR(
- contrib/libs/flatbuffers
-)
-
-END()
diff --git a/contrib/libs/flatbuffers/ya.make b/contrib/libs/flatbuffers/ya.make
index 2d46dbe7e4..896db7ce37 100644
--- a/contrib/libs/flatbuffers/ya.make
+++ b/contrib/libs/flatbuffers/ya.make
@@ -37,5 +37,4 @@ END()
RECURSE(
flatc
- samples
)