クラス テンプレート toppers::basic_text< Container, CharT, Traits, Allocator >

テキストデータ管理テンプレートクラス [詳細]

#include "toppers/text.hpp"

toppers::basic_text< Container, CharT, Traits, Allocator >のコラボレーション図

Collaboration graph
[凡例]
すべてのメンバ一覧

Public 型

typedef basic_text< Container,
CharT, Traits, Allocator > 
self_t
typedef std::basic_string<
CharT, Traits, Allocator > 
string_type
typedef ::toppers::text_line line_type
typedef basic_line_buf< CharT,
Traits, Allocator > 
line_buf
typedef CharT value_type
typedef Container< line_buf,
std::allocator< line_buf > > 
container
typedef value_typereference
typedef const value_typeconst_reference
typedef value_typepointer
typedef const value_typeconst_pointer
typedef Allocator allocator_type
typedef Allocator::difference_type difference_type
typedef Allocator::size_type size_type
typedef std::reverse_iterator<
const_iterator
const_reverse_iterator
typedef std::reverse_iterator<
iterator
reverse_iterator

Public メソッド

 basic_text ()
 デフォルトコンストラクタ
 basic_text (const const_iterator &first, const const_iterator &last)
 コンストラクタ
template<class ForwardIterator>
 basic_text (ForwardIterator first, ForwardIterator last)
 コンストラクタ
template<class ForwardIterator, class Directive>
 basic_text (ForwardIterator first, ForwardIterator last, Directive directive)
 コンストラクタ
 basic_text (std::basic_istream< CharT, Traits > &istr)
 コンストラクタ
template<class Directive>
 basic_text (std::basic_istream< CharT, Traits > &istr, Directive directive)
 コンストラクタ
const_iterator begin () const
 先頭位置の取得
iterator begin ()
 先頭位置の取得
const_iterator end () const
 終端位置+1の取得
iterator end ()
 終端位置+1の取得
const_iterator rbegin () const
 逆順先頭位置の取得
iterator rbegin ()
 逆順先頭位置の取得
const_iterator rend () const
 逆順終端位置+1の取得
iterator rend ()
 逆順終端位置+1の取得
const_reference front () const
 先頭文字の参照
reference front ()
 先頭文字の参照
const_reference back () const
 終端文字の参照
reference back ()
 終端文字の参照
const_reference at (size_type pos) const
 指定位置の文字の参照
reference at (size_type pos)
 指定位置の文字の参照
void append (const const_iterator &first, const const_iterator &last)
 指定範囲のテキストデータを追加
template<class ForwardIterator>
void append (ForwardIterator first, ForwardIterator last)
 指定範囲のテキストデータを追加
template<class ForwardIterator, class Directive>
void append (ForwardIterator first, ForwardIterator last, Directive directive)
 指定範囲のテキストデータを追加
void append (std::basic_istream< CharT, Traits > &istr)
 指定範囲のテキストデータを追加
template<class Directive>
void append (std::basic_istream< CharT, Traits > &istr, Directive directive)
 指定範囲のテキストデータを追加
void assign (const const_iterator &first, const const_iterator &last)
 指定範囲のテキストデータを代入
template<class ForwardIterator>
void assign (ForwardIterator first, ForwardIterator last)
 指定範囲のテキストデータを代入
template<class ForwardIterator, class Directive>
void assign (ForwardIterator first, ForwardIterator last, Directive directive)
 指定範囲のテキストデータを代入
void assign (std::basic_istream< CharT, Traits > &istr)
 指定範囲のテキストデータを代入
template<class Directive>
void assign (std::basic_istream< CharT, Traits > &istr, Directive directive)
 指定範囲のテキストデータを代入
void push_back (value_type value)
 終端に文字を追加
void pop_back ()
 終端から文字を削除
bool empty () const
 コンテナが空かどうかの判別
size_type size () const
 コンテナのサイズ
void swap (self_t &other)
 コンテナの交換
void clear ()
 コンテナのクリア

構成

class  const_iterator
 toppers::basic_text のイテレータ [詳細]
class  iterator
 toppers::basic_text のイテレータ [詳細]

説明

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
class toppers::basic_text< Container, CharT, Traits, Allocator >

テキストデータ管理テンプレートクラス

ファイルから読み込んだテキストデータの管理を行うためのクラスです。 このクラスでは、テキストデータを単なる文字列としてではなく、入力元の ファイル名と行番号を付加した形で管理します。

覚え書き:
このクラスはテキスト編集の用途を想定したものではありません。

text.hpp76 行で定義されています。


コンストラクタとデストラクタ

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
toppers::basic_text< Container, CharT, Traits, Allocator >::basic_text const const_iterator first,
const const_iterator last
[inline]
 

コンストラクタ

引数:
first 初期化に用いるデータ列の先頭
last 初期化に用いるデータ列の終端+1

text.hpp207 行で定義されています。

00208     {
00209       if ( first != last )
00210       {
00211         init( first, last );
00212       }
00213     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
template<class ForwardIterator>
toppers::basic_text< Container, CharT, Traits, Allocator >::basic_text ForwardIterator  first,
ForwardIterator  last
[inline]
 

コンストラクタ

引数:
first 初期化に用いるデータ列の先頭
last 初期化に用いるデータ列の終端+1
覚え書き:
ファイル名は"unknown"になります。

text.hpp222 行で定義されています。

00223     {
00224       if ( first != last )
00225       {
00226         init( first, last, append_directive );
00227       }
00228     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
template<class ForwardIterator, class Directive>
toppers::basic_text< Container, CharT, Traits, Allocator >::basic_text ForwardIterator  first,
ForwardIterator  last,
Directive  directive
[inline]
 

コンストラクタ

引数:
first 初期化に用いるデータ列の先頭
last 初期化に用いるデータ列の終端+1
directive 1行をコンテナに格納するための処理
覚え書き:
ファイル名は"unknown"になります。
directive は void directive( container& cont, line_buf& buf )の形式を とる関数へのポインタまたはファンクタであることを想定しています。 cont は内部でデータの格納に使用するコンテナ、 buf は1行分の文字 列とファイル名・行番号を格納したバッファです。

text.hpp243 行で定義されています。

00244     {
00245       if ( first != last )
00246       {
00247         init( first, last, directive );
00248       }
00249     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
toppers::basic_text< Container, CharT, Traits, Allocator >::basic_text std::basic_istream< CharT, Traits > &  istr  )  [inline]
 

コンストラクタ

引数:
istr 初期化に用いる入力ストリーム
覚え書き:
ファイル名は"unknown"になります。

text.hpp256 行で定義されています。

00257     {
00258       if ( first != last )
00259       {
00260         init( istr, append_directive );
00261       }
00262     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
template<class Directive>
toppers::basic_text< Container, CharT, Traits, Allocator >::basic_text std::basic_istream< CharT, Traits > &  istr,
Directive  directive
[inline]
 

コンストラクタ

引数:
istr 初期化に用いる入力ストリーム
directive 1行をコンテナに格納するための処理
覚え書き:
ファイル名は"unknown"になります。
directive は void directive( container& cont, line_buf& buf )の形式を とる関数へのポインタまたはファンクタであることを想定しています。 cont は内部でデータの格納に使用するコンテナ、 buf は1行分の文字 列とファイル名・行番号を格納したバッファです。

text.hpp276 行で定義されています。

00277     {
00278       init( istr, directive );
00279     }


関数

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
template<class Directive>
void toppers::basic_text< Container, CharT, Traits, Allocator >::append std::basic_istream< CharT, Traits > &  istr,
Directive  directive
[inline]
 

指定範囲のテキストデータを追加

引数:
istr 追加に用いる入力ストリーム
directive 1行をコンテナに格納するための処理
覚え書き:
ファイル名と行番号は追加先の終端のものを継続します。 追加先にデータがない場合は"unknown"になります。
directive は void directive( container& cont, line_buf& buf )の形式を とる関数へのポインタまたはファンクタであることを想定しています。 cont は内部でデータの格納に使用するコンテナ、 buf は1行分の文字 列とファイル名・行番号を格納したバッファです。

text.hpp487 行で定義されています。

参照先 toppers::basic_text< Container, CharT, Traits, Allocator >::init().

00488     {
00489       self_t t( *this );
00490       t.init( istr, directive );
00491       swap( t );
00492     }

関数の呼び出しグラフ:

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
void toppers::basic_text< Container, CharT, Traits, Allocator >::append std::basic_istream< CharT, Traits > &  istr  )  [inline]
 

指定範囲のテキストデータを追加

引数:
istr 追加に用いる入力ストリーム
覚え書き:
ファイル名と行番号は追加先の終端のものを継続します。 追加先にデータがない場合は"unknown"になります。

text.hpp469 行で定義されています。

00470     {
00471       append( istr, append_directive );
00472     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
template<class ForwardIterator, class Directive>
void toppers::basic_text< Container, CharT, Traits, Allocator >::append ForwardIterator  first,
ForwardIterator  last,
Directive  directive
[inline]
 

指定範囲のテキストデータを追加

引数:
first 追加に用いるデータ列の先頭
last 追加に用いるデータ列の終端+1
directive 1行をコンテナに格納するための処理
覚え書き:
ファイル名と行番号は追加先の終端のものを継続します。 追加先にデータがない場合は"unknown"になります。
directive は void directive( container& cont, line_buf& buf )の形式を とる関数へのポインタまたはファンクタであることを想定しています。 cont は内部でデータの格納に使用するコンテナ、 buf は1行分の文字 列とファイル名・行番号を格納したバッファです。

text.hpp453 行で定義されています。

参照先 toppers::basic_text< Container, CharT, Traits, Allocator >::init().

00454     {
00455       if ( first != last )
00456       {
00457         self_t t( *this );
00458         t.init( first, last, directive );
00459         swap( t );
00460       }
00461     }

関数の呼び出しグラフ:

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
template<class ForwardIterator>
void toppers::basic_text< Container, CharT, Traits, Allocator >::append ForwardIterator  first,
ForwardIterator  last
[inline]
 

指定範囲のテキストデータを追加

引数:
first 追加に用いるデータ列の先頭
last 追加に用いるデータ列の終端+1
覚え書き:
ファイル名と行番号は追加先の終端のものを継続します。 追加先にデータがない場合は"unknown"になります。

text.hpp434 行で定義されています。

00435     {
00436       append( first, last, append_directive );
00437     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
void toppers::basic_text< Container, CharT, Traits, Allocator >::append const const_iterator first,
const const_iterator last
[inline]
 

指定範囲のテキストデータを追加

引数:
first 追加に用いるデータ列の先頭
last 追加に用いるデータ列の終端+1

text.hpp416 行で定義されています。

参照先 toppers::basic_text< Container, CharT, Traits, Allocator >::init().

00417     {
00418       if ( first != last )
00419       {
00420         self_t t( *this );
00421         t.init( first, last );
00422         swap( t );
00423       }
00424     }

関数の呼び出しグラフ:

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
template<class Directive>
void toppers::basic_text< Container, CharT, Traits, Allocator >::assign std::basic_istream< CharT, Traits > &  istr,
Directive  directive
[inline]
 

指定範囲のテキストデータを代入

引数:
istr 代入に用いる入力ストリーム
directive 1行をコンテナに格納するための処理
覚え書き:
ファイル名と行番号は代入先の終端のものを継続します。 追加先にデータがない場合は"unknown"になります。
directive は void directive( container& cont, line_buf& buf )の形式を とる関数へのポインタまたはファンクタであることを想定しています。 cont は内部でデータの格納に使用するコンテナ、 buf は1行分の文字 列とファイル名・行番号を格納したバッファです。

text.hpp562 行で定義されています。

00563     {
00564       self_t t( istr, directive );
00565       swap( t );
00566     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
void toppers::basic_text< Container, CharT, Traits, Allocator >::assign std::basic_istream< CharT, Traits > &  istr  )  [inline]
 

指定範囲のテキストデータを代入

引数:
istr 代入に用いる入力ストリーム
覚え書き:
ファイル名と行番号は代入先の終端のものを継続します。 追加先にデータがない場合は"unknown"になります。

text.hpp543 行で定義されています。

00544     {
00545       self_t t( istr, append_directive );
00546       swap( t );
00547     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
template<class ForwardIterator, class Directive>
void toppers::basic_text< Container, CharT, Traits, Allocator >::assign ForwardIterator  first,
ForwardIterator  last,
Directive  directive
[inline]
 

指定範囲のテキストデータを代入

引数:
first 代入に用いるデータ列の先頭
last 代入に用いるデータ列の終端+1
directive 1行をコンテナに格納するための処理
覚え書き:
ファイル名は"unknown"になります。
directive は void directive( container& cont, line_buf& buf )の形式を とる関数へのポインタまたはファンクタであることを想定しています。 cont は内部でデータの格納に使用するコンテナ、 buf は1行分の文字 列とファイル名・行番号を格納したバッファです。

text.hpp531 行で定義されています。

00532     {
00533       self_t t( first, last, directive );
00534       swap( t );
00535     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
template<class ForwardIterator>
void toppers::basic_text< Container, CharT, Traits, Allocator >::assign ForwardIterator  first,
ForwardIterator  last
[inline]
 

指定範囲のテキストデータを代入

引数:
first 代入に用いるデータ列の先頭
last 代入に用いるデータ列の終端+1
覚え書き:
ファイル名は"unknown"になります。

text.hpp512 行で定義されています。

00513     {
00514       self_t t( first, last, append_directive );
00515       swap( t );
00516     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
void toppers::basic_text< Container, CharT, Traits, Allocator >::assign const const_iterator first,
const const_iterator last
[inline]
 

指定範囲のテキストデータを代入

引数:
first 代入に用いるデータ列の先頭
last 代入に用いるデータ列の終端+1

text.hpp499 行で定義されています。

00500     {
00501       self_t t( first, last );
00502       swap( t );
00503     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
reference toppers::basic_text< Container, CharT, Traits, Allocator >::at size_type  pos  )  [inline]
 

指定位置の文字の参照

戻り値:
指定位置の文字への参照を返す

text.hpp406 行で定義されています。

00407     {
00408       return container_.front().buf_[pos];
00409     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
const_reference toppers::basic_text< Container, CharT, Traits, Allocator >::at size_type  pos  )  const [inline]
 

指定位置の文字の参照

戻り値:
指定位置の文字への参照を返す

text.hpp397 行で定義されています。

00398     {
00399       return container_.front().buf_[pos];
00400     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
reference toppers::basic_text< Container, CharT, Traits, Allocator >::back  )  [inline]
 

終端文字の参照

戻り値:
終端文字への参照を返す

text.hpp387 行で定義されています。

00388     {
00389       string_type* pbuf = &container_.back().buf_;
00390       return pbuf_->at( pbuf_->size()-1 );
00391     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
const_reference toppers::basic_text< Container, CharT, Traits, Allocator >::back  )  const [inline]
 

終端文字の参照

戻り値:
終端文字への参照を返す

text.hpp377 行で定義されています。

00378     {
00379       const string_type* pbuf = &container_.back().buf_;
00380       return pbuf_->at( pbuf_->size()-1 );
00381     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
iterator toppers::basic_text< Container, CharT, Traits, Allocator >::begin  )  [inline]
 

先頭位置の取得

戻り値:
先頭文字へのイテレータを返す

text.hpp294 行で定義されています。

00295     {
00296       return iterator( container_.begin() );
00297     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
const_iterator toppers::basic_text< Container, CharT, Traits, Allocator >::begin  )  const [inline]
 

先頭位置の取得

戻り値:
先頭文字へのイテレータを返す

text.hpp285 行で定義されています。

00286     {
00287       return const_iterator( container_.begin() );
00288     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
bool toppers::basic_text< Container, CharT, Traits, Allocator >::empty  )  const [inline]
 

コンテナが空かどうかの判別

戻り値:
空の場合は true を返す

text.hpp619 行で定義されています。

00620     {
00621       return container_.empty();
00622     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
iterator toppers::basic_text< Container, CharT, Traits, Allocator >::end  )  [inline]
 

終端位置+1の取得

戻り値:
終端文字の次要素へのイテレータを返す

text.hpp312 行で定義されています。

00313     {
00314       return iterator( container_.end() );
00315     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
const_iterator toppers::basic_text< Container, CharT, Traits, Allocator >::end  )  const [inline]
 

終端位置+1の取得

戻り値:
終端文字の次要素へのイテレータを返す

text.hpp303 行で定義されています。

00304     {
00305       return const_iterator( container_.end() );
00306     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
reference toppers::basic_text< Container, CharT, Traits, Allocator >::front  )  [inline]
 

先頭文字の参照

戻り値:
先頭文字への参照を返す

text.hpp368 行で定義されています。

00369     {
00370       return container_.front().buf_[0];
00371     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
const_reference toppers::basic_text< Container, CharT, Traits, Allocator >::front  )  const [inline]
 

先頭文字の参照

戻り値:
先頭文字への参照を返す

text.hpp359 行で定義されています。

00360     {
00361       return container_.front().buf_[0];
00362     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
void toppers::basic_text< Container, CharT, Traits, Allocator >::push_back value_type  value  )  [inline]
 

終端に文字を追加

引数:
value 追加する文字

text.hpp572 行で定義されています。

00573     {
00574       if ( container_.empty() )
00575       {
00576         line_buf buf( initial_line(), string_type( 1, value ) );
00577         container_.push_back( buf );
00578       }
00579       else
00580       {
00581         const string_type* pbuf = &container_.back().buf_;
00582         if ( pbuf_->at( pbuf_->size()-1 ) == widen( '\n' ) )
00583         {
00584           line_buf buf( initial_line(), string_type( 1, value ) );
00585           ++buf.line_.line_;
00586           container_.push_back( buf );
00587         }
00588         else
00589         {
00590           container_.back().buf_ += value;
00591         }
00592       }
00593     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
iterator toppers::basic_text< Container, CharT, Traits, Allocator >::rbegin  )  [inline]
 

逆順先頭位置の取得

戻り値:
逆順先頭文字への逆イテレータを返す

text.hpp331 行で定義されています。

00332     {
00333       string_type* pbuf = &container_.back().buf_;
00334       return reverse_iterator( container_.rbegin(), pbuf->empty() ? 0 : pbuf->size()-1 );
00335     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
const_iterator toppers::basic_text< Container, CharT, Traits, Allocator >::rbegin  )  const [inline]
 

逆順先頭位置の取得

戻り値:
逆順先頭文字への逆イテレータを返す

text.hpp321 行で定義されています。

00322     {
00323       const string_type* pbuf = &container_.back().buf_;
00324       return const_reverse_iterator( container_.rbegin(), pbuf->empty() ? 0 : pbuf->size()-1 );
00325     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
iterator toppers::basic_text< Container, CharT, Traits, Allocator >::rend  )  [inline]
 

逆順終端位置+1の取得

戻り値:
逆順終端文字の次要素への逆イテレータを返す

text.hpp350 行で定義されています。

00351     {
00352       return reverse_iterator( container_.rend() );
00353     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
const_iterator toppers::basic_text< Container, CharT, Traits, Allocator >::rend  )  const [inline]
 

逆順終端位置+1の取得

戻り値:
逆順終端文字の次要素への逆イテレータを返す

text.hpp341 行で定義されています。

00342     {
00343       return const_reverse_iterator( container_.rend(), container_.back().buf_.size()-1 );
00344     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
size_type toppers::basic_text< Container, CharT, Traits, Allocator >::size  )  const [inline]
 

コンテナのサイズ

戻り値:
コンテナに含まれている文字数を返す

text.hpp628 行で定義されています。

00629     {
00630       return std::accumulate( container_.begin(), container_.end(), size_type( 0 ), add_line_size );
00631     }

template<template< typename, class > class Container, typename CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
void toppers::basic_text< Container, CharT, Traits, Allocator >::swap self_t other  )  [inline]
 

コンテナの交換

引数:
other 交換対象となるコンテナ

text.hpp637 行で定義されています。

参照先 toppers::basic_text< Container, CharT, Traits, Allocator >::container_toppers::basic_text< Container, CharT, Traits, Allocator >::line_.

00638     {
00639       container_.swap( other.container_ );
00640       line_.swap( other.line_ );
00641     }


このクラスの説明は次のファイルから生成されました:
Copyright © 2006 by TAKAGI Nobuhisa.
このページは Wed Apr 12 16:32:04 2006 に Doxygen によって生成されました。