Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
sudo: false

language: cpp

compiler:
- clang
- gcc

before_install:
- pip install --user cpp-coveralls

install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi
- if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi
- mkdir build
- cd build
- cmake ..
- make

script:
- ctest -V

addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
packages:
- gcc-4.9
- g++-4.9
- clang-3.7
23 changes: 18 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
cmake_minimum_required(VERSION 3.3)
project(super_hot_strings)
cmake_minimum_required(VERSION 2.8)
project(CppLab2)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if (MSVC)
add_definitions(/W4)
else()
add_definitions(-Wall)
add_definitions(-std=c++11)
endif()

set(SOURCE_FILES main.cpp)
add_executable(super_hot_strings ${SOURCE_FILES})
include_directories(Catch/include)
include_directories(include)

enable_testing()

set(SOURCES src/string.cpp)

add_executable(test_string tests/test_string.cpp ${SOURCES})

add_test(NAME ${PROJECT_NAME} COMMAND test_string)
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2016 sdukshis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Super Hot Strings for U and ME
[![Build Status](https://travis-ci.org/Waaazzzuuup/SHS.svg)](https://travis-ci.org/Waaazzzuuup/SHS)
[![Build status](https://ci.appveyor.com/api/projects/status/o79ympra1gx16ubn?svg=true)](https://ci.appveyor.com/project/Waaazzzuuup/shs)
-----------------------------------
# realisation of non-native strings
20 changes: 20 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 1.0.{build}

clone_folder: c:\dev\complex

build:

install:
- git submodule -q update --init --recursive

build_script:
- cd c:\dev\complex
- md build
- cd build
- cmake ..
- cmake --build . --config debug

after_build:

test_script:
- cmd: ctest -C Debug -VV
55 changes: 55 additions & 0 deletions include/MyString.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#ifndef CPP_STRING_H

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если файл называется MyString.h, то и имя макроса лучше сделать MYSTRING_H

#define CPP_STRING_H
//one definition rule

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Строки 1 и 2 - это include guard (страж включения). Правило единственного объявления - это немного другое. Это правило гласит, что идентификатор не может быть объявлен более чем 1 раз в пределах единицы компиляции.


class String {
private:
size_t length; //length of actual string, w/o EOL symvol

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::size_t и следует подключить файл , где объявлен этот тип

char * string;
public:
static char position;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для чего нужна эта переменная?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для отладки, лишнее

String();
String(const char *str);
String(const char *str, unsigned count);
String(char ch, unsigned count);
String(const String &other);
String(String &&other);
~String();
String & operator=(const String &other);
String & operator=(String &&other);

String & operator+=(const String &suffix);
String & operator+=(const char *suffix);
String & operator+=(char suffix);
void swap(String &other);
char & operator[](size_t pos);
const char operator[](size_t pos) const;
/**
throws an exception if pos >= size()
*/
char & at(size_t pos);

/**
throws an exception if pos >= size()
*/
const char at(size_t pos) const;
/**
/return pointer to '\0' terminated C-style string
*/
const char * data() const;
size_t size() const;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::size_t

friend bool operator==(const String &lhs, const String &rhs);
friend bool operator<(const String &lhs, const String &rhs);
};
String operator+(const String &lhs, const String &rhs);
String operator+(const String &lhs, const char *rhs);
String operator+(const char *lhs, const String &rhs);
bool operator!=(const String &lhs, const String &rhs);
bool operator<=(const String &lhs, const String &rhs);
bool operator>(const String &lhs, const String &rhs);
bool operator>=(const String &lhs, const String &rhs);
#endif

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишние пустые строки в конце файла




Loading