HEX
Server: Apache
System: Linux dinesh8189 5.15.98-grsec-sharedvalley-2.lc.el8.x86_64 #1 SMP Thu Mar 9 09:07:30 -03 2023 x86_64
User: cgmgerenciamento1 (814285)
PHP: 8.1.26
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //usr/share/doc/source-highlight/examples/styleformatter.h
/*
 *      Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2009
 *  Copyright: See COPYING file that comes with this distribution
 */

#ifndef STYLEFORMATTER_H_
#define STYLEFORMATTER_H_

#include <string>
#include <iostream>

#include <boost/shared_ptr.hpp>

#include "srchilite/formatter.h"
#include "srchilite/formatterparams.h"

/**
 * A specialization of srchilite::Formatter so that it prints information
 * about the language element that is being highlighted, and the format (that is,
 * bold, italics, etc).  To avoid get/set methods, let's make all members
 * public, it is just an example anyway :-)
 *///> TEXINFO
struct StyleFormatter: public srchilite::Formatter {
    /// the language element represented by this formatter
    std::string elem;

    bool bold, italic, underline, fixed, not_fixed;

    std::string color;

    std::string bgColor;

    StyleFormatter(const std::string &elem_ = "normal") :
        elem(elem_), bold(false), italic(false), underline(false),
                fixed(false), not_fixed(false) {
    }

    virtual void format(const std::string &s,
            const srchilite::FormatterParams *params = 0) {
        // do not print anything if normal or string to format is empty
        if (elem != "normal" || !s.size()) {
            std::cout << elem << ": \"" << s << "\"" << std::endl;
            std::cout << "formatted as: " << (bold ? "bold " : "")
                    << (italic ? "italic " : "") << (underline ? "underline "
                    : "");
            std::cout << (color.size() ? "color: " + color + " " : "");
            std::cout << (bgColor.size() ? "bgcolor: " + bgColor : "")
                    << std::endl;
        }
    }
};

/// shared pointer for StyleFormatter
typedef boost::shared_ptr<StyleFormatter> StyleFormatterPtr;

//> TEXINFO
#endif /* STYLEFORMATTER_H_ */