mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [
git repo
]
Loading...
Searching...
No Matches
mxlib.hpp
Go to the documentation of this file.
1
/** \file mxlib.hpp
2
* \author Jared R. Males
3
* \brief Declarations of some libarary wide utilities
4
*
5
*/
6
7
//***********************************************************************//
8
// Copyright 2015, 2016, 2017, 2018 Jared R. Males (jaredmales@gmail.com)
9
//
10
// This file is part of mxlib.
11
//
12
// mxlib is free software: you can redistribute it and/or modify
13
// it under the terms of the GNU General Public License as published by
14
// the Free Software Foundation, either version 3 of the License, or
15
// (at your option) any later version.
16
//
17
// mxlib is distributed in the hope that it will be useful,
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
// GNU General Public License for more details.
21
//
22
// You should have received a copy of the GNU General Public License
23
// along with mxlib. If not, see <http://www.gnu.org/licenses/>.
24
//***********************************************************************//
25
26
#ifndef mxlib_hpp
27
#define mxlib_hpp
28
29
#include <ios>
30
31
#include "mxlib_uncomp_version.h"
32
33
#include "
mxError.hpp
"
34
35
namespace
mx
36
{
37
38
const
char
*mxlib_comp_current_branch();
39
40
const
char
*mxlib_comp_current_sha1();
41
42
const
bool
mxlib_comp_repo_modified();
43
44
/// Dump the git status of a repository to a stream
45
/** Prints the provided SHA1 hash and whether or not the library
46
* has been modified since that commit.
47
*
48
* \tparam iosT a std::ostream-like type
49
* \tparam comment a character to print at the beginning of each line. Default is '#'.
50
*/
51
template
<
typename
iosT,
char
comment = '#'>
52
iosT &
dumpGitStatus
(
53
iosT &ios,
///< [in] a std::ostream-like stream.
54
const
std::string &repoName,
///< [in] The name of the repository
55
const
std::string &branch,
///< [in] The name of the branch
56
const
std::string &sha1,
///< [in] The sha1 hash for the current commit
57
const
bool
&modified,
///< [in] Whether or not the repository is currently modified
58
const
std::string §ion =
""
///< [in] [optional] Descriptive sub-section name (e.g. headers vs. compiled)
59
)
60
{
61
// This causes the stream to not output a '\0' if comment = '\0'
62
char
c[] = { comment,
'\0'
};
63
64
bool
sect = !( section ==
""
);
65
std::string space =
" "
;
66
if
( sect )
67
space +=
" "
;
68
69
ios << c <<
"--------------------------------------------\n"
;
70
ios << c <<
" "
<< repoName <<
" git status:\n"
;
71
if
( sect )
72
ios << c <<
" "
<< section <<
":\n"
;
73
ios << c << space <<
"branch: "
<< branch <<
"\n"
;
74
ios << c << space <<
"SHA1: "
<< sha1 <<
"\n"
;
75
ios << c << space <<
"modified flag: "
<< std::boolalpha << modified <<
"\n"
;
76
ios << c <<
"--------------------------------------------\n"
;
77
78
return
ios;
79
}
80
81
/// Dump the current git status of the mxlib library to a stream
82
/** Prints the current SHA1 hash and whether or not the library
83
* has been modified since that commit.
84
*
85
* \tparam iosT a std::ostream-like type
86
* \tparam comment a character to print at the beginning of each line. Default is '#'.
87
*/
88
template
<
typename
iosT,
char
comment = '#'>
89
iosT &
dumpGitStatus
( iosT &ios
/**< [in] a std::ostream-like stream. */
)
90
{
91
return
dumpGitStatus
( ios,
92
"mxlib"
,
93
mxlib_comp_current_branch(),
94
mxlib_comp_current_sha1(),
95
mxlib_comp_repo_modified() );
96
}
97
98
}
// namespace mx
99
100
#endif
// mxlib_hpp
mxError.hpp
The mxlib error reporting system.
mx
The mxlib c++ namespace.
Definition
mxError.hpp:40
mx::dumpGitStatus
iosT & dumpGitStatus(iosT &ios, const std::string &repoName, const std::string &branch, const std::string &sha1, const bool &modified, const std::string §ion="")
Dump the git status of a repository to a stream.
Definition
mxlib.hpp:52
mxlib.hpp
Generated on Mon Aug 11 2025 12:17:55 for mxlib by
1.9.8