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()
00028 {
00029 }
00030 
00031 
00032 // Add this tag to the passed in tag string.
00033 // NOTE: does not clear tagString.
00034 bool SamHeaderTag::getTagString(std::string& tagString)
00035 {
00036     if(myValue.length() != 0)
00037     {
00038         // There is a value associated with this tag, so add it to the string.
00039         tagString += "\t";
00040         tagString += myTag;
00041         tagString += ":";
00042         tagString += myValue;
00043         return(true);
00044     }
00045     // This tag has no associated value, return false.
00046     return(false);
00047 }
00048 
00049 
00050 // Set this tag to the passed in tag and value.
00051 bool SamHeaderTag::setTag(const char* tag, const char* value)
00052 {
00053     myTag = tag;
00054     myValue = value;
00055     return(true);
00056 }
00057 
00058 
00059 // Set the value associated with this tag to the passed in value.
00060 bool SamHeaderTag::setValue(const char* value)
00061 {
00062     myValue = value;
00063     return(true);
00064 }
00065 
00066 
00067 // Return the tag for this tag.
00068 const char* SamHeaderTag::getTag()
00069 {
00070     return(myTag.c_str());
00071 }
00072 
00073 
00074 // Return the value associated with this tag.
00075 const char* SamHeaderTag::getValue()
00076 {
00077     return(myValue.c_str());
00078 }
00079 
00080 
00081 // Return true if there is a non-blank value associated with this tag.
00082 bool SamHeaderTag::hasValue()
00083 {
00084     return(myValue.size() != 0);
00085 }
Generated on Wed Nov 17 15:38:27 2010 for StatGen Software by  doxygen 1.6.3