GithubHelp home page GithubHelp logo

Comments (4)

huiguangjun avatar huiguangjun commented on July 19, 2024

你可以继承 streambuf, 定义自己的buffer类(例如MyCharBuffer),实现相关的接口,对pkbyContent进行封装。
MyCharBuffer charBuffer(pkbyContent, ui64ContentLength);
std::shared_ptr < std::iostream > charContent = std::make_shared < std::iostream > (&charBuffer);

from aliyun-oss-cpp-sdk.

huiguangjun avatar huiguangjun commented on July 19, 2024

为了简化,继承std::stringbuf 作为例子。
class MyCharBuffer : public std::stringbuf
{
public:
MyCharBuffer(char *ptr, std::streamsize size) :
std::stringbuf(std::ios_base::in)
{
_Mysb::setg(ptr, ptr, ptr + size);
_Mysb::setp(ptr + size, ptr + size, ptr + size);
}
};

from aliyun-oss-cpp-sdk.

ayumukid avatar ayumukid commented on July 19, 2024

class MyCharBuffer : public std::stringbuf
{
public:
MyCharBuffer(char *ptr, std::streamsize size) :
std::stringbuf(std::ios_base::in)
{
_Mysb::setg(ptr, ptr, ptr + size);
_Mysb::setp(ptr + size, ptr + size, ptr + size);
}
};
在linux 环境下编译不过

MyOssBuffer.h:12:3: 错误:‘_Mysb’未声明
_Mysb::setp(ptr + size, ptr + size, ptr + size);

from aliyun-oss-cpp-sdk.

ayumukid avatar ayumukid commented on July 19, 2024
MyOssBuffer(char *ptr, std::streamsize size):
	std::stringbuf(std::ios_base::in)
{

#ifdef _WIN32
basic_streambuf::setg(ptr, ptr, ptr + size);
basic_streambuf::setp(ptr + size, ptr + size, ptr + size);
#else
basic_streambuf::setg(ptr, ptr, ptr + size);
basic_streambuf::setp(ptr + size, ptr + size);
#endif

}

使用这种方式 win linux下可以编译通过

from aliyun-oss-cpp-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.