"Fossies" - the Fresh Open Source Software Archive

Member "ivtools-ivtools-2.0.4/src/Attribute/attribute.c" (9 Oct 2020, 2262 Bytes) of package /linux/misc/ivtools-ivtools-2.0.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "attribute.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (c) 1996 Vectaport Inc.
    3  *
    4  * Permission to use, copy, modify, distribute, and sell this software and
    5  * its documentation for any purpose is hereby granted without fee, provided
    6  * that the above copyright notice appear in all copies and that both that
    7  * copyright notice and this permission notice appear in supporting
    8  * documentation, and that the names of the copyright holders not be used in
    9  * advertising or publicity pertaining to distribution of the software
   10  * without specific, written prior permission.  The copyright holders make
   11  * no representations about the suitability of this software for any purpose.
   12  * It is provided "as is" without express or implied warranty.
   13  *
   14  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
   15  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
   16  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL,
   17  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
   18  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
   19  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
   20  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   21  * 
   22  */
   23 
   24 #include <Attribute/attribute.h>
   25 #include <Attribute/attrvalue.h>
   26 
   27 /*****************************************************************************/
   28 
   29 int Attribute::_symid = -1;
   30 
   31 Attribute::Attribute(const char* name, AttributeValue* value) {
   32     if (name)
   33     symbolid = symbol_add((char *)name);
   34     else
   35     symbolid = -1;
   36     valueptr = value;
   37 }
   38 
   39 Attribute::Attribute(int symid, AttributeValue* value) {
   40   symbolid = symid;
   41   valueptr = value;
   42 }
   43 
   44 Attribute::Attribute(const Attribute& attr) {
   45     symbolid = attr.symbolid;
   46     if (symbolid != -1) // for reference count
   47     symbol_add(symbol_pntr(symbolid));
   48     valueptr = new AttributeValue(*attr.valueptr);
   49 }
   50 
   51 Attribute::~Attribute() {
   52     if (0 && symbolid != -1)  // need to rewrite symbol table
   53     symbol_del(symbolid);
   54     delete valueptr;
   55 }
   56 
   57 const char* Attribute::Name() {
   58     return symbol_pntr(symbolid);
   59 }
   60 
   61 void Attribute::Value(AttributeValue* value) {
   62     delete valueptr;
   63     valueptr = value;
   64 }
   65 
   66 AttributeValue* Attribute::Value() {
   67     return valueptr;
   68 }
   69 
   70 int Attribute::SymbolId() {
   71     return symbolid;
   72 }