This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
deb-goldedplus/goldlib/gall/gutltag.h

116 lines
3.4 KiB
C
Raw Normal View History

2000-02-25 10:15:17 +00:00
// This may look like C code, but it is really -*- C++ -*-
// ------------------------------------------------------------------
// The Goldware Library
// Copyright (C) 1990-1999 Odinn Sorensen
// ------------------------------------------------------------------
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library 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
// ------------------------------------------------------------------
// $Id$
// ------------------------------------------------------------------
// Tag number types and set class.
// ------------------------------------------------------------------
#ifndef __gutltag_h
#define __gutltag_h
// ------------------------------------------------------------------
#include <gdefs.h>
#include <gfile.h>
// ------------------------------------------------------------------
// Constants
2005-10-07 12:41:11 +00:00
const uint32_t TAGN_INVALID = 0;
2000-02-25 10:15:17 +00:00
const uint RELN_INVALID = 0;
2005-10-07 12:41:11 +00:00
const uint32_t TAGN_MAX = ((uint32_t)-1);
2000-02-25 10:15:17 +00:00
const uint RELN_MAX = ((uint)-1);
const int TAGN_CLOSEST = true;
const int TAGN_EXACT = false;
// ------------------------------------------------------------------
// Tag class
class GTag {
public:
// ----------------------------------------------------------------
// Internal data
2005-10-07 12:41:11 +00:00
uint32_t* tag; // tag array
2000-02-25 10:15:17 +00:00
uint tags; // tags in array
uint count; // fake tags count
uint allocated; // actual allocated tags
uint granularity; // memory allocation optimization
// ----------------------------------------------------------------
// Constructor and destructor
GTag();
~GTag();
// ----------------------------------------------------------------
// User functions
void Reset();
void ResetAll() { Reset(); count = 0; }
2005-10-07 12:41:11 +00:00
uint32_t* Resize(uint __tags);
2000-02-25 10:15:17 +00:00
2005-10-07 12:41:11 +00:00
uint32_t* Append(uint32_t __tagn);
uint32_t* Add(uint32_t __tagn);
uint Del(uint32_t __tagn);
2000-02-25 10:15:17 +00:00
uint DelReln(uint __reln);
2005-10-07 12:41:11 +00:00
uint DelResize(uint32_t __tagn);
2000-02-25 10:15:17 +00:00
void Sort();
void ElimDups();
2005-10-07 12:41:11 +00:00
uint32_t CvtReln(uint __reln);
uint ToReln(uint32_t __tagn);
uint ToReln(uint32_t __tagn, int __closest);
2000-02-25 10:15:17 +00:00
2005-10-07 12:41:11 +00:00
uint Find(uint32_t __tagn) { return ToReln(__tagn); }
2000-02-25 10:15:17 +00:00
uint Tags() const { return tags; }
uint Count() const { return count; }
uint SetCount(uint n) { tags = count = n; return count; }
2005-10-07 12:41:11 +00:00
void Set(uint n, uint32_t t) { tag[n] = t; }
uint32_t Get(uint n) { return (tags and (n<tags)) ? tag[n] : TAGN_INVALID; }
2000-02-25 10:15:17 +00:00
2005-10-07 12:41:11 +00:00
uint32_t& operator[](uint n) { return tag[n]; }
uint32_t& at(uint n) { return tag[n]; }
2000-02-25 10:15:17 +00:00
void Load(gfile& fp);
void Save(gfile& fp);
// ----------------------------------------------------------------
};
// ------------------------------------------------------------------
#endif
// ------------------------------------------------------------------