! \brief Constructs a string populated from an arbitrary value of * specified size. * * An extra '\0' is added, in case none was contained in str. * * \param str the initial value of the string instance. Note that '\0' * characters receive no special treatment. If NULL, * the string is left empty, with a size of 0. * *
| 509 | * \param size the number of characters to copy from str. |
| 510 | */ |
| 511 | string(const char * str, ::size_t size) : |
| 512 | size_(size), |
| 513 | str_(NULL) |
| 514 | { |
| 515 | if( size > 0 ) { |
| 516 | str_ = new char[size_+1]; |
| 517 | if (str_ != NULL) { |
| 518 | memcpy(str_, str, size_ * sizeof(char)); |
| 519 | str_[size_] = '\0'; |
| 520 | } |
| 521 | else { |
| 522 | size_ = 0; |
| 523 | } |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | /*! \brief Constructs a string populated from a null-terminated value. |
| 528 | * |
no outgoing calls
no test coverage detected