NullableString ============== .. cpp:class:: pandas::NullableString pandas C++ class. Example ------- .. code-block:: cpp #include using namespace pandas; // Use NullableString NullableString obj; // ... operations ... Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``bool has_value() const { return value.has_value()`` - bool - pd_nullable.h:53 - :ref:`View ` * - ``NullableString(const char\* s) : value(s ? std::optional(s) : std::nullopt)`` - NullableString(const char\* s) : - pd_nullable.h:49 - :ref:`View ` * - ``NullableString(const std::string& s) : value(s)`` - NullableString(const std::string& s) : - pd_nullable.h:50 - :ref:`View ` * - ``NullableString(std::nullopt_t) : value(std::nullopt)`` - NullableString(std::nullopt_t) : - pd_nullable.h:52 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-nullablestring-has_value-0: .. dropdown:: has_value (pd_test_1_all.cpp:88) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 78 :emphasize-lines: 11 // T & T = T, T & F = F, T & NA = NA // F & T = F, F & F = F, F & NA = F (False dominates) // NA & T = NA, NA & F = F, NA & NA = NA pandas::BooleanArray t({std::optional(true)}); pandas::BooleanArray f({std::optional(false)}); pandas::BooleanArray na({std::nullopt}); // T & T = T auto tt = (t & t); if (!tt[0].has_value() || !tt[0].value()) { std::cout << " [FAIL] : in pd_test_boolean_array_kleene_and() : T & T should be T" << std::endl; throw std::runtime_error("pd_test_boolean_array_kleene_and failed: T & T"); } // T & F = F auto tf = (t & f); if (!tf[0].has_value() || tf[0].value()) { std::cout << " [FAIL] : in pd_test_boolean_array_kleene_and() : T & F should be F" << std::endl; throw std::runtime_error("pd_test_boolean_array_kleene_and failed: T & F"); } .. _example-nullablestring-value-1: .. dropdown:: value (pd_test_1_all.cpp:88) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 78 :emphasize-lines: 11 // T & T = T, T & F = F, T & NA = NA // F & T = F, F & F = F, F & NA = F (False dominates) // NA & T = NA, NA & F = F, NA & NA = NA pandas::BooleanArray t({std::optional(true)}); pandas::BooleanArray f({std::optional(false)}); pandas::BooleanArray na({std::nullopt}); // T & T = T auto tt = (t & t); if (!tt[0].has_value() || !tt[0].value()) { std::cout << " [FAIL] : in pd_test_boolean_array_kleene_and() : T & T should be T" << std::endl; throw std::runtime_error("pd_test_boolean_array_kleene_and failed: T & T"); } // T & F = F auto tf = (t & f); if (!tf[0].has_value() || tf[0].value()) { std::cout << " [FAIL] : in pd_test_boolean_array_kleene_and() : T & F should be F" << std::endl; throw std::runtime_error("pd_test_boolean_array_kleene_and failed: T & F"); } .. _example-nullablestring-value-2: .. dropdown:: value (pd_test_1_all.cpp:88) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 78 :emphasize-lines: 11 // T & T = T, T & F = F, T & NA = NA // F & T = F, F & F = F, F & NA = F (False dominates) // NA & T = NA, NA & F = F, NA & NA = NA pandas::BooleanArray t({std::optional(true)}); pandas::BooleanArray f({std::optional(false)}); pandas::BooleanArray na({std::nullopt}); // T & T = T auto tt = (t & t); if (!tt[0].has_value() || !tt[0].value()) { std::cout << " [FAIL] : in pd_test_boolean_array_kleene_and() : T & T should be T" << std::endl; throw std::runtime_error("pd_test_boolean_array_kleene_and failed: T & T"); } // T & F = F auto tf = (t & f); if (!tf[0].has_value() || tf[0].value()) { std::cout << " [FAIL] : in pd_test_boolean_array_kleene_and() : T & F should be F" << std::endl; throw std::runtime_error("pd_test_boolean_array_kleene_and failed: T & F"); } .. _example-nullablestring-value-3: .. dropdown:: value (pd_test_1_all.cpp:88) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 78 :emphasize-lines: 11 // T & T = T, T & F = F, T & NA = NA // F & T = F, F & F = F, F & NA = F (False dominates) // NA & T = NA, NA & F = F, NA & NA = NA pandas::BooleanArray t({std::optional(true)}); pandas::BooleanArray f({std::optional(false)}); pandas::BooleanArray na({std::nullopt}); // T & T = T auto tt = (t & t); if (!tt[0].has_value() || !tt[0].value()) { std::cout << " [FAIL] : in pd_test_boolean_array_kleene_and() : T & T should be T" << std::endl; throw std::runtime_error("pd_test_boolean_array_kleene_and failed: T & T"); } // T & F = F auto tf = (t & f); if (!tf[0].has_value() || tf[0].value()) { std::cout << " [FAIL] : in pd_test_boolean_array_kleene_and() : T & F should be F" << std::endl; throw std::runtime_error("pd_test_boolean_array_kleene_and failed: T & F"); }