1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
/**
* @file thobjectname.cxx
*/
/* Copyright (C) 2000 Stacho Mudrak
*
* $Date: $
* $RCSfile: $
* $Revision: $
*
* --------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* --------------------------------------------------------------------
*/
#include "thobjectname.h"
#include "thexception.h"
#include "thparse.h"
#include "thdatabase.h"
thobjectname::thobjectname()
{
this->clear();
}
void thobjectname::clear()
{
this->name = NULL;
this->survey = NULL;
this->psurvey = NULL;
this->id = 0;
}
bool thobjectname::is_empty()
{
return (this->name == NULL);
}
void thparse_objectname(thobjectname & ds, thmbuffer * sstore, char * src)
{
ds.name = src;
size_t snl = strlen(src), sni;
for(sni = 0; sni < snl; sni++, src++)
if (*src == '@') {
*src = 0;
ds.survey = src + 1;
break;
}
if (!th_is_extkeyword(ds.name))
ththrow(("invalid object name -- %s", ds.name))
if (ds.survey != NULL)
if (!th_is_keyword_list(ds.survey, '.'))
ththrow(("invalid survey name -- %s", ds.survey));
ds.name = sstore->append(ds.name);
if (ds.survey != NULL)
ds.survey = sstore->append(ds.survey);
ds.psurvey = thdb.get_current_survey();
}
void fprintf(FILE * fh, thobjectname & ds)
{
if (ds.name != NULL)
fprintf(fh, "%s", ds.name);
else
fprintf(fh, "-");
if (ds.survey != NULL)
fprintf(fh, "@%s", ds.survey);
if (ds.id > 0)
fprintf(fh, ":%ld", ds.id);
}
|