{"action":"created","comment":{"url":"https://api.github.com/repos/ElenaVinogradova/String/pulls/comments/54562544","id":54562544,"diff_hunk":"@@ -0,0 +1,282 @@\n+#include <stddef.h>\n+#include <stdexcept>\n+#include \"MyString.h\"\n+\n+\n+String::String() {\n+    length = 0;\n+    string = new char[1];\n+    string[0] = '\\0';\n+}\n+\n+String::String(const char *str) {\n+    length = 0;\n+    const char *temp = str;\n+    while (*(temp++) != '\\0') {\n+        length++;\n+    }\n+    char *strCopy = new char[length + 1];\n+    for (std::size_t i = 0; i < length; i++) {\n+        strCopy[i] = str[i];\n+    }\n+\n+    string = strCopy;\n+    string[length] = '\\0';\n+}\n+\n+//cut from beginning\n+String::String(const char *str, unsigned count) {\n+    string = new char[count + 1];\n+    length = count;\n+    for (std::size_t i = 0; i <= length; i++) {\n+        string[i] = str[i];\n+    }\n+}\n+\n+//repeat symbol count times\n+String::String(char ch, unsigned count) {\n+    length = count;\n+    string = new char[length + 1];\n+    char *temp = string;\n+\n+    for (std::size_t i = 0; i < length; ++i) {\n+        *(temp++) = ch;\n+    }\n+    *(temp) = '\\0';\n+\n+}\n+\n+//copy constructor\n+String::String(const String &other) {\n+    string = new char[other.length + 1];\n+    length = other.length;\n+    for (size_t i = 0; i <= length; ++i) {\n+        string[i] = other.string[i];\n+    }\n+}\n+\n+\n+String::String(String &&other) {\n+    string = other.string;\n+    length = other.length;\n+    //other.string[0] = '\\0'; //no magic\n+    char nully = '\\0';\n+    other.string = &(nully); //magic\n+    other.length = 0;\n+}\n+\n+\n+String::~String() {\n+    if (string[0] != '\\0') {\n+        delete[] string;\n+    }\n+}\n+\n+//optize\n+String &String::operator=(const String &other) {\n+    delete[] string;\n+    string = new char[other.length + 1];\n+    length = other.length;\n+    for (size_t i = 0; i < length; i++) {\n+        string[i] = other.string[i];\n+    }\n+    string[length] = '\\0';\n+    return *this;\n+}\n+\n+String &String::operator=(String &&other) {\n+    delete[] string;\n+    string = other.string;\n+    length = other.length;\n+\n+    char nully = '\\0';\n+    other.string = &(nully); //magic #2\n+    other.length = 0;\n+    return *this;\n+\n+}\n+\n+String &String::operator+=(const String &suffix) {\n+    char *concat = new char[length + suffix.length + 1];\n+    for (size_t i = 0; i < length; ++i) {\n+        concat[i] = string[i];\n+    }\n+    for (size_t j = length; j < length + suffix.length; ++j) {\n+        concat[j] = suffix.string[j - length];\n+    }\n+    concat[length + suffix.length] = '\\0';\n+    delete[] string;\n+    string = concat;\n+    length += suffix.length;\n+\n+    return *this;\n+}\n+\n+String &String::operator+=(const char *suffix) {\n+    size_t suffixLength = 0;\n+    const char *temp = suffix;\n+    while (*(temp++) != '\\0') {","path":"src/string.cpp","position":118,"original_position":118,"commit_id":"ab8dba44a62500339e6d3616af602c4b1721589d","original_commit_id":"ab8dba44a62500339e6d3616af602c4b1721589d","user":{"login":"sdukshis","id":751874,"avatar_url":"https://avatars.githubusercontent.com/u/751874?v=3","gravatar_id":"","url":"https://api.github.com/users/sdukshis","html_url":"https://github.com/sdukshis","followers_url":"https://api.github.com/users/sdukshis/followers","following_url":"https://api.github.com/users/sdukshis/following{/other_user}","gists_url":"https://api.github.com/users/sdukshis/gists{/gist_id}","starred_url":"https://api.github.com/users/sdukshis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdukshis/subscriptions","organizations_url":"https://api.github.com/users/sdukshis/orgs","repos_url":"https://api.github.com/users/sdukshis/repos","events_url":"https://api.github.com/users/sdukshis/events{/privacy}","received_events_url":"https://api.github.com/users/sdukshis/received_events","type":"User","site_admin":false},"body":"Следует использовать std::strlen или вынести реализацию в отдельную функцию.","created_at":"2016-03-01T12:56:04Z","updated_at":"2016-03-01T12:56:04Z","html_url":"https://github.com/ElenaVinogradova/String/pull/1#discussion_r54562544","pull_request_url":"https://api.github.com/repos/ElenaVinogradova/String/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/ElenaVinogradova/String/pulls/comments/54562544"},"html":{"href":"https://github.com/ElenaVinogradova/String/pull/1#discussion_r54562544"},"pull_request":{"href":"https://api.github.com/repos/ElenaVinogradova/String/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/ElenaVinogradova/String/pulls/1","id":60693378,"html_url":"https://github.com/ElenaVinogradova/String/pull/1","diff_url":"https://github.com/ElenaVinogradova/String/pull/1.diff","patch_url":"https://github.com/ElenaVinogradova/String/pull/1.patch","issue_url":"https://api.github.com/repos/ElenaVinogradova/String/issues/1","number":1,"state":"open","locked":false,"title":"Sst","user":{"login":"ElenaVinogradova","id":15254409,"avatar_url":"https://avatars.githubusercontent.com/u/15254409?v=3","gravatar_id":"","url":"https://api.github.com/users/ElenaVinogradova","html_url":"https://github.com/ElenaVinogradova","followers_url":"https://api.github.com/users/ElenaVinogradova/followers","following_url":"https://api.github.com/users/ElenaVinogradova/following{/other_user}","gists_url":"https://api.github.com/users/ElenaVinogradova/gists{/gist_id}","starred_url":"https://api.github.com/users/ElenaVinogradova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElenaVinogradova/subscriptions","organizations_url":"https://api.github.com/users/ElenaVinogradova/orgs","repos_url":"https://api.github.com/users/ElenaVinogradova/repos","events_url":"https://api.github.com/users/ElenaVinogradova/events{/privacy}","received_events_url":"https://api.github.com/users/ElenaVinogradova/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-25T15:13:44Z","updated_at":"2016-03-01T12:56:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7fd2cba7bc41125e35b1ad948cfffd987ef6c7a6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ElenaVinogradova/String/pulls/1/commits","review_comments_url":"https://api.github.com/repos/ElenaVinogradova/String/pulls/1/comments","review_comment_url":"https://api.github.com/repos/ElenaVinogradova/String/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ElenaVinogradova/String/issues/1/comments","statuses_url":"https://api.github.com/repos/ElenaVinogradova/String/statuses/ab8dba44a62500339e6d3616af602c4b1721589d","head":{"label":"ElenaVinogradova:sst","ref":"sst","sha":"ab8dba44a62500339e6d3616af602c4b1721589d","user":{"login":"ElenaVinogradova","id":15254409,"avatar_url":"https://avatars.githubusercontent.com/u/15254409?v=3","gravatar_id":"","url":"https://api.github.com/users/ElenaVinogradova","html_url":"https://github.com/ElenaVinogradova","followers_url":"https://api.github.com/users/ElenaVinogradova/followers","following_url":"https://api.github.com/users/ElenaVinogradova/following{/other_user}","gists_url":"https://api.github.com/users/ElenaVinogradova/gists{/gist_id}","starred_url":"https://api.github.com/users/ElenaVinogradova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElenaVinogradova/subscriptions","organizations_url":"https://api.github.com/users/ElenaVinogradova/orgs","repos_url":"https://api.github.com/users/ElenaVinogradova/repos","events_url":"https://api.github.com/users/ElenaVinogradova/events{/privacy}","received_events_url":"https://api.github.com/users/ElenaVinogradova/received_events","type":"User","site_admin":false},"repo":{"id":52530965,"name":"String","full_name":"ElenaVinogradova/String","owner":{"login":"ElenaVinogradova","id":15254409,"avatar_url":"https://avatars.githubusercontent.com/u/15254409?v=3","gravatar_id":"","url":"https://api.github.com/users/ElenaVinogradova","html_url":"https://github.com/ElenaVinogradova","followers_url":"https://api.github.com/users/ElenaVinogradova/followers","following_url":"https://api.github.com/users/ElenaVinogradova/following{/other_user}","gists_url":"https://api.github.com/users/ElenaVinogradova/gists{/gist_id}","starred_url":"https://api.github.com/users/ElenaVinogradova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElenaVinogradova/subscriptions","organizations_url":"https://api.github.com/users/ElenaVinogradova/orgs","repos_url":"https://api.github.com/users/ElenaVinogradova/repos","events_url":"https://api.github.com/users/ElenaVinogradova/events{/privacy}","received_events_url":"https://api.github.com/users/ElenaVinogradova/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ElenaVinogradova/String","description":"","fork":false,"url":"https://api.github.com/repos/ElenaVinogradova/String","forks_url":"https://api.github.com/repos/ElenaVinogradova/String/forks","keys_url":"https://api.github.com/repos/ElenaVinogradova/String/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ElenaVinogradova/String/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ElenaVinogradova/String/teams","hooks_url":"https://api.github.com/repos/ElenaVinogradova/String/hooks","issue_events_url":"https://api.github.com/repos/ElenaVinogradova/String/issues/events{/number}","events_url":"https://api.github.com/repos/ElenaVinogradova/String/events","assignees_url":"https://api.github.com/repos/ElenaVinogradova/String/assignees{/user}","branches_url":"https://api.github.com/repos/ElenaVinogradova/String/branches{/branch}","tags_url":"https://api.github.com/repos/ElenaVinogradova/String/tags","blobs_url":"https://api.github.com/repos/ElenaVinogradova/String/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ElenaVinogradova/String/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ElenaVinogradova/String/git/refs{/sha}","trees_url":"https://api.github.com/repos/ElenaVinogradova/String/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ElenaVinogradova/String/statuses/{sha}","languages_url":"https://api.github.com/repos/ElenaVinogradova/String/languages","stargazers_url":"https://api.github.com/repos/ElenaVinogradova/String/stargazers","contributors_url":"https://api.github.com/repos/ElenaVinogradova/String/contributors","subscribers_url":"https://api.github.com/repos/ElenaVinogradova/String/subscribers","subscription_url":"https://api.github.com/repos/ElenaVinogradova/String/subscription","commits_url":"https://api.github.com/repos/ElenaVinogradova/String/commits{/sha}","git_commits_url":"https://api.github.com/repos/ElenaVinogradova/String/git/commits{/sha}","comments_url":"https://api.github.com/repos/ElenaVinogradova/String/comments{/number}","issue_comment_url":"https://api.github.com/repos/ElenaVinogradova/String/issues/comments{/number}","contents_url":"https://api.github.com/repos/ElenaVinogradova/String/contents/{+path}","compare_url":"https://api.github.com/repos/ElenaVinogradova/String/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ElenaVinogradova/String/merges","archive_url":"https://api.github.com/repos/ElenaVinogradova/String/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ElenaVinogradova/String/downloads","issues_url":"https://api.github.com/repos/ElenaVinogradova/String/issues{/number}","pulls_url":"https://api.github.com/repos/ElenaVinogradova/String/pulls{/number}","milestones_url":"https://api.github.com/repos/ElenaVinogradova/String/milestones{/number}","notifications_url":"https://api.github.com/repos/ElenaVinogradova/String/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ElenaVinogradova/String/labels{/name}","releases_url":"https://api.github.com/repos/ElenaVinogradova/String/releases{/id}","deployments_url":"https://api.github.com/repos/ElenaVinogradova/String/deployments","created_at":"2016-02-25T14:26:48Z","updated_at":"2016-02-25T14:27:17Z","pushed_at":"2016-02-25T15:13:44Z","git_url":"git://github.com/ElenaVinogradova/String.git","ssh_url":"git@github.com:ElenaVinogradova/String.git","clone_url":"https://github.com/ElenaVinogradova/String.git","svn_url":"https://github.com/ElenaVinogradova/String","homepage":null,"size":6,"stargazers_count":0,"watchers_count":0,"language":"CMake","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"ElenaVinogradova:master","ref":"master","sha":"07976570e9982c28aec136074010dd0dafaa9c27","user":{"login":"ElenaVinogradova","id":15254409,"avatar_url":"https://avatars.githubusercontent.com/u/15254409?v=3","gravatar_id":"","url":"https://api.github.com/users/ElenaVinogradova","html_url":"https://github.com/ElenaVinogradova","followers_url":"https://api.github.com/users/ElenaVinogradova/followers","following_url":"https://api.github.com/users/ElenaVinogradova/following{/other_user}","gists_url":"https://api.github.com/users/ElenaVinogradova/gists{/gist_id}","starred_url":"https://api.github.com/users/ElenaVinogradova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElenaVinogradova/subscriptions","organizations_url":"https://api.github.com/users/ElenaVinogradova/orgs","repos_url":"https://api.github.com/users/ElenaVinogradova/repos","events_url":"https://api.github.com/users/ElenaVinogradova/events{/privacy}","received_events_url":"https://api.github.com/users/ElenaVinogradova/received_events","type":"User","site_admin":false},"repo":{"id":52530965,"name":"String","full_name":"ElenaVinogradova/String","owner":{"login":"ElenaVinogradova","id":15254409,"avatar_url":"https://avatars.githubusercontent.com/u/15254409?v=3","gravatar_id":"","url":"https://api.github.com/users/ElenaVinogradova","html_url":"https://github.com/ElenaVinogradova","followers_url":"https://api.github.com/users/ElenaVinogradova/followers","following_url":"https://api.github.com/users/ElenaVinogradova/following{/other_user}","gists_url":"https://api.github.com/users/ElenaVinogradova/gists{/gist_id}","starred_url":"https://api.github.com/users/ElenaVinogradova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElenaVinogradova/subscriptions","organizations_url":"https://api.github.com/users/ElenaVinogradova/orgs","repos_url":"https://api.github.com/users/ElenaVinogradova/repos","events_url":"https://api.github.com/users/ElenaVinogradova/events{/privacy}","received_events_url":"https://api.github.com/users/ElenaVinogradova/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ElenaVinogradova/String","description":"","fork":false,"url":"https://api.github.com/repos/ElenaVinogradova/String","forks_url":"https://api.github.com/repos/ElenaVinogradova/String/forks","keys_url":"https://api.github.com/repos/ElenaVinogradova/String/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ElenaVinogradova/String/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ElenaVinogradova/String/teams","hooks_url":"https://api.github.com/repos/ElenaVinogradova/String/hooks","issue_events_url":"https://api.github.com/repos/ElenaVinogradova/String/issues/events{/number}","events_url":"https://api.github.com/repos/ElenaVinogradova/String/events","assignees_url":"https://api.github.com/repos/ElenaVinogradova/String/assignees{/user}","branches_url":"https://api.github.com/repos/ElenaVinogradova/String/branches{/branch}","tags_url":"https://api.github.com/repos/ElenaVinogradova/String/tags","blobs_url":"https://api.github.com/repos/ElenaVinogradova/String/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ElenaVinogradova/String/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ElenaVinogradova/String/git/refs{/sha}","trees_url":"https://api.github.com/repos/ElenaVinogradova/String/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ElenaVinogradova/String/statuses/{sha}","languages_url":"https://api.github.com/repos/ElenaVinogradova/String/languages","stargazers_url":"https://api.github.com/repos/ElenaVinogradova/String/stargazers","contributors_url":"https://api.github.com/repos/ElenaVinogradova/String/contributors","subscribers_url":"https://api.github.com/repos/ElenaVinogradova/String/subscribers","subscription_url":"https://api.github.com/repos/ElenaVinogradova/String/subscription","commits_url":"https://api.github.com/repos/ElenaVinogradova/String/commits{/sha}","git_commits_url":"https://api.github.com/repos/ElenaVinogradova/String/git/commits{/sha}","comments_url":"https://api.github.com/repos/ElenaVinogradova/String/comments{/number}","issue_comment_url":"https://api.github.com/repos/ElenaVinogradova/String/issues/comments{/number}","contents_url":"https://api.github.com/repos/ElenaVinogradova/String/contents/{+path}","compare_url":"https://api.github.com/repos/ElenaVinogradova/String/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ElenaVinogradova/String/merges","archive_url":"https://api.github.com/repos/ElenaVinogradova/String/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ElenaVinogradova/String/downloads","issues_url":"https://api.github.com/repos/ElenaVinogradova/String/issues{/number}","pulls_url":"https://api.github.com/repos/ElenaVinogradova/String/pulls{/number}","milestones_url":"https://api.github.com/repos/ElenaVinogradova/String/milestones{/number}","notifications_url":"https://api.github.com/repos/ElenaVinogradova/String/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ElenaVinogradova/String/labels{/name}","releases_url":"https://api.github.com/repos/ElenaVinogradova/String/releases{/id}","deployments_url":"https://api.github.com/repos/ElenaVinogradova/String/deployments","created_at":"2016-02-25T14:26:48Z","updated_at":"2016-02-25T14:27:17Z","pushed_at":"2016-02-25T15:13:44Z","git_url":"git://github.com/ElenaVinogradova/String.git","ssh_url":"git@github.com:ElenaVinogradova/String.git","clone_url":"https://github.com/ElenaVinogradova/String.git","svn_url":"https://github.com/ElenaVinogradova/String","homepage":null,"size":6,"stargazers_count":0,"watchers_count":0,"language":"CMake","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ElenaVinogradova/String/pulls/1"},"html":{"href":"https://github.com/ElenaVinogradova/String/pull/1"},"issue":{"href":"https://api.github.com/repos/ElenaVinogradova/String/issues/1"},"comments":{"href":"https://api.github.com/repos/ElenaVinogradova/String/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/ElenaVinogradova/String/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/ElenaVinogradova/String/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ElenaVinogradova/String/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/ElenaVinogradova/String/statuses/ab8dba44a62500339e6d3616af602c4b1721589d"}}}}