/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */ /* $Id: vctPrintf.h,v 1.4 2007/04/26 19:33:58 anton Exp $ Author(s): Ofri Sadowsky Created on: 2006-02-15 (C) Copyright 2006-2007 Johns Hopkins University (JHU), All Rights Reserved. --- begin cisst license - do not edit --- This software is provided "as is" under an open source license, with no warranty. The complete license can be found in license.txt and http://www.cisst.org/cisst/license.txt. --- end cisst license --- */ #ifndef _vctPrintf_h #define _vctPrintf_h #include #include #include #include #include #include template bool cmnTypePrintf(cmnPrintfParser & parser, const vctFixedSizeConstVectorBase<_size, _stride, _elementType, _dataPtrType> & vector) { if (!parser.MatchOutputWithFormatChar(vector[0]) ) { return false; } unsigned int counter; for (counter = 0; counter < _size; ++counter) { cmnTypePrintf(parser, vector[counter]); if (counter != (_size-1)) parser.RawOutput(" "); } return true; } template bool cmnTypePrintf(cmnPrintfParser & parser, const vctDynamicConstVectorBase<_vectorOwnerType, _elementType> & vector) { const unsigned int vectorSize = vector.size(); if (vectorSize < 1) return true; if (!parser.MatchOutputWithFormatChar(vector[0]) ) { return false; } unsigned int counter; for (counter = 0; counter < vectorSize; ++counter) { const _elementType element = vector[counter]; cmnTypePrintf(parser, element); if (counter != (vectorSize-1)) parser.RawOutput(" "); } return true; } template inline bool cmnTypePrintf(cmnPrintfParser & parser, const vctFixedSizeConstMatrixBase<_rows, _cols, _rowStride, _colStride, _elementType, _dataPtrType> & matrix) { if (!parser.MatchOutputWithFormatChar(matrix.Element(0,0)) ) { return false; } unsigned int rowCounter, colCounter; for (rowCounter = 0; rowCounter < _rows; ++rowCounter) { for (colCounter = 0; colCounter < _cols; ++colCounter) { cmnTypePrintf(parser, matrix.Element(rowCounter, colCounter)); if (colCounter != (_cols-1)) parser.RawOutput(" "); } if (rowCounter != (_rows - 1)) parser.RawOutput("\n"); } return true; } template bool cmnTypePrintf(cmnPrintfParser & parser, const vctDynamicConstMatrixBase<_matrixOwnerType, _elementType> & matrix) { const unsigned int rows = matrix.rows(); const unsigned int cols = matrix.cols(); if (matrix.size() < 1) return true; if (!parser.MatchOutputWithFormatChar(matrix.Element(0,0)) ) { return false; } unsigned int rowCounter, colCounter; for (rowCounter = 0; rowCounter < rows; ++rowCounter) { for (colCounter = 0; colCounter < cols; ++colCounter) { cmnTypePrintf(parser, matrix.Element(rowCounter, colCounter)); if (colCounter != (cols - 1)) parser.RawOutput(" "); } if (rowCounter != (rows - 1)) parser.RawOutput("\n"); } return true; } #endif // _vctPrintf_h // **************************************************************************** // Change History // **************************************************************************** // // $Log: vctPrintf.h,v $ // Revision 1.4 2007/04/26 19:33:58 anton // All files in libraries: Applied new license text, separate copyright and // updated dates, added standard header where missing. // // Revision 1.3 2006/11/20 20:33:20 anton // Licensing: Applied new license to cisstCommon, cisstVector, cisstNumerical, // cisstInteractive, cisstImage and cisstOSAbstraction. // // Revision 1.2 2006/02/16 16:36:16 anton // vctPrintf.h: Replaced _rows and _cols by appropriate values for dynamic // matrices cmnTypePrintf. // // Revision 1.1 2006/02/16 00:21:00 ofri // Added formatted output files cmnPrintf and vctPrintf in the respective // directories (code, include) // // // ****************************************************************************