00001 #ifndef GAME_SYOKUNIN_COM_SAPLING_SCRIBBLE_H 00002 00003 #define GAME_SYOKUNIN_COM_SAPLING_SCRIBBLE_H 00004 00005 /* 00006 gslib/sapling/scribble.h 00007 00008 zlib/libpng license 00009 ------------------- 00010 00011 Copyright (C) 2004 &o 00012 00013 This software is provided 'as-is', without any express or implied warranty. In n 00014 o event will the authors be held liable for any damages arising from the use of 00015 this software. 00016 00017 Permission is granted to anyone to use this software for any purpose, including 00018 commercial applications, and to alter it and redistribute it freely, subject to 00019 the following restrictions: 00020 00021 The origin of this software must not be misrepresented; you must not claim that 00022 you wrote the original software. If you use this software in a product, an ackno 00023 wledgment in the product documentation would be appreciated but is not required. 00024 00025 Altered source versions must be plainly marked as such, and must not be misrepre 00026 sented as being the original software. 00027 This notice may not be removed or altered from any source distribution. 00028 00029 project site : https://sourceforge.jp/projects/gslib/ 00030 my site : http://www.game-syokunin.com/ 00031 -------------------------------------------------------------------------------- 00032 00033 法的には、上記の原文のほうが有効なので、より厳密には日本語訳よりも原文を参考にし 00034 てください。日本語訳は、http://opensource.jp/licenses/zlib-license.html から頂い 00035 てきました。 00036 00037 zlib/libpngライセンス ( 日本語訳 ) 00038 00039 Copyright (C) 2004 &o 00040 00041 本ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証も 00042 なく提供されます。本ソフトウェアの使用によって生じるいかなる損害についても、作者 00043 は一切の責任を負わないものとします。 以下の制限に従う限り、商用アプリケーション 00044 を含めて、本ソフトウェアを任意の目的に使用し、自由に改変して再頒布することをすべ 00045 ての人に許可します。 00046 00047 本ソフトウェアの出自について虚偽の表示をしてはなりません。あなたがオリジナルのソ 00048 フトウェアを作成したと主張してはなりません。あなたが本ソフトウェアを製品内で使用 00049 する場合、製品の文書に謝辞をれていただければ幸いですが、必須ではありません。 00050 ソースを変更した場合は、そのことを明示しなければなりません。オリジナルのソフトウ 00051 ェアであるという虚偽の表示をしてはなりません。 00052 ソースの頒布物から、この表示を削除したり、表示の内容を変更したりしてはなりません 00053 。 00054 00055 project site : https://sourceforge.jp/projects/gslib/ 00056 my site : http://www.game-syokunin.com/ 00057 */ 00058 00059 #include <gslib/sapling/tree.h> 00060 00061 namespace gslib { 00062 namespace sapling { 00063 00065 template < typename Value, typename Allocator > 00066 class scribbler { 00067 typedef tree< 00068 Value, 00069 Allocator > tree_type; 00070 typedef typename tree_type::sibling_iterator iterator; 00071 typedef typename tree_type::const_reference const_reference; 00072 tree_type& tree_; 00073 iterator cur_; 00074 public: 00075 scribbler( tree_type& t ) : tree_( t ) { 00076 cur_ = tree_.end_sibling(); 00077 } 00078 00079 scribbler& b( const_reference v ) { 00080 cur_ = tree_.insert( cur_, v ).end(); 00081 return *this; 00082 } 00083 00084 scribbler& e() { 00085 cur_ = cur_.parent().next(); 00086 return *this; 00087 } 00088 00089 scribbler& operator () ( const_reference v ) { 00090 cur_ = tree_.insert( cur_, v ).next(); 00091 return *this; 00092 } 00093 }; 00094 00096 00117 template < typename Value, typename Allocator > 00118 scribbler< Value, Allocator > scribble( tree< Value, Allocator >& t ) { 00119 BOOST_ASSERT( true == t.empty() ); 00120 return scribbler< Value, Allocator >( t ); 00121 } 00122 } 00123 } 00124 00125 #endif