Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

node_find_class.cpp


SourceForge.net Logo     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;
}
This program displays the following output:
''
'ABC'
'ABC '
'ABC 123'
'ABC '
'ABC'
''
''



Copyright © 1997-2006 Igor Kholodov mailto:cttl@users.sourceforge.net.

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.


Generated on Thu Nov 2 17:44:55 2006 for Common Text Transformation Library by  doxygen 1.3.9.1