CTTL on
SourceForge |
Download
Latest |
Documentation
Index |
Library
News |
CVS
Repository |
Other
Links |
Shows results of manual node navigation via cttl::node::find_class()
and cttl::node::rfind_class()
calls. Position of the node is moved around boundaries of the nearby character class of the user input.
// sample code: node_find_class.cpp // demonstrates cttl::node::find_class() and cttl::node::rfind_class() //#define NDEBUG // define before assert.h to stop assertions from being compiled //#define CTTL_TRACE_EVERYTHING #include <iostream> #include "cttl/cttl.h" int main() { using cttl::input; using cttl::node; input<> inp( "ABC 123" ); node<> from( new_node( inp ) ); node<> to( new_node( inp ) ); from.go_bof(); to.go_bof(); to.find_class( isspace ); std::cout << '\'' << ( from + to ).text() << '\'' << std::endl ; to.find_class( isalpha ); std::cout << '\'' << ( from + to ).text() << '\'' << std::endl ; to.find_class( isspace ); std::cout << '\'' << ( from + to ).text() << '\'' << std::endl ; to.find_class( isdigit ); std::cout << '\'' << ( from + to ).text() << '\'' << std::endl ; to.rfind_class( isdigit ); std::cout << '\'' << ( from + to ).text() << '\'' << std::endl ; to.rfind_class( isspace ); std::cout << '\'' << ( from + to ).text() << '\'' << std::endl ; to.rfind_class( isalpha ); std::cout << '\'' << ( from + to ).text() << '\'' << std::endl ; to.rfind_class( isspace ); std::cout << '\'' << ( from + to ).text() << '\'' << std::endl ; return 0; }
'' 'ABC' 'ABC ' 'ABC 123' 'ABC ' 'ABC' '' ''
Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.