libStatGen Software  1
SamHeaderTag.cpp
00001 /*
00002  *  Copyright (C) 2010  Regents of the University of Michigan
00003  *
00004  *   This program is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #include "SamHeaderTag.h"
00019 
00020 
00021 SamHeaderTag::SamHeaderTag(const char* tag, const char* value)
00022 {
00023     setTag(tag, value);
00024 }
00025 
00026 
00027 SamHeaderTag::SamHeaderTag(const SamHeaderTag& oldTag)
00028 {
00029     setTag(oldTag.myTag.c_str(), oldTag.myValue.c_str());
00030 }
00031 
00032 
00033 SamHeaderTag::~SamHeaderTag()
00034 {
00035 }
00036 
00037 
00038 // Add this tag to the passed in tag string.
00039 // NOTE: does not clear tagString.
00040 bool SamHeaderTag::getTagString(std::string& tagString)
00041 {
00042     if(myValue.length() != 0)
00043     {
00044         // There is a value associated with this tag, so add it to the string.
00045         tagString += "\t";
00046         tagString += myTag;
00047         tagString += ":";
00048         tagString += myValue;
00049         return(true);
00050     }
00051     // This tag has no associated value, return false.
00052     return(false);
00053 }
00054 
00055 
00056 // Set this tag to the passed in tag and value.
00057 bool SamHeaderTag::setTag(const char* tag, const char* value)
00058 {
00059     myTag = tag;
00060     myValue = value;
00061     return(true);
00062 }
00063 
00064 
00065 // Set the value associated with this tag to the passed in value.
00066 bool SamHeaderTag::setValue(const char* value)
00067 {
00068     myValue = value;
00069     return(true);
00070 }
00071 
00072 
00073 // Return the tag for this tag.
00074 const char* SamHeaderTag::getTag()
00075 {
00076     return(myTag.c_str());
00077 }
00078 
00079 
00080 // Return the value associated with this tag.
00081 const char* SamHeaderTag::getValue()
00082 {
00083     return(myValue.c_str());
00084 }
00085 
00086 
00087 // Return true if there is a non-blank value associated with this tag.
00088 bool SamHeaderTag::hasValue()
00089 {
00090     return(myValue.size() != 0);
00091 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends