libStatGen Software 1
SamHeaderTag.cpp
1/*
2 * Copyright (C) 2010 Regents of the University of Michigan
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "SamHeaderTag.h"
19
20
21SamHeaderTag::SamHeaderTag(const char* tag, const char* value)
22{
23 setTag(tag, value);
24}
25
26
27SamHeaderTag::SamHeaderTag(const SamHeaderTag& oldTag)
28{
29 setTag(oldTag.myTag.c_str(), oldTag.myValue.c_str());
30}
31
32
33SamHeaderTag::~SamHeaderTag()
34{
35}
36
37
38// Add this tag to the passed in tag string.
39// NOTE: does not clear tagString.
40bool SamHeaderTag::getTagString(std::string& tagString)
41{
42 if(myValue.length() != 0)
43 {
44 // There is a value associated with this tag, so add it to the string.
45 tagString += "\t";
46 tagString += myTag;
47 tagString += ":";
48 tagString += myValue;
49 return(true);
50 }
51 // This tag has no associated value, return false.
52 return(false);
53}
54
55
56// Set this tag to the passed in tag and value.
57bool SamHeaderTag::setTag(const char* tag, const char* value)
58{
59 myTag = tag;
60 myValue = value;
61 return(true);
62}
63
64
65// Set the value associated with this tag to the passed in value.
66bool SamHeaderTag::setValue(const char* value)
67{
68 myValue = value;
69 return(true);
70}
71
72
73// Return the tag for this tag.
74const char* SamHeaderTag::getTag()
75{
76 return(myTag.c_str());
77}
78
79
80// Return the value associated with this tag.
81const char* SamHeaderTag::getValue()
82{
83 return(myValue.c_str());
84}
85
86
87// Return true if there is a non-blank value associated with this tag.
88bool SamHeaderTag::hasValue()
89{
90 return(myValue.size() != 0);
91}