-
Notifications
You must be signed in to change notification settings - Fork 0
Work branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Work branch #1
Changes from all commits
2e649d0
25195c3
8b5ab44
f1be366
afaeae8
6fec7a0
2008249
c3dfae7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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) |
| 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. | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Super Hot Strings for U and ME | ||
| [](https://travis-ci.org/Waaazzzuuup/SHS) | ||
| [](https://ci.appveyor.com/project/Waaazzzuuup/shs) | ||
| ----------------------------------- | ||
| # realisation of non-native strings |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| #ifndef CPP_STRING_H | ||
| #define CPP_STRING_H | ||
| //one definition rule | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. std::size_t и следует подключить файл , где объявлен этот тип |
||
| char * string; | ||
| public: | ||
| static char position; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Для чего нужна эта переменная?
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Лишние пустые строки в конце файла |
||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если файл называется MyString.h, то и имя макроса лучше сделать MYSTRING_H