FBBuilder ========= .. cpp:class:: numpy::FBBuilder numpy C++ class. Example ------- .. code-block:: cpp #include using namespace numpy; // Use FBBuilder FBBuilder obj; // ... operations ... Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``int32_t current_offset() const`` - int32_t - df_dataframe.h:21581 - * - ``void pad(size_t alignment)`` - void - df_dataframe.h:21545 - :ref:`View ` * - ``pad(4)`` - - df_dataframe.h:21550 - :ref:`View ` * - ``pad(4)`` - - df_dataframe.h:21559 - :ref:`View ` * - ``void write_i16(int16_t val)`` - void - df_dataframe.h:21563 - * - ``void write_i32(int32_t val)`` - void - df_dataframe.h:21568 - * - ``void write_i64(int64_t val)`` - void - df_dataframe.h:21575 - * - ``int32_t write_string(const std::string& s)`` - int32_t - df_dataframe.h:21549 - Code Examples ------------- The following examples are extracted from the test suite. .. _example-fbbuilder-pad-0: .. dropdown:: pad (np_test_1_all.cpp:18733) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 18723 :emphasize-lines: 11 std::cout << "========= testPadding ======================="; // Create test array auto array = createInt32Array({ 2, 2 }, 0); array.setElementAt({ 0, 0 }, 1); array.setElementAt({ 0, 1 }, 2); array.setElementAt({ 1, 0 }, 3); array.setElementAt({ 1, 1 }, 4); // Test constant padding auto padded_const = pad(array, 1, "constant", 0); if (!(padded_const.getShape()[0] == 4)) { std::string description = std::string("testPadding():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(padded_const.getShape()[0] == 4)"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); } if (!(padded_const.getShape()[1] == 4)) { std::string description = std::string("testPadding():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(padded_const.getShape()[1] == 4)"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); } .. _example-fbbuilder-pad-1: .. dropdown:: pad (np_test_1_all.cpp:18733) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 18723 :emphasize-lines: 11 std::cout << "========= testPadding ======================="; // Create test array auto array = createInt32Array({ 2, 2 }, 0); array.setElementAt({ 0, 0 }, 1); array.setElementAt({ 0, 1 }, 2); array.setElementAt({ 1, 0 }, 3); array.setElementAt({ 1, 1 }, 4); // Test constant padding auto padded_const = pad(array, 1, "constant", 0); if (!(padded_const.getShape()[0] == 4)) { std::string description = std::string("testPadding():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(padded_const.getShape()[0] == 4)"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); } if (!(padded_const.getShape()[1] == 4)) { std::string description = std::string("testPadding():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(padded_const.getShape()[1] == 4)"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); } .. _example-fbbuilder-pad-2: .. dropdown:: pad (np_test_1_all.cpp:18733) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 18723 :emphasize-lines: 11 std::cout << "========= testPadding ======================="; // Create test array auto array = createInt32Array({ 2, 2 }, 0); array.setElementAt({ 0, 0 }, 1); array.setElementAt({ 0, 1 }, 2); array.setElementAt({ 1, 0 }, 3); array.setElementAt({ 1, 1 }, 4); // Test constant padding auto padded_const = pad(array, 1, "constant", 0); if (!(padded_const.getShape()[0] == 4)) { std::string description = std::string("testPadding():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(padded_const.getShape()[0] == 4)"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); } if (!(padded_const.getShape()[1] == 4)) { std::string description = std::string("testPadding():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(padded_const.getShape()[1] == 4)"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); }