PSCF v1.1
Format.cpp
1/*
2* Util Package - C++ Utilities for Scientific Computation
3*
4* Copyright 2010 - 2017, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "Format.h"
9
10namespace Util
11{
12
13 // Define and initialize static constants
14 int Format::defaultWidth_ = 15;
15 int Format::defaultPrecision_ = 7;
16
21 { Format::defaultWidth_ = width; }
22
23 /*
24 * Set Format::defaultPrecision_
25 */
26 void Format::setDefaultPrecision(int precision)
27 { Format::defaultPrecision_ = precision; }
28
29 /*
30 * Get the default output field width.
31 */
33 { return defaultWidth_; }
34
35 /*
36 * Get the default output precision.
37 */
39 { return defaultPrecision_; }
40
41 /*
42 * This static method exists to guarantee initialization of static
43 * constants that are defined in the same file. Call it somewhere
44 * in the program to guarantee that the contents of this file will
45 * be linked, rather than optimized away. It may only be called once.
46 */
48 {
49 // This function can only be called once.
50 static int nCall = 0;
51 if (nCall == 0) {
52 Format::defaultWidth_ = 15;
53 Format::defaultPrecision_ = 7;
54 }
55 ++nCall;
56 }
57
58}
static void initStatic()
Initialize or reset default width and precision values.
Definition: Format.cpp:47
static void setDefaultPrecision(int precision)
Set the default output precision.
Definition: Format.cpp:26
static int defaultWidth()
Return the default output field width.
Definition: Format.cpp:32
static void setDefaultWidth(int width)
Set the default output field width.
Definition: Format.cpp:20
static int defaultPrecision()
Return the default output precision.
Definition: Format.cpp:38
Utility classes for scientific computation.
Definition: accumulators.mod:1