192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri/**************************************************************************
292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri *
392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * Copyright 2010 Luca Barbieri
492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri *
592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * Permission is hereby granted, free of charge, to any person obtaining
692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * a copy of this software and associated documentation files (the
792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * "Software"), to deal in the Software without restriction, including
892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * without limitation the rights to use, copy, modify, merge, publish,
992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * distribute, sublicense, and/or sell copies of the Software, and to
1092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * permit persons to whom the Software is furnished to do so, subject to
1192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * the following conditions:
1292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri *
1392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * The above copyright notice and this permission notice (including the
1492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * next paragraph) shall be included in all copies or substantial
1592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * portions of the Software.
1692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri *
1792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
2192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri *
2592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri **************************************************************************/
2692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
2792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#include <memory>
2892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#include <string.h>
2992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#include <iomanip>
3092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri#include "dxbc.h"
3192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri
3292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieristd::ostream& operator <<(std::ostream& out, const dxbc_container& container)
3392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri{
3492617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	for(unsigned i = 0; i < container.chunks.size(); ++i)
3592617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	{
3692617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		struct dxbc_chunk_header* chunk = container.chunks[i];
3792617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		char fourcc_str[5];
3892617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		memcpy(fourcc_str, &chunk->fourcc, 4);
3992617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		fourcc_str[4] = 0;
4092617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri		out << "# DXBC chunk " << std::setw(2) << i << ": " << fourcc_str << " offset " << ((char*)chunk - (char*)container.data) << " size " << bswap_le32(chunk->size) << "\n";
4192617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	}
4292617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri	return out;
4392617aeac109481258f0c3863d09c1b8903d438bLuca Barbieri}
44