#1108 Refactored static indent(depth) from png/tiff/jpeg to Internal::indent(depth)

This commit is contained in:
Robin Mills
2016-03-18 07:48:15 +00:00
parent 09c734fbcd
commit e7b804f3f5
5 changed files with 21 additions and 30 deletions
+9
View File
@@ -630,4 +630,13 @@ namespace Exiv2 {
return binaryToString(buf.pData_,size,start);
}
std::string indent(int32_t d)
{
std::string result ;
if ( d > 0 )
while ( d--)
result += " ";
return result;
}
}} // namespace Internal, Exiv2
+5
View File
@@ -65,6 +65,11 @@ namespace Exiv2 {
*/
std::string binaryToString(const byte* buff, size_t size, size_t start /*=0*/);
/*!
@brief indent output for kpsRecursive in \em printStructure() \em .
*/
std::string indent(int32_t depth);
}} // namespace Internal, Exiv2
#endif // #ifndef IMAGE_INT_HPP_
+1 -10
View File
@@ -353,21 +353,12 @@ namespace Exiv2 {
return iptcMetadata_.erase(pos);
}
static std::string indent(int d)
{
std::string result ;
if ( d > 0 )
while ( d--)
result += " ";
return result;
}
void IptcData::printStructure(std::ostream& out, const byte* bytes,const size_t size,uint32_t depth)
{
uint32_t i = 0 ;
while ( i < size-3 && bytes[i] != 0x1c ) i++;
depth++;
out << indent(depth) << "Record | DataSet | Name | Length | Data" << std::endl;
out << Internal::indent(depth) << "Record | DataSet | Name | Length | Data" << std::endl;
while ( bytes[i] == 0x1c && i < size-3 ) {
char buff[100];
uint16_t record = bytes[i+1];
+1 -8
View File
@@ -159,13 +159,6 @@ namespace Exiv2 {
return true;
}
static std::string indent(int depth)
{
std::string result;
while ( depth -- ) result += " ";
return result;
}
std::string upper(const std::string& str)
{
std::string result;
@@ -303,7 +296,7 @@ namespace Exiv2 {
uint32_t l = (uint32_t) std::strlen(bytes)+2;
// create a copy on write memio object with the data, then print the structure
BasicIo::AutoPtr p = BasicIo::AutoPtr(new MemIo(dataBuf.pData_+l,dataBuf.size_-l));
out << indent(depth) << (const char*) buff.pData_ << ": " << (const char*) dataBuf.pData_ << std::endl;
out << Internal::indent(depth) << (const char*) buff.pData_ << ": " << (const char*) dataBuf.pData_ << std::endl;
}
if ( bICC ) {
+5 -12
View File
@@ -451,13 +451,6 @@ namespace Exiv2 {
#define MIN(a,b) ((a)<(b))?(b):(a)
static std::string indent(int depth)
{
std::string result;
while ( depth -- ) result += " ";
return result;
}
void TiffImage::printStructure(std::ostream& out, Exiv2::PrintStructureOption option,int depth)
{
if (io_->open() != 0) throw Error(9, io_->path(), strError());
@@ -491,15 +484,15 @@ namespace Exiv2 {
bool tooBig = dirLength > 500;
if ( bFirst && bPrint ) {
out << indent(depth) << Internal::stringFormat("STRUCTURE OF TIFF FILE (%c%c): ",c,c) << io.path() << std::endl;
if ( tooBig ) out << indent(depth) << "dirLength = " << dirLength << std::endl;
out << Internal::indent(depth) << Internal::stringFormat("STRUCTURE OF TIFF FILE (%c%c): ",c,c) << io.path() << std::endl;
if ( tooBig ) out << Internal::indent(depth) << "dirLength = " << dirLength << std::endl;
}
if (tooBig) break;
// Read the dictionary
for ( int i = 0 ; i < dirLength ; i ++ ) {
if ( bFirst && bPrint ) {
out << indent(depth)
out << Internal::indent(depth)
<< " address | tag | "
<< " type | count | offset | value\n";
}
@@ -542,7 +535,7 @@ namespace Exiv2 {
if ( bPrint ) {
uint32_t address = start + 2 + i*12 ;
out << indent(depth)
out << Internal::indent(depth)
<< Internal::stringFormat("%8u | %#06x %-25s |%10s |%9u |%10u | "
,address,tag,tagName(tag,25),typeName(type),count,offset);
if ( isShortType(type) ){
@@ -603,7 +596,7 @@ namespace Exiv2 {
} while (start) ;
if ( bPrint ) {
out << indent(depth) << "END " << io.path() << std::endl;
out << Internal::indent(depth) << "END " << io.path() << std::endl;
}
depth--;
}