📄 test.cpp
字号:
struct string_char_traits <char> { typedef char char_type; static void assign (char_type& c1, const char_type& c2) { c1 = c2; } static bool eq (const char_type & c1, const char_type& c2) { return (c1 == c2); } static bool ne (const char_type& c1, const char_type& c2) { return (c1 != c2); } static bool lt (const char_type& c1, const char_type& c2) { return (c1 < c2); } static char_type eos () { return 0; } static bool is_del(char_type a) { return ((__ctype_b[(int) ( ( a ) )] & (unsigned short int) _ISspace ) != 0) ; } static int compare (const char_type* s1, const char_type* s2, size_t n) { return memcmp (s1, s2, n); } static size_t length (const char_type* s) { return strlen (s); } static char_type* copy (char_type* s1, const char_type* s2, size_t n) { return (char_type*) memcpy (s1, s2, n); } static char_type* move (char_type* s1, const char_type* s2, size_t n) { return (char_type*) memmove (s1, s2, n); } static char_type* set (char_type* s1, const char_type& c, size_t n) { return (char_type*) memset (s1, c, n); }};# 159 "/usr/include/g++/std/straits.h" 3} # 36 "/usr/include/g++/std/bastring.h" 2 3# 46 "/usr/include/g++/std/bastring.h" 3# 1 "/usr/include/g++/cassert" 1 3 # 1 "/usr/include/g++/std/cassert.h" 1 3 # 1 "/usr/i486-linux/include/assert.h" 1 3 # 19 "/usr/i486-linux/include/assert.h" 3 extern "C" {extern void __eprintf (const char *, const char *, unsigned, const char *) __attribute__ ((noreturn));}# 52 "/usr/i486-linux/include/assert.h" 3# 6 "/usr/include/g++/std/cassert.h" 2 3# 5 "/usr/include/g++/cassert" 2 3# 48 "/usr/include/g++/std/bastring.h" 2 3extern "C++" {class istream; class ostream; template <class charT, class traits = string_char_traits<charT> >struct __bsrep { typedef __bsrep Rep; size_t len, res, ref; bool selfish; charT* data () { return reinterpret_cast<charT *>(this + 1); } charT& operator[] (size_t s) { return data () [s]; } charT* grab () { if (selfish) return clone (); ++ref; return data (); } void release () { if (--ref == 0) delete this; } inline static void * operator new (size_t, size_t); inline static Rep* create (size_t); charT* clone (); inline void copy (size_t, const charT *, size_t); inline void move (size_t, const charT *, size_t); inline void set (size_t, const charT, size_t);# 91 "/usr/include/g++/std/bastring.h" 3 inline static bool excess_slop (size_t, size_t); inline static size_t frob_size (size_t);private: Rep &operator= (const Rep &);}; template <class charT, class traits = string_char_traits<charT> >class basic_string{private: typedef __bsrep<charT, traits> Rep;public: typedef traits traits_type; typedef charT value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef charT& reference; typedef const charT& const_reference; typedef charT* pointer; typedef const charT* const_pointer; typedef pointer iterator; typedef const_pointer const_iterator; static const size_type npos = static_cast<size_type>(-1);private: Rep *rep () const { return reinterpret_cast<Rep *>(dat) - 1; } void repup (Rep *p) { rep ()->release (); dat = p->data (); }public: const charT* data () const { return rep ()->data(); } size_type length () const { return rep ()->len; } size_type size () const { return rep ()->len; } size_type capacity () const { return rep ()->res; } size_type max_size () const { return npos - 1; } bool empty () const { return size () == 0; } basic_string& operator= (const basic_string& str) { if (&str != this) { rep ()->release (); dat = str.rep ()->grab (); } return *this; } explicit basic_string (): dat (nilRep.grab ()) { } basic_string (const basic_string& str): dat (str.rep ()->grab ()) { } basic_string (const basic_string& str, size_type pos, size_type n = npos) : dat (nilRep.grab ()) { assign (str, pos, n); } basic_string (const charT* s, size_type n) : dat (nilRep.grab ()) { assign (s, n); } basic_string (const charT* s) : dat (nilRep.grab ()) { assign (s); } basic_string (size_type n, charT c) : dat (nilRep.grab ()) { assign (n, c); } ~basic_string () { rep ()->release (); } void swap (basic_string &s) { charT *d = dat; dat = s.dat; s.dat = d; } basic_string& append (const basic_string& str, size_type pos = 0, size_type n = npos) { return replace (length (), 0, str, pos, n); } basic_string& append (const charT* s, size_type n) { return replace (length (), 0, s, n); } basic_string& append (const charT* s) { return append (s, traits::length (s)); } basic_string& append (size_type n, charT c) { return replace (length (), 0, n, c); } basic_string& assign (const basic_string& str, size_type pos = 0, size_type n = npos) { return replace (0, npos, str, pos, n); } basic_string& assign (const charT* s, size_type n) { return replace (0, npos, s, n); } basic_string& assign (const charT* s) { return assign (s, traits::length (s)); } basic_string& assign (size_type n, charT c) { return replace (0, npos, n, c); } basic_string& operator= (const charT* s) { return assign (s); } basic_string& operator= (charT c) { return assign (1, c); } basic_string& operator+= (const basic_string& rhs) { return append (rhs); } basic_string& operator+= (const charT* s) { return append (s); } basic_string& operator+= (charT c) { return append (1, c); } basic_string& insert (size_type pos1, const basic_string& str, size_type pos2 = 0, size_type n = npos) { return replace (pos1, 0, str, pos2, n); } basic_string& insert (size_type pos, const charT* s, size_type n) { return replace (pos, 0, s, n); } basic_string& insert (size_type pos, const charT* s) { return insert (pos, s, traits::length (s)); } basic_string& insert (size_type pos, size_type n, charT c) { return replace (pos, 0, n, c); } iterator insert(iterator p, charT c) { insert (p - begin (), 1, c); return p; } iterator insert(iterator p, size_type n, charT c) { insert (p - begin (), n, c); return p; } basic_string& remove (size_type pos = 0, size_type n = npos) { return replace (pos, n, 0, (charT)0); } basic_string& remove (iterator pos) { return replace (pos - begin (), 1, 0, (charT)0); } basic_string& remove (iterator first, iterator last) { return replace (first - begin (), last - first, 0, (charT)0); } basic_string& replace (size_type pos1, size_type n1, const basic_string& str, size_type pos2 = 0, size_type n2 = npos); basic_string& replace (size_type pos, size_type n1, const charT* s, size_type n2); basic_string& replace (size_type pos, size_type n1, const charT* s) { return replace (pos, n1, s, traits::length (s)); } basic_string& replace (size_type pos, size_type n1, size_type n2, charT c); basic_string& replace (size_type pos, size_type n, charT c) { return replace (pos, n, 1, c); } basic_string& replace (iterator i1, iterator i2, const basic_string& str) { return replace (i1 - begin (), i2 - i1, str); } basic_string& replace (iterator i1, iterator i2, const charT* s, size_type n) { return replace (i1 - begin (), i2 - i1, s, n); } basic_string& replace (iterator i1, iterator i2, const charT* s) { return replace (i1 - begin (), i2 - i1, s); } basic_string& replace (iterator i1, iterator i2, size_type n, charT c) { return replace (i1 - begin (), i2 - i1, n, c); }private: static charT eos () { return traits::eos (); } void unique () { if (rep ()->ref > 1) alloc (capacity (), true); } void selfish () { unique (); rep ()->selfish = true; }public: charT operator[] (size_type pos) const { if (pos == length ()) return eos (); return data ()[pos]; } reference operator[] (size_type pos) { unique (); return (*rep ())[pos]; } reference at (size_type pos) { ((void) (( !( pos >= length () ) ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/usr/include/g++/std/bastring.h" , 280 , "!(pos >= length ())" ), 0) )) ; return (*this)[pos]; } const_reference at (size_type pos) const { ((void) (( !( pos >= length () ) ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/usr/include/g++/std/bastring.h" , 285 , "!(pos >= length ())" ), 0) )) ; return data ()[pos]; }private: void terminate () const { traits::assign ((*rep ())[length ()], eos ()); }public: const charT* c_str () const { terminate (); return data (); } void resize (size_type n, charT c); void resize (size_type n) { resize (n, eos ()); } void reserve (size_type) { } size_type copy (charT* s, size_type n, size_type pos = 0); size_type find (const basic_string& str, size_type pos = 0) const { return find (str.data(), pos, str.length()); } size_type find (const charT* s, size_type pos, size_type n) const; size_type find (const charT* s, size_type pos = 0) const { return find (s, pos, traits::length (s)); } size_type find (charT c, size_type pos = 0) const; size_type rfind (const basic_string& str, size_type pos = npos) const { return rfind (str.data(), pos, str.length()); } size_type rfind (const charT* s, size_type pos, size_type n) const; size_type rfind (const charT* s, size_type pos = npos) const { return rfind (s, pos, traits::length (s)); } size_type rfind (charT c, size_type pos = npos) const; size_type find_first_of (const basic_string& str, size_type pos = 0) const { return find_first_of (str.data(), pos, str.length()); } size_type find_first_of (const charT* s, size_type pos, size_type n) const; size_type find_first_of (const charT* s, size_type pos = 0) const { return find_first_of (s, pos, traits::length (s)); } size_type find_first_of (charT c, size_type pos = 0) const { return find (c, pos); } size_type find_last_of (const basic_string& str, size_type pos = npos) const { return find_last_of (str.data(), pos, str.length()); } size_type find_last_of (const charT* s, size_type pos, size_type n) const; size_type find_last_of (const charT* s, size_type pos = npos) const { return find_last_of (s, pos, traits::length (s)); } size_type find_last_of (charT c, size_type pos = npos) const { return rfind (c, pos); } size_type find_first_not_of (const basic_string& str, size_type pos = 0) const { return find_first_not_of (str.data(), pos, str.length()); } size_type find_first_not_of (const charT* s, size_type pos, size_type n) const; size_type find_first_not_of (const charT* s, size_type pos = 0) const { return find_first_not_of (s, pos, traits::length (s)); } size_type find_first_not_of (charT c, size_type pos = 0) const; size_type find_last_not_of (const basic_string& str, size_type pos = npos) const { return find_last_not_of (str.data(), pos, str.length()); } size_type find_last_not_of (const charT* s, size_type pos, size_type n) const; size_type find_last_not_of (const charT* s, size_type pos = npos) const { return find_last_not_of (s, pos, traits::length (s)); } size_type find_last_not_of (charT c, size_type pos = npos) const; basic_string substr (size_type pos = 0, size_type n = npos) const { return basic_string (*this, pos, n); } int compare (const basic_string& str, size_type pos = 0, size_type n = npos) const; int compare (const charT* s, size_type pos, size_type n) const; int compare (const charT* s, size_type pos = 0) const { return compare (s, pos, traits::length (s)); } iterator begin () { selfish (); return &(*this)[0]; } iterator end () { selfish (); return &(*this)[length ()]; } const_iterator begin () const { return &(*rep ())[0]; } const_iterator end () const { return &(*rep ())[length ()]; }private: void alloc (size_type size, bool save); static size_type _find (const charT* ptr, charT c, size_type xpos, size_type len); inline bool check_realloc (size_type s) const; static Rep nilRep; charT *dat;};template <class charT, class traits>inline basic_string <charT, traits>operator+ (const basic_string <charT, traits>& lhs, const basic_string <charT, traits>& rhs){ basic_string <charT, traits> str (lhs); str.append (rhs); return str;}template <class charT, class traits>inline basic_string <charT, traits>operator+ (const charT* lhs, const basic_string <charT, traits>& rhs){ basic_string <charT, traits> str (lhs); str.append (rhs); return str;}template <class charT, class traits>inline basic_string <charT, traits>operator+ (charT lhs, const basic_string <charT, traits>& rhs){ basic_string <charT, traits> str (1, lhs); str.append (rhs); return str;}template <class charT, class traits>inline basic_string <charT, traits>operator+ (const basic_string <charT, traits>& lhs, const charT* rhs){ basic_string <charT, traits> str (lhs); str.append (rhs); return str;}template <class charT, class traits>inline basic_string <charT, traits>operator+ (const basic_string <charT, traits>& lhs, charT rhs){ basic_string <charT, traits> str (lhs); str.append (1, rhs); return str;}template <class charT, class traits>inline booloperator== (const basic_string <charT, traits>& lhs, const basic_string <charT, traits>& rhs){ return (lhs.compare (rhs) == 0);}template <class charT, class traits>inline booloperator== (const charT* lhs, const basic_string <charT, traits>& rhs){ return (rhs.compare (lhs) == 0);}template <class charT, class traits>inline booloperator== (const basic_string <charT, traits>& lhs, const charT* rhs){ return (lhs.compare (rhs) == 0);}template <class charT, class traits>inline booloperator!= (const charT* lhs, const basic_string <charT, traits>& rhs){ return (rhs.compare (lhs) != 0);}template <class charT, class traits>inline booloperator!= (const basic_string <charT, traits>& lhs, const charT* rhs){ return (lhs.compare (rhs) != 0);}template <class charT, class traits>inline booloperator< (const basic_string <charT, traits>& lhs, const basic_string <charT, traits>& rhs){ return (lhs.compare (rhs) < 0);}template <class charT, class traits>inline booloperator< (const charT* lhs, const basic_string <charT, traits>& rhs){ return (rhs.compare (lhs) > 0);}template <class charT, class traits>inline booloperator< (const basic_string <charT, traits>& lhs, const charT* rhs){ return (lhs.compare (rhs) < 0);}template <class charT, class traits>inline booloperator> (const charT* lhs, const basic_string <charT, traits>& rhs){ return (rhs.compare (lhs) < 0);}template <class charT, class traits>inline booloperator> (const basic_string <charT, traits>& lhs, const charT* rhs){ return (lhs.compare (rhs) > 0);}template <class charT, class traits>inline booloperator<= (const charT* lhs, const basic_string <charT, traits>& rhs){ return (rhs.compare (lhs) >= 0);}template <class charT, class traits>inline booloperator<= (const basic_string <charT, traits>& lhs, const charT* rhs){ return (lhs.compare (rhs) <= 0);}template <class charT, class traits>inline booloperator>= (const charT* lhs, const basic_string <charT, traits>& rhs){ return (rhs.compare (lhs) <= 0);}template <class charT, class traits>inline booloperator>= (const basic_string <charT, traits>& lhs, const charT* rhs){ return (lhs.compare (rhs) >= 0);} template <class charT, class traits>inline booloperator!= (const basic_string <charT, traits>& lhs, const basic_string <charT, traits>& rhs){ return (lhs.compare (rhs) != 0);}template <class charT, class traits>inline booloperator> (const basic_string <charT, traits>& lhs, const basic_string <charT, traits>& rhs){ return (lhs.compare (rhs) > 0);}template <class charT, class traits>inline booloperator<= (const basic_string <charT, traits>& lhs, const basic_string <charT, traits>& rhs){ return (lhs.compare (rhs) <= 0);}template <class charT, class traits>inline booloperator>= (const basic_string <charT, traits>& lhs, const basic_string <charT, traits>& rhs){ return (lhs.compare (rhs) >= 0);}class istream; class ostream;template <class charT, class traits> istream&operator>> (istream&, basic_string <charT, traits>&);template <class charT, class traits> ostream&operator<< (ostream&, const basic_string <charT, traits>&);template <class charT, class traits> istream&getline (istream&, basic_string <charT, traits>&, charT delim = '\n');} # 1 "/usr/include/g++/std/sinst.h" 1 3 extern "C++" { extern template class __bsrep<char, string_char_traits<char> >;extern template class basic_string<char,string_char_traits<char> > ; extern template basic_string<char,string_char_traits<char> > operator + (const basic_string<char,string_char_traits<char> > &, const basic_string<char,string_char_traits<char> > &); extern template basic_string<char,string_char_traits<char> > operator + (const char *, const basic_string<char,string_char_traits<char> > &); extern template basic_string<char,string_char_traits<char> > operator + (const basic_string<char,string_char_traits<char> > &, const char *); extern template basic_string<char,string_char_traits<char> > operator + ( char , const basic_string<char,string_char_traits<char> > &); extern template basic_string<char,string_char_traits<char> > operator + (const basic_string<char,string_char_traits<char> > &, char ); extern template bool operator == (const basic_string<char,string_char_traits<char> > &, const basic_string<char,string_char_traits<char> > &); extern template bool operator == (const char *, const basic_string<char,string_char_traits<char> > &); extern template bool operator == (const basic_string<char,string_char_traits<char> > &, const char *); extern template bool operator != (const basic_string<char,string_char_traits<char> > &, const basic_string<char,string_char_traits<char> > &); extern template bool operator != (const char *, const basic_string<char,string_char_traits<char> > &); extern template bool operator != (const basic_string<char,string_char_traits<char> > &, const char *); extern template bool operator < (const basic_string<char,string_char_traits<char> > &, const basic_string<char,string_char_traits<char> > &); extern template bool operator < (const char *, const basic_string<char,string_char_traits<char> > &); extern template bool operator < (const basic_string<char,string_char_traits<char> > &, const char *); extern template bool operator > (const basic_string<char,string_char_traits<char> > &, const basic_string<char,string_char_traits<char> > &); extern template bool operator > (const char *, const basic_string<char,string_char_traits<char> > &); extern template bool operator > (const basic_string<char,string_char_traits<char> > &, const char *); extern template bool operator <= (const basic_string<char,string_char_traits<char> > &, const basic_string<char,string_char_traits<char> > &); extern template bool operator <= (const char *, const basic_string<char,string_char_traits<char> > &); extern template bool operator <= (const basic_string<char,string_char_traits<char> > &, const char *); extern template bool operator >= (const basic_string<char,string_char_traits<char> > &, const basic_string<char,string_char_traits<char> > &); extern template bool operator >= (const char *, const basic_string<char,string_char_traits<char> > &); extern template bool operator >= (const basic_string<char,string_char_traits<char> > &, const char *); } # 571 "/usr/include/g++/std/bastring.h" 2 3# 6 "/usr/include/g++/std/string.h" 2 3extern "C++" {typedef basic_string <char, string_char_traits <char> > string; } # 13 "CodeFrags.h" 2 class CodeFrags{public: CodeFrags (istream &i, const string &l) : input (i), lang (l) {atFrag = 0;} int nextFrag (); int hasFrag () const {return atFrag;} void outputFrag (ostream &output); int eof () const {return input.eof ();}protected: istream &input; const string lang; string line; int atFrag; void nextSection ();};# 11 "CodeFrags.cpp" 2static const string sectionSep ("*");int CodeFrags::nextFrag (){ nextSection (); atFrag = 0; while (!input.eof () && line.length () != 0 && line != lang) { if (line == sectionSep) return 0; getline (input, line); } atFrag = !input.eof (); getline (input, line); return atFrag;}void CodeFrags::nextSection (){ while (line != sectionSep && !input.eof ()) { getline (input, line); }; getline (input, line);}void CodeFrags::outputFrag (ostream &output){ if (hasFrag) { while (line [0] == '>' && !input.eof ()) { if (line.length () > 1) output << line.substr (1, line.length () - 1) << endl; else output << endl; getline (input, line); } } atFrag = 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -