Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "BookInformation.h"
- void ifAuthor(string &book, const unsigned int &nOfStr, unsigned int &index)
- {
- // запись имени автора в строку
- unsigned int headIndex = index;
- index = book.find('|');
- string author = book.substr(headIndex, index);
- book[index] = ' ';
- cout << "headIndex: " << headIndex << endl << "index: " << index << endl;
- cout << "BOOK: " << book << endl << "STRING: " << author << endl;
- // проверка наличия одного(!) пробела
- unsigned int nSpaces = 0;
- for (unsigned int i = 0; i <= author.size(); ++i)
- {
- if (author[i] == ' ')
- ++nSpaces;
- if (nSpaces > 1)
- throw nOfStr;
- }
- if (nSpaces != 1)
- throw nOfStr;
- // проверка, что первая буква - прописная
- unsigned int iLetter = headIndex;
- int firstCode = static_cast<int>(author[iLetter]);
- if (!((((firstCode >= -64) && (firstCode <= -33)) || firstCode == -88)))
- throw nOfStr;
- // проверка "амилия"
- ++iLetter;
- for (; author[iLetter] != ' '; ++iLetter)
- {
- int codeOfNumber = static_cast<int>(author[iLetter]);
- if (!(((codeOfNumber >= -32) && (codeOfNumber <= -1)) || codeOfNumber == -72))
- throw nOfStr;
- }
- ++iLetter;
- int nameInitial = static_cast<int>(author[iLetter]);
- int patronymicInitial = static_cast<int>(author[iLetter + 2]);
- if (!((((nameInitial >= -64) && (nameInitial <= -33)) || nameInitial == -88) &&
- (((patronymicInitial >= -64) && (patronymicInitial <= -33)) || patronymicInitial == -88) &&
- (author[iLetter + 1] == '.') && (author[iLetter + 3] == '.')))
- throw nOfStr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement