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

📄 astring.hh

📁 COOOL:CWP面向对象最优化库(CWP Object Oriented Optimization Library) COOOL是C++类的一个集合
💻 HH
字号:
//============================================================// COOOL           version 1.1           ---     Nov,  1995//   Center for Wave Phenomena, Colorado School of Mines//============================================================////   This code is part of a preliminary release of COOOL (CWP// Object-Oriented Optimization Library) and associated class // libraries. //// The COOOL library is a free software. You can do anything you want// with it including make a fortune.  However, neither the authors,// the Center for Wave Phenomena, nor anyone else you can think of// makes any guarantees about anything in this package or any aspect// of its functionality.//// Since you've got the source code you can also modify the// library to suit your own purposes. We would appreciate it // if the headers that identify the authors are kept in the // source code.//// from Martin Smith's  AString class //======================#ifndef _AString_hh#define _AString_hh#include "defs.hh"// .NAME AString - simple string class// .LIBRARY c++u// .HEADER c++ utility classes// .INCLUDE c++/AString.hh// .FILE AString.cc// .SECTION Description// .B AString// is a simple string class that manages its own storage.// It allows concatenation of strings using + and +=,// assignment using =, and equality tests using ==.#ifndef TRUE#define TRUE 1#endif#ifndef FALSE#define FALSE 0#endif//@Man://@Memo: a simple string class that manages its own storage/*@Doc:  This is a simple string class that manages its own storage. It allows concatenation of strings using + and +=, assignment using =, and equality tests using ==.*/class AString {   private:      //@ManMemo: the number of chars in s. -1 -> not known         int		len;		   //@ManMemo: amount of memory allocated for this string   int		mem;		   //@ManMemo: grab memory in hunks of this size   int		chunk_size;       ///      void	bigEnough(const int);   ///       void	initVars();   ///      int		inRange(const long) const;   //@ManMemo: assigns to len.   void	length(const int new_length);   protected:    //@ManMemo: the internal string    char*	contents;    //@ManMemo:  type conversion constructor   AString(const char);   ///   int		compare(const AString&) const;   ///   int		compare(const char*) const;   ///   void	concat(const AString&);   ///   void	concat(const char*);   ///   void	concat(const char&);   ///   void	copy(const AString&);   ///   void	copy(const char*);   ///   void	copy(const char&);   ///   int		isNull() const;  public:   //@ManMemo: default constructor   AString();			   //@ManMemo:  type conversion constructor   AString(const char*);	   //@ManMemo:  copy constructor   AString(const AString&);	   ~AString();			   //@ManMemo:  what size hunks is memory grabbed in    int		chunksize() const;    //@ManMemo:  change size of memory hunks    void	chunksize(const int new_size);    //@ManMemo:  is the string empty or NULL    int		empty() const;		          //@ManMemo:  how many chars in AString    int		length() const;		             //@ManMemo: Class name   const char* className() const;   //@ManMemo:  assignment    AString& 	operator=(const AString&);        //@ManMemo:  assignment    AString& 	operator=(const char*);	          //@ManMemo:  return ith char, i < length()    const char&	operator[](const long i)const;     //@ManMemo:  concatenation    AString&	operator+=(const AString&);       //@ManMemo:  concatenation    AString&	operator+=(const char*);          //@ManMemo:  conversion function    operator const char*() const;   //@ManMemo:  convert to lower cases   AString	asLowerCase() const;   //@ManMemo:  concatenationfriend AString operator+(const AString&, const AString&);   //@ManMemo:  concatenationfriend AString operator+(const AString&, const char*);   //@ManMemo:  concatenationfriend AString operator+(const char*, const AString&);   //@ManMemo:  equalityfriend int operator==(const AString&, const AString&);   //@ManMemo:  equalityfriend int operator==(const AString&, const char*);   //@ManMemo:  equalityfriend int operator==(const char*, const AString&);friend int operator!=(const AString&, const AString&);   //@ManMemo:  inequalityfriend int operator!=(const AString&, const char*);   //@ManMemo:  inequalityfriend int operator!=(const char*, const AString&);   //@ManMemo:  greater thanfriend int operator>(const AString&, const AString&);   //@ManMemo:  greater thanfriend int operator>(const AString&, const char*);   //@ManMemo:  greater thanfriend int operator>(const char*, const AString&);   //@ManMemo:  greater than or equal tofriend int operator>=(const AString&, const AString&);   //@ManMemo:  greater than or equal tofriend int operator>=(const AString&, const char*);   //@ManMemo:  greater than or equal tofriend int operator>=(const char*, const AString&);   //@ManMemo:   less thanfriend int operator<(const AString&, const AString&);   //@ManMemo:   less thanfriend int operator<(const AString&, const char*);   //@ManMemo:   less thanfriend int operator<(const char*, const AString&);   //@ManMemo:  less than or equal tofriend int operator<=(const AString&, const AString&);   //@ManMemo:  less than or equal tofriend int operator<=(const AString&, const char*);   //@ManMemo:  less than or equal tofriend int operator<=(const char*, const AString&);   //@ManMemo:  stream I/Ofriend ostream& operator<<(ostream&, const AString&);   //@ManMemo:  stream I/Ofriend istream& operator>>(istream&, AString&); };AString ASFormat(char*, ...);AString toAS(unsigned char);AString toAS(char);AString toAS(unsigned short);AString toAS(short);AString toAS(unsigned int);AString toAS(int);AString toAS(unsigned long);AString toAS(long);AString toAS(double);#endif

⌨️ 快捷键说明

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