stringoutputstream.h

来自「一个语言识别引擎」· C头文件 代码 · 共 50 行

H
50
字号
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

/*
 * Copyright (C) 2006 Paul Fitzpatrick
 * CopyPolicy: Released under the terms of the GNU GPL v2.0.
 *
 */

#ifndef _YARP2_STRINGOUTPUTSTREAM_
#define _YARP2_STRINGOUTPUTSTREAM_

#include <yarp/OutputStream.h>
#include <yarp/String.h>

namespace yarp {
    class StringOutputStream;
}

/**
 * An OutputStream that produces a String.  For testing purposes.
 */
class yarp::StringOutputStream : public OutputStream {
public:
    using OutputStream::write;

    StringOutputStream() { }


    String toString() {
        return data;
    }


    virtual void write(const Bytes& b) { // throws
        //ACE_DEBUG((LM_DEBUG,"StringOutputStream::write"));
        for (int i=0; i<b.length(); i++) {
            data += b.get()[i];
        }
    }

    virtual void close() {
    }

private:
    String data;
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?