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

📄 ustream.cpp

📁 模糊聚類分析源碼。包含教學文件
💻 CPP
字号:
/*    Context       : Basic Utility Files  Author        : Frank Hoeppner, see also AUTHORS file   Description   : implementation of function module ustream                  Source Documentation Handbook: tutorial-UTIL  History       :      Comment       :     This file was generated automatically. DO NOT EDIT.  Copyright     : Copyright (C) 1999-2000 Frank Hoeppner    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/#ifndef UtilStream_SOURCE#define UtilStream_SOURCE/* configuration include */#ifdef HAVE_CONFIG_H/*//FILETREE_IFDEF HAVE_CONFIG_H*/#include "config.h"/*//FILETREE_ENDIF*/#endif/* necessary includes */#include "ustream.hpp"#include "ustream-d.hpp"/* private typedefs *//* private functions *//* data *//* implementation */intread_white  (  istream& is  , char *p_text  , size_t maxlen  )  {  char c;  const int skipchars = 1;  bool storechars( (p_text!=NULL) && (maxlen>0) ); // true:store, false:skip  size_t stringlen(0); // no. of characters read  if (is.good())    {    do      {      is.get(c);      if (    (storechars)           && (stringlen<maxlen)         )        {        p_text[stringlen]=c;        }      ++stringlen;      }    while (    (is.good())            && (isspace(c))          );    is.putback(c);    }        {    size_t storelen(0);    if (storechars)      {      if (stringlen-skipchars<maxlen)        {        storelen = stringlen-skipchars;        }      else        {        storelen = maxlen;        }      p_text[storelen] = '\0';      }    return storelen;  }  }intread_word_break  (  istream& is,  const char * p_delimiter  , char *p_text  , size_t maxlen  )  {  char c;  int i;  bool cont;  bool nonempty((p_delimiter!=NULL) && (p_delimiter[0]!='\0'));  bool notfirst(false);  const int skipchars = 1;  bool storechars( (p_text!=NULL) && (maxlen>0) ); // true:store, false:skip  size_t stringlen(0); // no. of characters read  read_white(is);  if (is.good())    {    do      {      is.get(c);      cont = !isspace(c);      if (cont && nonempty && notfirst)         {         i=0;         while (p_delimiter[i]!='\0')           {           cont &= (c!=p_delimiter[i]);           ++i;           }        }      notfirst=true;      if (    (storechars)           && (stringlen<maxlen)         )        {        p_text[stringlen]=c;        }      ++stringlen;      }    while (    (is.good())            && (cont)          );    is.putback(c);    }      {    size_t storelen(0);    if (storechars)      {      if (stringlen-skipchars<maxlen)        {        storelen = stringlen-skipchars;        }      else        {        storelen = maxlen;        }      p_text[storelen] = '\0';      }    return storelen;  }  }boolread_until  (  istream& is,  const char * p_find  , char *p_text  , size_t maxlen  )  {  int matching = 0;  const int skipchars = strlen(p_find);  bool storechars( (p_text!=NULL) && (maxlen>0) ); // true:store, false:skip  size_t stringlen(0); // no. of characters read  if (    (p_find    != NULL)       && (p_find[0] != '\0')       && (is.good())     )    {    char c;    do      {      is.get(c);      if (c==p_find[matching])        {        ++matching;        }      else        {        matching = 0;        }        if (    (storechars)           && (stringlen<maxlen)         )        {        p_text[stringlen]=c;        }      ++stringlen;      }    while (    (matching<skipchars)            && (is.good())          );    {      size_t storelen(0);      if (storechars)        {        if (stringlen-skipchars<maxlen)          {          storelen = stringlen-skipchars;          }        else          {          storelen = maxlen;          }        p_text[storelen] = '\0';        }    }    }  return ((matching==skipchars) && (is.good() || is.eof()));  }intread_until_eof  (  istream& is  , char *p_text  , size_t maxlen    )  {  char c;  bool storechars( (p_text!=NULL) && (maxlen>0) ); // true:store, false:skip  size_t stringlen(0); // no. of characters read  if (is.good())    {    do      {      is.get(c);      if (    (storechars)           && (stringlen<maxlen)         )        {        p_text[stringlen]=c;        }      ++stringlen;      }    while (!is.eof());    }  {    size_t storelen(0);    if (storechars)      {      if (stringlen<maxlen)        {        storelen = stringlen;        }      else        {        storelen = maxlen;        }      p_text[storelen] = '\0';      }    return storelen;  }  }void read_entry  (  istream& is  , char *p_text  , size_t maxlen  )  {  read_white(is);  if (is_followed_by(is,"{",false))    {    read_until_matching_paranthesis(is,'{','}' , p_text, maxlen);    }  else if (is_followed_by(is,"\"",false))    {    read_until(is,"\"" , p_text, maxlen);    }  else    {    read_word_break(is,"," , p_text, maxlen);    }  }intread_lines_starting_with  (  istream& is,   const char* p_find  , char *p_text  , size_t maxlen  )  {  bool found;  size_t storelen = 0;    do    {    maxlen -= storelen;    read_white(is , p_text, maxlen);    found = is_followed_by(is,p_find);    if (found)       {       storelen += read_line(is , p_text, maxlen);      }    }  while (found);  return storelen;  }int read_until_matching_paranthesis  (  istream& is,   char ip,  char dp  , char *p_text  , size_t maxlen  )  {  char c;  const int skipchars = 1;  bool storechars( (p_text!=NULL) && (maxlen>0) ); // true:store, false:skip  size_t stringlen(0); // no. of characters read  int counter = 1;  while (    (counter!=0)           && (is.good())         )    {    is.get(c);    if ( c == ip )      {      ++counter;      }    else      {      if ( c == dp )        {        --counter;        }      }    if (    (storechars)         && (stringlen<maxlen)       )      {      p_text[stringlen]=c;      }    ++stringlen;    }  {    size_t storelen(0);    if (storechars)      {      if (stringlen-skipchars<maxlen)        {        storelen = stringlen-skipchars;        }      else        {        storelen = maxlen;        }      p_text[storelen] = '\0';      }    return storelen;  }  }boolread_data  (  istream& a_input_stream,  char_cc ap_keyword  , char *p_text  , size_t maxlen  )  {  a_input_stream.clear();  a_input_stream.seekg(ios::beg);  bool done;  do    {    done = (!read_until(a_input_stream,"{"));    if (!done)      {      if (is_followed_by(a_input_stream,ap_keyword,false))        {        read_white(a_input_stream);        read_until_matching_paranthesis(a_input_stream,'{','}' , p_text, maxlen);        return true;        }      else        {        read_until_matching_paranthesis(a_input_stream,'{','}');        }      done = itob(a_input_stream.eof());        }    }  while (!done);  return false;  }/* template instantiation */#endif /* UtilStream_SOURCE */

⌨️ 快捷键说明

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