void test_xml_escape(
    const CharType * xml_escaped, 
    const CharType * xml, 
    unsigned int size
){
    typedef boost::archive::iterators::xml_escape<const CharType *> translator;

    BOOST_CHECK(
        std::equal(
            translator(BOOST_MAKE_PFTO_WRAPPER(xml)),
            translator(BOOST_MAKE_PFTO_WRAPPER(xml + size)),
            xml_escaped
        )
    );
}
void test_transform_width(unsigned int size){
    // test transform_width
    char rawdata[8];
    
    char * rptr;
    for(rptr = rawdata + 6; rptr-- > rawdata;)
        *rptr = std::rand();

    // convert 8 to 6 bit characters
    typedef boost::archive::iterators::transform_width<
        char *, BitsOut, BitsIn 
    > translator1;

    std::vector<char> v6;

    std::copy(
        translator1(BOOST_MAKE_PFTO_WRAPPER(static_cast<char *>(rawdata))),
        translator1(BOOST_MAKE_PFTO_WRAPPER(rawdata + size)),
        std::back_inserter(v6)
    );

    // check to see we got the expected # of characters out
    if(0 ==  size)
        BOOST_CHECK(v6.size() == 0);
    else
        BOOST_CHECK(v6.size() == (size * BitsIn - 1 ) / BitsOut + 1);

    typedef boost::archive::iterators::transform_width<
        std::vector<char>::iterator, BitsIn, BitsOut
    > translator2;

    BOOST_CHECK(
        std::equal(
            rawdata,
            rawdata + size,
            translator2(BOOST_MAKE_PFTO_WRAPPER(v6.begin()))
        )
    );

}
TiXmlElement* CqDisplayServerImage::serialiseToXML()
{
	TiXmlElement* imageXML = new TiXmlElement("Image");

	TiXmlElement* typeXML = new TiXmlElement("Type");
	TiXmlText* typeText = new TiXmlText("managed");
	typeXML->LinkEndChild(typeText);
	imageXML->LinkEndChild(typeXML);

	TiXmlElement* nameXML = new TiXmlElement("Name");
	TiXmlText* nameText = new TiXmlText(name());
	nameXML->LinkEndChild(nameText);
	imageXML->LinkEndChild(nameXML);

	if(filename().empty())
	{
		TiXmlElement* dataXML = new TiXmlElement("Bitmap");
		std::stringstream base64Data;
		size_t dataLen = m_displayData->width() * m_displayData->height() * numChannels() * sizeof(TqUchar);
		std::copy(	base64_text(BOOST_MAKE_PFTO_WRAPPER(m_displayData->rawData())), 
					base64_text(BOOST_MAKE_PFTO_WRAPPER(m_displayData->rawData() + dataLen)), 
					std::ostream_iterator<char>(base64Data));
		TiXmlText* dataTextXML = new TiXmlText(base64Data.str());
		dataTextXML->SetCDATA(true);
		dataXML->LinkEndChild(dataTextXML);
		imageXML->LinkEndChild(dataXML);
	}
	else
	{
		TiXmlElement* filenameXML = new TiXmlElement("Filename");
		TiXmlText* filenameText = new TiXmlText(filename());
		filenameXML->LinkEndChild(filenameText);
		imageXML->LinkEndChild(filenameXML);
	}

	return(imageXML);
}
Beispiel #4
0
            return;
        }
        ++m_count;
        ++(this->base_reference());
    }
    CharType dereference() const {
        if(m_count == N)
            return '\n';
        return * (this->base_reference());
    }
    unsigned int m_count;
public:
    // make composible buy using templated constructor
    template<class T>
    insert_linebreaks(BOOST_PFTO_WRAPPER(T)  start) :
        super_t(Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)))),
        m_count(0)
    {}
    // intel 7.1 doesn't like default copy constructor
    insert_linebreaks(const insert_linebreaks & rhs) : 
        super_t(rhs.base_reference()),
        m_count(rhs.m_count)
    {}
};

} // namespace iterators
} // namespace archive
} // namespace boost

#endif // BOOST_ARCHIVE_ITERATORS_INSERT_LINEBREAKS_HPP
        Base
    >
{
    friend class boost::iterator_core_access;
    typedef transform_iterator<
        typename detail::from_6_bit<CharType>,
        Base
    > super_t;

public:
    template<class T, class State>
    stateful_base64_from_binary(BOOST_PFTO_WRAPPER(T) start,
                           BOOST_PFTO_WRAPPER(T) end,
                           State & state) :
        super_t(
            Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start)), end, state),
            detail::from_6_bit<CharType>()
        )
    {}
    template<class T>
    stateful_base64_from_binary(BOOST_PFTO_WRAPPER(T) start) :
        super_t(
            Base(BOOST_MAKE_PFTO_WRAPPER(static_cast< T >(start))),
            detail::from_6_bit<CharType>()
        )
    {}
    // intel 7.1 doesn't like default copy constructor
    stateful_base64_from_binary(const stateful_base64_from_binary & rhs) : 
        super_t(
            Base(rhs.base_reference()),
            detail::from_6_bit<CharType>()