⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 identif.cpp

📁 Design Componenet With C++ STL配套书源代码
💻 CPP
字号:
// k2/identify/identif.cpp#include"identif.h"#include<cctype>// please remove the following macro if your// compiler supports sentry-objects// sentry does not work in GNU C++ compilers before version 3.0#define SENTRY_NOT_YET_IMPLEMENTEDstd::istream& operator>>(std::istream& is, Identifier& N) {#ifndef SENTRY_NOT_YET_IMPLEMENTED    std::istream::sentry s(is);    if(!s) return is;#endif    /* The constructor of the sentry-object carries       out system dependent work. In particular, it checks the input       stream so that in case of error, we can terminate       the >> -operator immediately (see Kreft and Langer, 1999).         */    std::string tempIdentifier;    // find beginning of word    char c = '\0';    while(is && !(isalpha(c) || '_' == c))          is.get(c);    tempIdentifier += c;    /* When the beginning is found, all following underscores and       alphanumeric characters are collected. `White space' or a       special character terminate the reading process. */    // collect the rest    while(is && (isalnum(c) || '_' == c)) {       is.get(c);       if(isalnum(c) || '_' == c)         tempIdentifier += c;    }    /* The last character read does not belong to the identifier. The       iostream} library provides the possibility of returning an       unused character to the input so that it is available to a       subsequent program. */    is.putback(c);   // back into the input stream    N.theIdentifier = tempIdentifier;    return is;}/* Implementation of the output operator is very easy; the internal   string variable of an identifier is passed to the output os: */std::ostream& operator<<(std::ostream& os, const Identifier& N) {#ifndef SENTRY_NOT_YET_IMPLEMENTED    std::ostream::sentry s(os);    if(s) #endif       os << N.toString();    return os;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -