fixed
This commit is contained in:
parent
7c659a3093
commit
157bcf4af8
2 changed files with 110 additions and 109 deletions
|
|
@ -1 +1,110 @@
|
|||
// Tóth Dániel Mátyás | IFPQYY | v1
|
||||
#include "CMyString.h"
|
||||
#include "CMyStringException.h"
|
||||
|
||||
CMyString::CMyString() {
|
||||
m_nDataLength = 0;
|
||||
m_nAllocLength = 1;
|
||||
m_pchData = new char[m_nAllocLength];
|
||||
m_pchData[0] = '\0';
|
||||
}
|
||||
CMyString::CMyString(const char* psz) {
|
||||
m_nDataLength = 0;
|
||||
if (psz == nullptr)
|
||||
{
|
||||
m_nAllocLength = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (psz[m_nDataLength])
|
||||
{
|
||||
m_nDataLength++;
|
||||
}
|
||||
m_nAllocLength = m_nDataLength + 1;
|
||||
}
|
||||
m_pchData = new char[m_nAllocLength];
|
||||
int i = 0;
|
||||
while (i < m_nAllocLength)
|
||||
{
|
||||
m_pchData[i] = psz[i];
|
||||
i++;
|
||||
}
|
||||
m_pchData[i] = '\0';
|
||||
}
|
||||
CMyString::CMyString(char ch, size_t repeat = 1) {
|
||||
m_nDataLength = repeat;
|
||||
m_nAllocLength = repeat + 1;
|
||||
m_pchData = new char[m_nAllocLength];
|
||||
int i = 0;
|
||||
while (i < repeat)
|
||||
{
|
||||
m_pchData[i] = ch;
|
||||
i++;
|
||||
}
|
||||
m_pchData[i] = '\0';
|
||||
}
|
||||
CMyString::CMyString(const CMyString& str) {
|
||||
if (str.empty())
|
||||
{
|
||||
m_nDataLength = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nDataLength = str.size();
|
||||
}
|
||||
m_nAllocLength = m_nDataLength + 1;
|
||||
m_pchData = new char[m_nAllocLength];
|
||||
int i = 0;
|
||||
const char* cont = str.c_str();
|
||||
while (cont[i])
|
||||
{
|
||||
m_pchData[i] = cont[i];
|
||||
i++;
|
||||
}
|
||||
m_pchData[i] = '\0';
|
||||
}
|
||||
CMyString::~CMyString() {
|
||||
delete m_pchData;
|
||||
}
|
||||
size_t CMyString::size() const {
|
||||
|
||||
}
|
||||
size_t CMyString::capacity() const {
|
||||
|
||||
}
|
||||
const char* CMyString::c_str() const {
|
||||
|
||||
}
|
||||
void CMyString::clear() {
|
||||
|
||||
}
|
||||
char CMyString::getat(size_t index) const {
|
||||
|
||||
}
|
||||
void CMyString::setat(size_t index, char ch) {
|
||||
|
||||
}
|
||||
void CMyString::reserve(size_t newcapacity) {
|
||||
|
||||
}
|
||||
void CMyString::erase(size_t pos, size_t count) {
|
||||
|
||||
}
|
||||
bool CMyString::empty() const {
|
||||
return m_nDataLength == 0;
|
||||
}
|
||||
void CMyString::display() const {
|
||||
|
||||
}
|
||||
void CMyString::shrink_to_fill() {
|
||||
|
||||
}
|
||||
void CMyString::reverse() {
|
||||
|
||||
}
|
||||
void CMyString::append(const char* psz, unsigned offset = 0, unsigned count = -0) {
|
||||
|
||||
}
|
||||
CMyString& CMyString::operator=(const CMyString& str) {
|
||||
|
||||
}
|
||||
|
|
@ -1,110 +1,2 @@
|
|||
// Tóth Dániel Mátyás | IFPQYY | v1
|
||||
#include "CMyString.h"
|
||||
#include "CMyStringException.h"
|
||||
|
||||
CMyString::CMyString(){
|
||||
m_nDataLength = 0;
|
||||
m_nAllocLength = 1;
|
||||
m_pchData = new char[m_nAllocLength];
|
||||
m_pchData[0] = '\0';
|
||||
}
|
||||
CMyString::CMyString(const char* psz){
|
||||
m_nDataLength = 0;
|
||||
if (psz == nullptr)
|
||||
{
|
||||
m_nAllocLength = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (psz[m_nDataLength])
|
||||
{
|
||||
m_nDataLength++;
|
||||
}
|
||||
m_nAllocLength = m_nDataLength + 1;
|
||||
}
|
||||
m_pchData = new char[m_nAllocLength];
|
||||
int i = 0;
|
||||
while (i < m_nAllocLength)
|
||||
{
|
||||
m_pchData[i] = psz[i];
|
||||
i++;
|
||||
}
|
||||
m_pchData[i] = '\0';
|
||||
}
|
||||
CMyString::CMyString(char ch, size_t repeat = 1){
|
||||
m_nDataLength = repeat;
|
||||
m_nAllocLength = repeat + 1;
|
||||
m_pchData = new char[m_nAllocLength];
|
||||
int i = 0;
|
||||
while (i < repeat)
|
||||
{
|
||||
m_pchData[i] = ch;
|
||||
i++;
|
||||
}
|
||||
m_pchData[i] = '\0';
|
||||
}
|
||||
CMyString::CMyString(const CMyString& str){
|
||||
if (str.empty())
|
||||
{
|
||||
m_nDataLength = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nDataLength = str.size();
|
||||
}
|
||||
m_nAllocLength = m_nDataLength + 1;
|
||||
m_pchData = new char[m_nAllocLength];
|
||||
int i = 0;
|
||||
const char* cont = str.c_str();
|
||||
while (cont[i])
|
||||
{
|
||||
m_pchData[i] = cont[i];
|
||||
i++;
|
||||
}
|
||||
m_pchData[i] = '\0';
|
||||
}
|
||||
CMyString::~CMyString(){
|
||||
delete m_pchData;
|
||||
}
|
||||
size_t CMyString::size() const {
|
||||
|
||||
}
|
||||
size_t CMyString::capacity() const {
|
||||
|
||||
}
|
||||
const char* CMyString:: c_str() const {
|
||||
|
||||
}
|
||||
void CMyString::clear() {
|
||||
|
||||
}
|
||||
char CMyString::getat(size_t index) const {
|
||||
|
||||
}
|
||||
void CMyString::setat(size_t index, char ch) {
|
||||
|
||||
}
|
||||
void CMyString::reserve(size_t newcapacity) {
|
||||
|
||||
}
|
||||
void CMyString::erase(size_t pos, size_t count) {
|
||||
|
||||
}
|
||||
bool CMyString::empty() const {
|
||||
return m_nDataLength == 0;
|
||||
}
|
||||
void CMyString::display() const {
|
||||
|
||||
}
|
||||
void CMyString::shrink_to_fill() {
|
||||
|
||||
}
|
||||
void CMyString::reverse() {
|
||||
|
||||
}
|
||||
void CMyString::append(const char* psz, unsigned offset = 0, unsigned count = -0) {
|
||||
|
||||
}
|
||||
CMyString& CMyString::operator=(const CMyString& str) {
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue