00001 /* 00002 Copyright (C) 2003, 2004 Zentaro Kavanagh 00003 00004 Copyright (C) 2003, 2004 Commonwealth Scientific and Industrial Research 00005 Organisation (CSIRO) Australia 00006 00007 Redistribution and use in source and binary forms, with or without 00008 modification, are permitted provided that the following conditions 00009 are met: 00010 00011 - Redistributions of source code must retain the above copyright 00012 notice, this list of conditions and the following disclaimer. 00013 00014 - Redistributions in binary form must reproduce the above copyright 00015 notice, this list of conditions and the following disclaimer in the 00016 documentation and/or other materials provided with the distribution. 00017 00018 - Neither the name of CSIRO Australia nor the names of its 00019 contributors may be used to endorse or promote products derived from 00020 this software without specific prior written permission. 00021 00022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00025 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR 00026 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00027 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00028 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00029 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00030 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00031 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00032 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 #include "stdafx.h" 00035 #include <libCMMLTags/C_HeadTag.h> 00036 00037 C_HeadTag::C_HeadTag(void) 00038 { 00039 mTagType = C_CMMLTag::HEAD; 00040 mMetaList = new C_MetaTagList; 00041 mTitle = new C_TitleTag; 00042 mBase = NULL; 00043 } 00044 00045 C_HeadTag::~C_HeadTag(void) 00046 { 00047 delete mTitle; 00048 delete mBase; 00049 delete mMetaList; 00050 00051 } 00052 00053 //Accessors 00054 wstring C_HeadTag::profile() { 00055 return mProfile; 00056 } 00057 C_TitleTag* C_HeadTag::title() { 00058 return mTitle; 00059 } 00060 C_BaseTag* C_HeadTag::base() { 00061 return mBase; 00062 } 00063 C_MetaTagList* C_HeadTag::metaList() { 00064 return mMetaList; 00065 } 00066 //Mutators 00067 void C_HeadTag::setProfile(wstring inProfile) { 00068 mProfile = inProfile; 00069 } 00070 void C_HeadTag::setTitle(C_TitleTag* inTitle) { 00071 delete mTitle; 00072 mTitle = inTitle; 00073 } 00074 00075 void C_HeadTag::setMetaList(C_MetaTagList* inMetaList) { 00076 delete mMetaList; 00077 mMetaList = inMetaList; 00078 } 00079 void C_HeadTag::setBase(C_BaseTag* inBase) { 00080 delete mBase; 00081 mBase = inBase; 00082 } 00083 //Other 00084 00085 void C_HeadTag::privateClone(C_CMMLTag* outTag) { 00086 C_HumReadCMMLTag::privateClone(outTag); 00087 C_HeadTag* locTag = reinterpret_cast<C_HeadTag*>(outTag); 00088 locTag->setProfile(mProfile); 00089 00090 if (mBase != NULL) { 00091 locTag->setBase(mBase->clone()); 00092 } 00093 locTag->setMetaList(mMetaList->clone()); 00094 locTag->setTitle(mTitle->clone()); 00095 } 00096 C_CMMLTag* C_HeadTag::genericClone() { 00097 return clone(); 00098 } 00099 C_HeadTag* C_HeadTag::clone() { 00100 C_HeadTag* retTag = new C_HeadTag; 00101 privateClone(retTag); 00102 return retTag; 00103 00104 } 00105 00106 00107 wstring C_HeadTag::toString() { 00108 //TODO::: Should use new helper functions !! 00109 wstring retStr = L"<head"; 00110 00111 if (mId.size() != 0) { 00112 retStr += L" id=\""; 00113 retStr += escapeEntities(mId); 00114 retStr += L"\""; 00115 } 00116 00117 retStr += makeLangElements(); 00118 00119 if (mProfile.size() != 0) { 00120 retStr += L" profile=\""; 00121 retStr += escapeEntities(mProfile); 00122 retStr += L"\""; 00123 } 00124 retStr+= L">\n"; 00125 00126 if (mBase != NULL) { 00127 retStr += mBase->toString(); 00128 } 00129 00130 retStr += mTitle->toString(); 00131 retStr += mMetaList->toString(); 00132 retStr += L"</head>\n\n"; 00133 return retStr; 00134 }