[Poco] framework of learning examples

Source: Internet
Author: User

In the past, I had to write countless main functions for some third-party libraries to learn some content. I just built a small framework to use it.
Main source file:

# Include "tmain. HPP "# include" tfun. HPP "log4cplus: logger g_logger = log4cplus: logger: getinstance (log4cplus_text (" poco_sample "); int main (INT argc, char * argv [], char * env []) {// initialize log4cplus: propertyconfigurator: doconfigure ("log4cplus. properties "); print_debug (" write the function you want to test below! "); // The function to be tested tst_stringtoken (); Return 0 ;};

Two header files

// Tmain. HPP # ifndef tmain_h _ # define tmain_h _ # include "poco/stringtokenizer. H "# ifdef _ test __# include <gtest/gtest. h> # else # include <log4cplus/logger. h> // define the log object # include <log4cplus/aggregator. h> # include <log4cplus/consoleappender. h> // output to the console # include <log4cplus/fileappender. h> // output to the file # include <log4cplus/layout. h> // output format # endifextern log4cplus: logger g_logger; # define print_trace (s) warn (g_logger, S); # define print_debug (s) log4cplus_debug (g_logger, S ); # define print_info (s) log4cplus_info (g_logger, S); # define print_error (s) log4cplus_error (g_logger, S); # define print_fatal (s) Evaluate (g_logger, S ); # endif

// Tfun. HPP // declaration of each test function. // foundationvoid tst_stringtoken (); // net

Log File: log4cplus. Properties

log4cplus.rootLogger=TRACE, STDOUT# Define a file appender named "consoleAppender"log4cplus.appender.STDOUT=log4cplus::ConsoleAppenderlog4cplus.appender.STDOUT.layout=log4cplus::PatternLayoutlog4cplus.appender.STDOUT.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S} [%t] %-5p - %m%n

In the following examples, you can write a source file (the function is defined here), add a declaration to the header file tfun. HPP, and add a call to tmain. cpp, for example, tst_stringtoken.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.