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 "
error/error.hpp
"
34
#include "
error/exception.hpp
"
35
36
namespace
mx
37
{
38
39
const
char
*mxlib_comp_current_branch();
40
41
const
char
*mxlib_comp_current_sha1();
42
43
const
bool
mxlib_comp_repo_modified();
44
45
/// Dump the git status of a repository to a stream
46
/** Prints the provided SHA1 hash and whether or not the library
47
* has been modified since that commit.
48
*
49
* \tparam iosT a std::ostream-like type
50
* \tparam comment a character to print at the beginning of each line. Default is '#'.
51
*/
52
template
<
typename
iosT,
char
comment = '#'>
53
iosT &
dumpGitStatus
(
54
iosT &ios,
///< [in] a std::ostream-like stream.
55
const
std::string &repoName,
///< [in] The name of the repository
56
const
std::string &branch,
///< [in] The name of the branch
57
const
std::string &sha1,
///< [in] The sha1 hash for the current commit
58
const
bool
&modified,
///< [in] Whether or not the repository is currently modified
59
const
std::string §ion =
""
///< [in] [optional] Descriptive sub-section name (e.g. headers vs. compiled)
60
)
61
{
62
// This causes the stream to not output a '\0' if comment = '\0'
63
char
c[] = { comment,
'\0'
};
64
65
bool
sect = !( section ==
""
);
66
std::string space =
" "
;
67
if
( sect )
68
space +=
" "
;
69
70
ios << c <<
"--------------------------------------------\n"
;
71
ios << c <<
" "
<< repoName <<
" git status:\n"
;
72
if
( sect )
73
ios << c <<
" "
<< section <<
":\n"
;
74
ios << c << space <<
"branch: "
<< branch <<
"\n"
;
75
ios << c << space <<
"SHA1: "
<< sha1 <<
"\n"
;
76
ios << c << space <<
"modified flag: "
<< std::boolalpha << modified <<
"\n"
;
77
ios << c <<
"--------------------------------------------\n"
;
78
79
return
ios;
80
}
81
82
/// Dump the current git status of the mxlib library to a stream
83
/** Prints the current SHA1 hash and whether or not the library
84
* has been modified since that commit.
85
*
86
* \tparam iosT a std::ostream-like type
87
* \tparam comment a character to print at the beginning of each line. Default is '#'.
88
*/
89
template
<
typename
iosT,
char
comment = '#'>
90
iosT &
dumpGitStatus
( iosT &ios
/**< [in] a std::ostream-like stream. */
)
91
{
92
return
dumpGitStatus
( ios,
93
"mxlib"
,
94
mxlib_comp_current_branch(),
95
mxlib_comp_current_sha1(),
96
mxlib_comp_repo_modified() );
97
}
98
99
}
// namespace mx
100
101
#endif
// mxlib_hpp
error.hpp
The mxlib error reporting system.
exception.hpp
The mxlib exception class.
mx
The mxlib c++ namespace.
Definition
mxlib.hpp:37
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:53
mxlib.hpp
Generated on Thu Feb 19 2026 23:03:56 for mxlib by
1.9.8