! * \brief String container class. */
| 400 | * \brief String container class. |
| 401 | */ |
| 402 | class String { |
| 403 | public: |
| 404 | /*! |
| 405 | * \brief avoid misuse of nullptr |
| 406 | */ |
| 407 | String(std::nullptr_t) = delete; // NOLINT(*) |
| 408 | /*! |
| 409 | * \brief constructor |
| 410 | */ |
| 411 | String() { data_.InitTypeIndex(TypeIndex::kTVMFFISmallStr); } |
| 412 | // constructors from Any |
| 413 | /*! |
| 414 | * \brief Copy constructor |
| 415 | * \param other The other string |
| 416 | */ |
| 417 | String(const String& other) = default; // NOLINT(*) |
| 418 | /*! |
| 419 | * \brief Move constructor |
| 420 | * \param other The other string |
| 421 | */ |
| 422 | String(String&& other) = default; // NOLINT(*) |
| 423 | /*! |
| 424 | * \brief Copy assignment operator |
| 425 | * \param other The other string |
| 426 | */ |
| 427 | String& operator=(const String& other) = default; // NOLINT(*) |
| 428 | /*! |
| 429 | * \brief Move assignment operator |
| 430 | * \param other The other string |
| 431 | */ |
| 432 | String& operator=(String&& other) = default; // NOLINT(*) |
| 433 | |
| 434 | /*! |
| 435 | * \brief Swap this String with another string |
| 436 | * \param other The other string |
| 437 | */ |
| 438 | void swap(String& other) noexcept { // NOLINT(*) |
| 439 | std::swap(data_, other.data_); |
| 440 | } |
| 441 | |
| 442 | /*! |
| 443 | * \brief Copy assignment operator |
| 444 | * \param other The other string |
| 445 | */ |
| 446 | String& operator=(const std::string& other) { |
| 447 | String(other).swap(*this); // NOLINT(*) |
| 448 | return *this; |
| 449 | } |
| 450 | /*! |
| 451 | * \brief Move assignment operator |
| 452 | * \param other The other string |
| 453 | */ |
| 454 | String& operator=(std::string&& other) { |
| 455 | String(std::move(other)).swap(*this); // NOLINT(*) |
| 456 | return *this; |
| 457 | } |
| 458 | |
| 459 | /*! |