当前位置: 首页>>代码示例>>C++>>正文


C++ Printer类代码示例

本文整理汇总了C++中Printer的典型用法代码示例。如果您正苦于以下问题:C++ Printer类的具体用法?C++ Printer怎么用?C++ Printer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Printer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: printCash

void printCash(const string &line) {
    size_t position = 0;
    unsigned int price;
    unsigned int amount;

    Printer cashier;

    price = getPrice(line, position);
    amount = getPrice(line, position);

    if (price == amount) {
        cout << "ZERO" << endl;
        return;
    }

    if (price > amount) {
        cout << "ERROR" << endl;
        return;
    }

    amount -= price;

    for (auto i = cash.rbegin(); i != cash.rend() && amount != 0; ++i) {
        while (amount >= i->second) {
            cashier.print(i->first);
            amount -= i->second;
        }
    }

    cout << endl;
}
开发者ID:Ation,项目名称:codeeval,代码行数:31,代码来源:main.cpp

示例2: printReversed

void printReversed(const string &line) {
    size_t position = 0;
    Printer p;
    unsigned int number;

    static vector<int> values;

    values.clear();

    while (line[position] != ';') {
        getUnsignedInteger(line, position, number);
        values.push_back(number);
    }

    getUnsignedInteger(line, position, number);

    if (number > values.size() ) {
        number = values.size();
    }

    int start = number - 1;
    while (start < values.size() ) {
        for (int i = start; i > start - (int)number; --i) {
            p.print(values[i]);
        }
        start += number;
    }

    for (int i = start - number + 1; i < values.size(); i++) {
        p.print(values[i]);
    }

    cout << endl;
}
开发者ID:Ation,项目名称:codeeval,代码行数:34,代码来源:main.cpp

示例3: accept

void ParityAggrLit::accept(::Printer *v)
{ 
	Printer *printer = v->output()->printer<Printer>();
	printer->begin(head(), sign_, even_==fixed_, set_);
	foreach(CondLit &lit, conds_) lit.accept(printer);
	printer->end();
}
开发者ID:RayHuo,项目名称:iASP,代码行数:7,代码来源:parityaggrlit.cpp

示例4: main

int main(int argc, char* argv[]){

	// c++11 initializer_list constructor
	Printer obj = {10};
	std::cout << obj() << std::endl;

	obj.print("obj.print");

	// mem_fn 转换
	auto func = std::mem_fn(&Printer::print);

	obj.data = 100;
	func(obj, "mem_fun");

	// bind 绑定
	auto func2 = std::bind(&Printer::print, &obj, _1);
	func2("bind");

	// bind操作符函数绑定
	auto func3 = std::bind(&Printer::operator(), &obj);
	std::cout << "bind operator() " << func3() << std::endl;

	// mem_fn 操作符转换为普通函数
	auto func4 = std::mem_fn(&Printer::operator());
	std::cout << "mem_fun operator() " << func4(obj) << std::endl;

	return 0;
}
开发者ID:emptylau,项目名称:hungry,代码行数:28,代码来源:mem_fn.cpp

示例5: main

int main( int argc, char** argv  )
{
	int deviceNum = 0;
	
	if( argc != 2 )
	{
		cout << "InkPlus <device number>" << endl;
		return -1;
	}

	const char* deviceFile = argv[1];
	
	try
	{
		cout << "Retrieving information about USB lp..." << deviceFile << endl;
		Printer firstPrinter = getusbprinterlevels(deviceFile);
		cout << "Found " << firstPrinter.Name() << endl;
	}
	catch( int e )
	{
		cout << "Error " << e << endl;
		return e;
	}
	
	return 0;
}
开发者ID:esanbock,项目名称:inkleveler,代码行数:26,代码来源:InkPlus.cpp

示例6: setupPrintData

 void model::setupPrintData( Printer & p ) {
     p.addVariableToPrint(this->stateAt(0), "theta");
     p.addVariableToPrint(this->stateAt(1), "theta_dot");
     p.addVariableToPrint(m, "Mass");
     p.addVariableToPrint(c, "Dampening");
     p.addVariableToPrint(l, "Length");
 }
开发者ID:choward1491,项目名称:KrystalBall,代码行数:7,代码来源:pendulum_model.cpp

示例7: accept

void JunctionAggrLit::accept(::Printer *v)
{
	Printer *printer = v->output()->printer<Printer>();
	printer->begin(head());
	foreach(CondLit &lit, conds_) lit.accept(printer);
	printer->end();
}
开发者ID:RayHuo,项目名称:iASP,代码行数:7,代码来源:junctionaggrlit.cpp

示例8: Write_

/**
 * Write the quoted element out to the stream.
 *
 * @param out -- The output stream to write the evaluate to.
 */
void Quoted_::Write_(Printer& out) const
{
    out.Indent();
    out << "'";
    out.IgnoreNextIndent();
    this->element.Write(out);
}
开发者ID:signatal,项目名称:codeography,代码行数:12,代码来源:quoted_.cpp

示例9: main

int main(int argc, const char **argv) {
    assert(Printer_Base::uni_special(0x80));
    assert(!Printer_Base::uni_special(0x79));
    assert(Printer_Base::strlen("\e[38;5;190mA\e[0m")==1);
    int width = 25;
    char filler = '_';
    double val = 1.234567901234;
    std::cout << Printer_Base::align("Left-aligned", width,
                                     Printer_Base::LEFT, filler) << "\r\n"
              << Printer_Base::align("Centered", width,
                                     Printer_Base::CENTER, filler) << "\r\n"
              << Printer_Base::align(val, width,
                                     Printer_Base::CENTER, filler) << "\r\n"
              << Printer_Base::align(val, width,
                                     Printer_Base::CENTER, filler, 8) << "\r\n"
              << Printer_Base::align("Right-aligned", width,
                                     Printer_Base::RIGHT, filler) << std::endl;
    Printer<4> printer;
    std::string rows[] {"Title","Row title","Row title",""},
    cols[] {"Col 1", "Col 2", "Col 3", "Col 4"};
    int data[] {0, 1, 2, 3, 4, 5, 6, 7};
    printer.push(&rows[0], &rows[0]+4).level();
    printer.push<int, 2, 4>(data, &cols[0], &cols[0]+4).level();
    Printer<6> widePrinter;
    widePrinter.insert(2, printer).level()
    .push<int, 4, 2>(data, &cols[0], &cols[0]+4);
    std::cout << widePrinter << std::endl;
}
开发者ID:jep-dev,项目名称:FOGL,代码行数:28,代码来源:system.cpp

示例10: rr_log_fn

void RR_CALL Printer::rr_log_fn (rr_dev dev, int type,
			       const char *buffer,
			       size_t len, void *closure)
{
  Printer *printer = static_cast<Printer*>(closure);
  printer->handle_rr_log(dev, type, buffer, len);
}
开发者ID:semiLab,项目名称:repsnapper,代码行数:7,代码来源:printer_libreprap.cpp

示例11: fprint

  void
fprint(FILE *out, Opnd opnd)
{
  Printer *printer = target_printer();
  printer->set_file_ptr(out);
  printer->print_opnd(opnd);
}
开发者ID:JehandadKhan,项目名称:roccc-2.0,代码行数:7,代码来源:opnd.cpp

示例12: main

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    
    if (argc != 2) {
        std::cout << "Usage: cmdimg image" << std::endl;
        return 0;
    }

    Printer *p = new Printer();
    std::cout << "Trying to open port" << std::endl;

    bool res = p->open("/dev/ttyAMA0");
    std::cout << "Status: " << res << std::endl;

    if (!res) {
        std::cerr << "Error opening port, aborting" << std::endl;
        return (0);
    }

    p->init();

    p->printImage(QImage(argv[1]));

    std::cout << "Closing Device" << std::endl;
    p->close();

    return 1;

    return a.exec();
}
开发者ID:jortworx,项目名称:Raspi-Thermal-Printer,代码行数:31,代码来源:cmdimg.cpp

示例13: reFilter

void benchmark::BenchRunner::RunAll(Printer& printer, uint64_t num_evals, double scaling, const std::string& filter, bool is_list_only)
{
    if (!std::ratio_less_equal<benchmark::clock::period, std::micro>::value) {
        std::cerr << "WARNING: Clock precision is worse than microsecond - benchmarks may be less accurate!\n";
    }
#ifdef DEBUG
    std::cerr << "WARNING: This is a debug build - may result in slower benchmarks.\n";
#endif

    std::regex reFilter(filter);
    std::smatch baseMatch;

    printer.header();

    for (const auto& p : benchmarks()) {
        if (!std::regex_match(p.first, baseMatch, reFilter)) {
            continue;
        }

        uint64_t num_iters = static_cast<uint64_t>(p.second.num_iters_for_one_second * scaling);
        if (0 == num_iters) {
            num_iters = 1;
        }
        State state(p.first, num_evals, num_iters, printer);
        if (!is_list_only) {
            p.second.func(state);
        }
        printer.result(state);
    }

    printer.footer();
}
开发者ID:machinecoin-project,项目名称:machinecoin-core,代码行数:32,代码来源:bench.cpp

示例14: stackPrintAlternate

void stackPrintAlternate(const string &line) {
    int end;
    int start;
    char *data = const_cast<char*>(line.c_str());
    Printer p;

    end = line.length() - 1;

    back(data, start, end);
    p.print(&( data[start] ));

    while (true) {
        end = start - 1;
        back(data, start, end);
        if (start <= 0) {
            break;
        }

        end = start - 1;
        back(data, start, end);
        data[end + 1] = 0;

        if (end < 0) {
            break;
        }
        p.print(&( data[start] ));
    }
	cout << endl;
}
开发者ID:Ation,项目名称:codeeval,代码行数:29,代码来源:main.cpp

示例15: head

void MinMaxAggrLit::_accept(::Printer *v)
{
	Printer<MinMaxAggrLit, T> *printer = v->output()->printer<Printer<MinMaxAggrLit, T> >();
	printer->begin(AggrCond::Printer::State(aggrUid(), domain_.lastId()), head(), sign_, complete(), set_);
	if(lower()) { printer->lower(valLower_, lowerEq_); }
	if(upper()) { printer->upper(valUpper_, upperEq_); }
	printer->end();
}
开发者ID:grote,项目名称:oclingo,代码行数:8,代码来源:minmaxaggrlit.cpp


注:本文中的Printer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。