cisst-saw
Toggle main menu visibility
Loading...
Searching...
No Matches
tmp
cisst-saw
cisst
cisstVector
vctPrintf.h
Go to the documentation of this file.
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4
/*
5
6
Author(s): Ofri Sadowsky
7
Created on: 2006-02-15
8
9
(C) Copyright 2006-2007 Johns Hopkins University (JHU), All Rights
10
Reserved.
11
12
--- begin cisst license - do not edit ---
13
14
This software is provided "as is" under an open source license, with
15
no warranty. The complete license can be found in license.txt and
16
http://www.cisst.org/cisst/license.txt.
17
18
--- end cisst license ---
19
20
*/
21
22
#pragma once
23
#ifndef _vctPrintf_h
24
#define _vctPrintf_h
25
26
#include <
cisstCommon/cmnPortability.h
>
27
#include <
cisstCommon/cmnPrintf.h
>
28
#include <
cisstVector/vctFixedSizeConstVectorBase.h
>
29
#include <
cisstVector/vctFixedSizeConstMatrixBase.h
>
30
#include <
cisstVector/vctDynamicConstVectorBase.h
>
31
#include <
cisstVector/vctDynamicConstMatrixBase.h
>
32
33
template
<vct::
size_t
ype _size, vct::str
id
e_type _str
id
e,
class
_elementType,
class
_dataPtrType>
34
bool
cmnTypePrintf
(cmnPrintfParser & parser,
35
const
vctFixedSizeConstVectorBase<_size, _stride, _elementType, _dataPtrType>
& vector)
36
{
37
if
(!parser.MatchOutputWithFormatChar(vector[0]) ) {
38
return
false
;
39
}
40
41
vct::size_type
counter;
42
for
(counter = 0; counter < _size; ++counter) {
43
cmnTypePrintf
(parser, vector[counter]);
44
if
(counter != (_size-1))
45
parser.RawOutput(
" "
);
46
}
47
48
return
true
;
49
}
50
51
template
<
class
_vectorOwnerType,
class
_elementType>
52
bool
cmnTypePrintf
(cmnPrintfParser & parser,
53
const
vctDynamicConstVectorBase<_vectorOwnerType, _elementType>
& vector)
54
{
55
const
vct::size_type
vectorSize = vector.size();
56
if
(vectorSize < 1)
57
return
true
;
58
59
if
(!parser.MatchOutputWithFormatChar(vector[0]) ) {
60
return
false
;
61
}
62
63
vct::size_type
counter;
64
for
(counter = 0; counter < vectorSize; ++counter) {
65
const
_elementType element = vector[counter];
66
cmnTypePrintf
(parser, element);
67
if
(counter != (vectorSize-1))
68
parser.RawOutput(
" "
);
69
}
70
71
return
true
;
72
}
73
74
75
template
<
vct::size_type
_rows,
vct::size_type
_cols,
vct::stride_type
_rowStride,
vct::stride_type
_colStride,
76
class
_elementType,
class
_dataPtrType>
77
inline
bool
cmnTypePrintf
(cmnPrintfParser & parser,
78
const
vctFixedSizeConstMatrixBase
<_rows, _cols, _rowStride, _colStride,
79
_elementType, _dataPtrType> & matrix)
80
{
81
if
(!parser.MatchOutputWithFormatChar(matrix.Element(0,0)) ) {
82
return
false
;
83
}
84
85
vct::size_type
rowCounter, colCounter;
86
for
(rowCounter = 0; rowCounter < _rows; ++rowCounter) {
87
for
(colCounter = 0; colCounter < _cols; ++colCounter) {
88
cmnTypePrintf
(parser, matrix.Element(rowCounter, colCounter));
89
if
(colCounter != (_cols-1))
90
parser.RawOutput(
" "
);
91
}
92
if
(rowCounter != (_rows - 1))
93
parser.RawOutput(
"\n"
);
94
}
95
96
return
true
;
97
}
98
99
100
template
<
class
_matrixOwnerType,
class
_elementType>
101
bool
cmnTypePrintf
(cmnPrintfParser & parser,
102
const
vctDynamicConstMatrixBase<_matrixOwnerType, _elementType>
& matrix)
103
{
104
const
vct::size_type
rows
= matrix.rows();
105
const
vct::size_type
cols
= matrix.cols();
106
107
if
(matrix.size() < 1)
108
return
true
;
109
110
if
(!parser.MatchOutputWithFormatChar(matrix.Element(0,0)) ) {
111
return
false
;
112
}
113
114
vct::size_type
rowCounter, colCounter;
115
for
(rowCounter = 0; rowCounter <
rows
; ++rowCounter) {
116
for
(colCounter = 0; colCounter <
cols
; ++colCounter) {
117
cmnTypePrintf
(parser, matrix.Element(rowCounter, colCounter));
118
if
(colCounter != (
cols
- 1))
119
parser.RawOutput(
" "
);
120
}
121
if
(rowCounter != (
rows
- 1))
122
parser.RawOutput(
"\n"
);
123
}
124
125
return
true
;
126
}
127
128
129
#endif
// _vctPrintf_h
130
vctDynamicConstMatrixBase
Definition
vctForwardDeclarations.h:145
vctDynamicConstVectorBase
Definition
vctForwardDeclarations.h:119
vctFixedSizeConstMatrixBase
A template for a fixed size matrix with fixed spacing in memory.
Definition
vctFixedSizeConstMatrixBase.h:104
vctFixedSizeConstVectorBase
A template for a fixed length vector with fixed spacing in memory.
Definition
vctFixedSizeConstVectorBase.h:108
cmnPortability.h
Portability across compilers and operating systems tools.
cmnPrintf.h
Declaration of cmnPrintf and cmnPrintfParser.
cmnTypePrintf
CISST_EXPORT bool cmnTypePrintf(cmnPrintfParser &parser, const int number)
vct::size_type
size_t size_type
Definition
vctContainerTraits.h:35
vct::stride_type
ptrdiff_t stride_type
Definition
vctContainerTraits.h:37
vctDynamicConstMatrixBase.h
Declaration of vctDynamicConstMatrixBase.
cols
size_type cols() const
Definition
vctDynamicConstMatrixBase.h:243
rows
size_type rows() const
Definition
vctDynamicConstMatrixBase.h:238
vctDynamicConstVectorBase.h
Declaration of vctDynamicConstVectorBase.
vctFixedSizeConstMatrixBase.h
Declaration of vctFixedSizeConstMatrixBase.
vctFixedSizeConstVectorBase.h
Declaration of vctFixedSizeConstVectorBase.
Generated by
1.18.0