DtMmdb: move to lib directory as a standalone library.

This commit is contained in:
Liang Chang
2022-01-13 00:15:14 +08:00
parent f3baea9faa
commit e93b2bc626
589 changed files with 31 additions and 2985 deletions

View File

@@ -1,43 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $TOG: FPExceptions.h /main/4 1998/04/17 11:46:25 mgreess $ */
#ifndef _FPExceptions_h
#define _FPExceptions_h
#include "dti_excs/Exceptions.hh"
/////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////
class hardCopyRendererException : public Exception
{
public:
DECLARE_EXCEPTION(hardCopyRendererException, Exception)
};
#define CASTHCREXCEPT
#endif /* _FPExceptions_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,51 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $TOG: FPset.C /main/4 1998/04/17 11:46:42 mgreess $
#include "HardCopy/FPset.h"
FPset::FPset(int s, const Element& element,
const FeatureSet& local,
const FeatureSet& complete,
const FeatureSet& parent) :
ptrs(0), count(s), f_QuaddingString(0),
f_element(&element),
f_local(&local),
f_complete(&complete),
f_parent(&parent)
{
ptrs = new featureProcessorPtr[count];
}
unsigned int FPset::operator==(const FPset&)
{
throw(CASTHCREXCEPT hardCopyRendererException());
return 1;
}
FPset::~FPset()
{
for (int i=0; i<count; i++ )
delete ptrs[i];
delete ptrs;
}

View File

@@ -1,66 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: FPset.h /main/3 1996/06/11 17:04:12 cde-hal $ */
#ifndef _FPset_h
#define _FPset_h
#include "StyleSheet/Renderer.h"
#include "StyleSheet/Const.h"
#include "StyleSheet/Element.h"
#include "HardCopy/FPExceptions.h"
#include "HardCopy/HardCopyFP.h"
#include "HardCopy/lout_limits.h"
class FPset
{
public:
/*
FPset(const FPset& fps) : ptrs(fps.ptrs), count(fps.count), f_QuaddingString(0) {};
FPset(featureProcessorPtr* p, int s) : ptrs(p), count(s), f_QuaddingString(0) {};
*/
FPset(int s, const Element&, const FeatureSet&,
const FeatureSet&, const FeatureSet&);
~FPset();
const Element& element() { return *f_element; };
const FeatureSet& local() { return *f_local; };
const FeatureSet& complete() { return *f_complete; };
const FeatureSet& parent() { return *f_parent; };
FPset operator=(const FPset&);
unsigned int operator==(const FPset&);
featureProcessorPtr* ptrs;
int count;
const char* f_QuaddingString;
const Element* f_element;
const FeatureSet* f_local;
const FeatureSet* f_complete;
const FeatureSet* f_parent;
};
#endif

View File

@@ -1,283 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $TOG: HardCopyFP.C /main/4 1998/04/17 11:46:58 mgreess $
#include "HardCopyFP.h"
char* loutFeatureProcessor::empty_string()
{
char* x = new char[1]; x[0] = 0;
return x;
}
char*
loutFeatureProcessor::prepend(const char* header, const char* body)
{
int hlen = strlen(header);
int blen = strlen(body);
char* x = new char[hlen + blen + 1];
*((char *) memcpy (x, header, hlen) + hlen) = '\0';
*((char *) memcpy (x + hlen, body, blen) + blen) = '\0';
return x;
}
void
loutFeatureProcessor::handleData(const char *data, unsigned int size, ostream& out)
{
for (unsigned int i=0; i<size; i++ )
out << data[i];
}
char* literalBuffer = new char[1024];
int literalBufferSize = 1024;
const char* loutFeatureProcessor::convertToLiteral(const char* str)
{
int size = strlen(str);
for (int i=0; i<size; i++ )
if ( str[i] == '\\' || str[i] == '"' ) {
if ( literalBufferSize < 2*size + 3 ) {
literalBufferSize = 2*size + 3;
literalBufferSize *= 2;
delete [] literalBuffer;
literalBuffer = new char[literalBufferSize];
}
int j = 0;
literalBuffer[j++] = '"';
for (int i=0; i<size; i++ ) {
if ( str[i] == '\\' || str[i] == '"' ) {
literalBuffer[j++] = '\\';
}
literalBuffer[j++] = str[i];
}
literalBuffer[j++] = '"';
literalBuffer[j] = 0;
return literalBuffer;
}
return str;
}
const char* loutFeatureProcessor::stringToCharPtr(const FeatureValue* f)
{
if ( f ) {
if ( f -> type() == FeatureValue::string ) {
const char* x = *f;
return x;
} else
throw(CASTHCREXCEPT hardCopyRendererException());
}
return 0;
}
unsigned int
loutFeatureProcessor::dimensionToFloat(
float& y,
FeatureValueDimension::Unit& unitOfY,
const FeatureValue* f,
FeatureValueDimension::Unit u
)
{
if ( f ) {
if ( f -> type() == FeatureValue::dimension ) {
FeatureValueDimension* x = (FeatureValueDimension*)f;
unitOfY = x -> unit();
if ( u == FeatureValueDimension::NONE ) {
if ( x -> unit() == FeatureValueDimension::PICA ) {
y = x -> getValue(FeatureValueDimension::POINT);
unitOfY = FeatureValueDimension::POINT;
} else
y = *x;
} else {
y = x -> getValue(u);
}
return 1;
} else
throw(CASTHCREXCEPT hardCopyRendererException());
} else {
y = 0;
return 0;
}
}
const char*
loutFeatureProcessor::dimensionToCharPtr(const FeatureValue* f,
FeatureValueDimension::Unit u)
{
static char dBuf[50];
float y;
FeatureValueDimension::Unit unitOfY;
if ( dimensionToFloat(y, unitOfY, f, u) ) {
if ( u != FeatureValueDimension::NONE ) {
unitOfY = u;
}
switch ( unitOfY ) {
case FeatureValueDimension::INCH:
snprintf(dBuf, sizeof(dBuf), "%.2fi", y);
break;
case FeatureValueDimension::PICA:
throw(CASTHCREXCEPT hardCopyRendererException());
break;
case FeatureValueDimension::POINT:
snprintf(dBuf, sizeof(dBuf), "%.2fp", y);
break;
case FeatureValueDimension::CM:
snprintf(dBuf, sizeof(dBuf), "%.2fc", y);
break;
case FeatureValueDimension::PIXEL:
throw(CASTHCREXCEPT hardCopyRendererException());
break;
default:
throw(CASTHCREXCEPT hardCopyRendererException());
}
return (const char*)dBuf;
} else
return 0;
}
const char*
featureProcessor::getFeatureValue(const Feature* f)
{
if ( f )
return stringToCharPtr(f -> value());
else
return 0;
}
FeatureValueArray*
featureProcessor::getFeatureValueArray(const Feature* f)
{
if ( f ) {
if ( f -> value() -> type() == FeatureValue::array )
return (FeatureValueArray*)(f -> value());
else {
MESSAGE(cerr, form("%s is not of an array type.", f -> name().name()));
throw(CASTHCREXCEPT hardCopyRendererException());
}
} else
return 0;
}
unsigned int
featureProcessor::getDimensionValue(float& x, const Feature* f,
FeatureValueDimension::Unit u)
{
FeatureValueDimension::Unit unit;
if ( f )
return dimensionToFloat(x, unit, f -> value(), u);
else
return 0;
}
const char*
featureProcessor::getDimensionValue(const Feature* f,
FeatureValueDimension::Unit u)
{
if ( f )
return dimensionToCharPtr(f -> value(), u);
else
return 0;
}
unsigned int
featureProcessor::getFeatureValue(int& x, const Feature* f)
{
if ( f ) {
x = *(f -> value());
return true;
} else
return false;
}
unsigned int
featureProcessor::getFeatureValue(float& x, const Feature* f)
{
if ( f ) {
x = *(f -> value());
return true;
} else
return false;
}
const FeatureSet *
featureProcessor::getFeatureSetValue(const Feature* f)
{
if ( f && f -> value() -> type() == FeatureValue::featureset )
return ((const FeatureValueFeatureSet *)f->value())->value();
else
return 0;
}
FeatureValue*
loutFeatureProcessor::evaluate(const char*)
{
MESSAGE(cerr, "featureProcessor::evaluate(): FP specific function should be called.");
throw(CASTHCREXCEPT hardCopyRendererException());
return 0;
}
unsigned int
loutFeatureProcessor::accept(const char*, const Expression*)
{
MESSAGE(cerr, "featureProcessor::accept(): FP specific function should be called");
throw(CASTHCREXCEPT hardCopyRendererException());
return false;
}
void loutFeatureProcessor::clear()
{
MESSAGE(cerr, "featureProcessor::clear(): FP specific function should be called");
throw(CASTHCREXCEPT hardCopyRendererException());
}
void
loutFeatureProcessor::preEvaluate(const Element& e)
{
MESSAGE(cerr, "featureProcessor::preEvaluate(): FP specific function should be called");
throw(CASTHCREXCEPT hardCopyRendererException());
}
void
loutFeatureProcessor::postEvaluate(const Element& e)
{
MESSAGE(cerr, "featureProcessor::postEvaluate(): FP specific function should be called");
throw(CASTHCREXCEPT hardCopyRendererException());
}

View File

@@ -1,154 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: HardCopyFP.h /main/3 1996/06/11 17:04:22 cde-hal $ */
#ifndef _fp_h
#define _fp_h 1
#include <iostream>
using namespace std;
#include "FPExceptions.h"
#include "StyleSheet/Feature.h"
#include "StyleSheet/FeatureValue.h"
#include "StyleSheet/Element.h"
#include "StyleSheet/Const.h"
#include "StyleSheet/Debug.h"
#include "utility/funcs.h"
enum BLOCK_MODE { NON_BLOCK, BLOCK };
extern enum BLOCK_MODE g_block_mode;
class featureProcessor : public Destructable
{
protected:
const char* f_name;
virtual const char* stringToCharPtr(const FeatureValue*) = 0;
virtual unsigned int dimensionToFloat(float& Y,
FeatureValueDimension::Unit& UnitOfY,
const FeatureValue*,
FeatureValueDimension::Unit) = 0;
virtual const char* dimensionToCharPtr(const FeatureValue*,
FeatureValueDimension::Unit) = 0;
// turn to Hard Copy engine specific literal
virtual const char* convertToLiteral(const char* str) = 0;
public:
featureProcessor(featureProcessor& x): f_name(x.f_name) {};
featureProcessor(const char* name): f_name(name) {};
virtual ~featureProcessor() {};
virtual featureProcessor* clone() = 0;
virtual void handleBegElement(const Element &element, const FeatureSet&, const FeatureSet&, const FeatureSet&, const FeatureSet& initialFeatureSet, ostream&) = 0;
virtual void handleEndElement(ostream&) = 0;
virtual void handleData(const char *data, unsigned int size, ostream&)=0;
const char* name() { return f_name; };
// evaluate the variable (in x.y.z form) to a feature value.
virtual FeatureValue* evaluate(const char* variableName) = 0;
virtual unsigned int accept(const char* nm, const Expression*) = 0;
virtual void preEvaluate(const Element&) = 0;
virtual void postEvaluate(const Element&) = 0;
virtual void clear() = 0;
////////////////////////////////////////
// functions for getting feature values.
//
// Sample usage:
// int x;
// if ( getFeatureValue(x, FeatureSet.deep_lookup(FONT, FONT_SIZE)) ) {
// //use x here
// }
////////////////////////////////////////
//
// default value (NONE) means using whatever unit is available
// Otherwise, a conversion is performed
//
unsigned int getDimensionValue(float& y,
const Feature*,
FeatureValueDimension::Unit = FeatureValueDimension::NONE);
const char *getDimensionValue(const Feature*,
FeatureValueDimension::Unit = FeatureValueDimension::NONE);
const char *getFeatureValue(const Feature*);
unsigned int getFeatureValue(int&, const Feature*);
unsigned int getFeatureValue(float&, const Feature*);
FeatureValueArray* getFeatureValueArray(const Feature*);
const FeatureSet *getFeatureSetValue(const Feature*);
};
typedef featureProcessor* featureProcessorPtr;
class loutFeatureProcessor : public featureProcessor
{
protected:
unsigned int f_change;
protected:
char* empty_string();
char* prepend(const char*, const char*);
// turn to Hard Copy engine specific literal
const char* convertToLiteral(const char* str);
public:
loutFeatureProcessor(loutFeatureProcessor& x) :
featureProcessor(x), f_change(x.f_change) {};
loutFeatureProcessor(const char* name) :
featureProcessor(name), f_change(false) {};
~loutFeatureProcessor() {};
virtual void handleEndElement(ostream& out) {
if ( f_change == true )
out << "}";
};
virtual void handleData(const char *data, unsigned int size, ostream&);
const char* stringToCharPtr(const FeatureValue*);
unsigned int dimensionToFloat(float&,
FeatureValueDimension::Unit& unitOfY,
const FeatureValue*,
FeatureValueDimension::Unit);
const char* dimensionToCharPtr(const FeatureValue*,
FeatureValueDimension::Unit);
virtual FeatureValue* evaluate(const char* variableName) ;
virtual unsigned int accept(const char* nm, const Expression*) ;
virtual void preEvaluate(const Element&) ;
virtual void postEvaluate(const Element&) ;
virtual void clear() ;
};
#endif

View File

@@ -1,11 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
noinst_LTLIBRARIES = libHardCopy.la
libHardCopy_la_CXXFLAGS = -DEXPAND_TEMPLATES -DCDE_NEXT -I..
libHardCopy_la_SOURCES = FPset.C \
HardCopyFP.C \
TemplatesAutoNumber.C \
autoNumber.C \
autoNumberFP.C

View File

@@ -1,85 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: TemplatesAutoNumber.C /main/9 1996/10/08 19:23:56 cde-hal $
#include "HardCopy/autoNumber.h"
#ifdef CDE_NEXT
//#include <StyleSheet/cde_next.h>
#include "dti_cc/CC_String.h"
#include "dti_cc/cc_hdict.h"
#include "dti_cc/CC_Dlist.h"
#include "dti_cc/CC_Stack.C"
#endif /* end of CDE_NEXT */
#if defined(sun) || defined(hpux)
#ifndef CDE_NEXT /* { */
typedef hashTable<CC_String,autoNumberListT> _f10_;
typedef hashTable<CC_String,autoNumber> _f11_;
typedef CC_TPtrSlistDictionary<CC_String,autoNumberListT> _f12_;
typedef CC_TPtrSlistDictionary<CC_String,autoNumber> _f13_;
typedef hashTableIterator<CC_String,autoNumber> _f14_;
typedef hashTableIterator<CC_String, autoNumberListT> _f15;
#else
typedef CC_TPtrSlist<autoNumber> _CC_TPtrSlist_autoNumber_;
typedef hashTable<CC_String, autoNumberListT> _hashTable_CC_String_autoNumberListT_;
typedef hashTable<CC_String,autoNumber> _hashTable_CC_String_autoNumber_;
typedef hashTableIterator<CC_String,autoNumber> _hashTableIterator_CC_String_autoNumber_;
typedef hashTableIterator<CC_String, autoNumberListT> _hashTableIterator_CC_String_autoNumberListT_;
typedef Stack<int> _Stack_int_;
#endif /* end of CDE_NEXT } */
#endif
#ifdef _IBMR2
#pragma define ( hashTable<CC_String,autoNumberListT> )
#pragma define ( hashTable<CC_String,autoNumber> )
#ifndef CDE_NEXT
#pragma define ( CC_TPtrSlistDictionary<CC_String,autoNumberListT> )
#pragma define ( CC_TPtrSlistDictionary<CC_String,autoNumber> )
#endif
#pragma define ( CC_TPtrSlist<autoNumber> )
#pragma define ( hashTableIterator<CC_String,autoNumber> )
#pragma define ( hashTableIterator<CC_String,autoNumberListT> )
#pragma define ( Stack<int> )
#endif

View File

@@ -1,2 +0,0 @@
// all_tmplts - force instantiation of all templates under HPUX
@all

View File

@@ -1,528 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $TOG: autoNumber.C /main/6 1998/04/17 11:47:13 mgreess $
#include <ctype.h>
#include <limits.h>
#if defined(CSRG_BASED)
#define MAXINT INT_MAX
#else
#include <values.h>
#endif
#include "HardCopy/autoNumber.h"
#include "HardCopy/FPExceptions.h"
buffer autoNumber::f_buf(128);
autoNumber::autoNumber(const char* nm, enum autoNumberType t, int delta, const char* prefix, const char* postfix) :
f_name(strdup(nm)), f_type(t), f_delta(delta),
f_prefix(strdup(prefix)), f_postfix(strdup(postfix)),
f_initialValue(0)
{
int x = strlen(prefix) + strlen(postfix) + 12;
if ( x > f_buf.buf_sz() )
f_buf.expand_chunk(x);
}
autoNumber::~autoNumber()
{
delete f_name;
delete f_prefix;
delete f_postfix;
while (f_values.entries())
f_values.pop();
while (f_serial_nums.entries())
f_serial_nums.pop();
}
void autoNumber::setNumTagsSeen()
{
if (f_serial_nums.entries() > 0 && f_serial_nums.top() < MAXINT)
f_serial_nums.top()++;
}
void
autoNumber::reset()
{
// reset stack of values
while (f_values.entries() > 1) // leave one entry for re-use
f_values.pop();
f_values.top() = f_initialValue;
// reset stack of serial numbers
while (f_serial_nums.entries() > 1) // leave one entry for re-use
f_serial_nums.pop();
f_serial_nums.top() = 0;
}
void
autoNumber::push()
{
f_values.push(f_initialValue);
f_serial_nums.push(0);
}
void
autoNumber::pop()
{
if (f_values.entries() > 1)
f_values.pop();
if (f_serial_nums.entries() > 1)
f_serial_nums.pop();
}
unsigned int autoNumber::operator==(const autoNumber&)
{
return false;
}
ostream& operator<<(ostream& out, const autoNumber& an)
{
debug(cerr, an.f_name);
debug(cerr, an.f_delta);
debug(cerr, an.f_prefix);
debug(cerr, an.f_postfix);
debug(cerr, an.f_type);
debug(cerr, an.f_serial_nums.top());
return out;
}
//////////////////////////////////////////////////
//
//////////////////////////////////////////////////
autoNumberNumeric::autoNumberNumeric(const char* nm, int delta, int inv,
const char* prefix, const char* postfix) :
autoNumber(nm, NUMERIC, delta, prefix, postfix)
{
f_initialValue = inv;
f_values.push(f_initialValue);
f_serial_nums.push(0);
}
autoNumberNumeric::~autoNumberNumeric()
{
}
void autoNumberNumeric::setNextValue()
{
if (f_serial_nums.entries() && f_values.entries())
{
if (f_serial_nums.top() >= 2)
f_values.top() += f_delta;
}
}
const char*
autoNumberNumeric::getValue()
{
char* ptr = f_buf.get_base();
int ptrlen = f_buf.buf_sz();
if (f_values.entries())
snprintf(ptr, ptrlen, "%s",
form("%s%d%s", f_prefix, f_values.top(), f_postfix));
else
*ptr = 0;
return ptr;
}
//////////////////////////////////////////////////
//
//////////////////////////////////////////////////
autoNumberCased::autoNumberCased(const char* nm, autoNumberType an_t,
int delta, enum CaseType ct, const char* prefix, const char* postfix) :
autoNumber(nm, an_t, delta, prefix, postfix), f_case(ct)
{
}
autoNumberCased::~autoNumberCased()
{
}
//////////////////////////////////////////////////
//
//////////////////////////////////////////////////
char autoNumberAlphabetic::f_lowerCaseLetters[26] =
{
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z'
};
char autoNumberAlphabetic::f_upperCaseLetters[26] =
{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'T', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z'
};
autoNumberAlphabetic::autoNumberAlphabetic(
const char* nm,
int delta,
CaseType ct,
const char* InitialValue, const char* prefix, const char* postfix
) :
autoNumberCased(nm, ALPHABETIC, delta, ct, prefix, postfix)
{
f_initialValue = alphaToInt(InitialValue, f_case);
f_values.push(f_initialValue);
f_serial_nums.push(0);
}
autoNumberAlphabetic::~autoNumberAlphabetic()
{
}
static const int base = 26;
int autoNumberAlphabetic::alphaToInt(const char* alpha, enum CaseType a_case)
{
int digits = strlen(alpha);
int i;
int offset = 0;
switch ( a_case ) {
case UPPER:
for (i=0; i<digits; i++)
if ( isupper(alpha[i]) == 0 ) {
MESSAGE(cerr,
"Initial alphabetic autonumber value is not capitalized");
throw(CASTHCREXCEPT hardCopyRendererException());
}
offset = 'A';
break;
case LOWER:
for (i=0; i<digits; i++)
if ( islower(alpha[i]) == 0 ) {
MESSAGE(cerr,
"Initial alphabetic autonumber value is not in small case");
throw(CASTHCREXCEPT hardCopyRendererException());
}
offset = 'a';
break;
}
int x = 0;
int expansionFactor = 1;
for ( i=digits-1; i>=0; i-- ) {
x += (alpha[i] - offset)*expansionFactor;
expansionFactor *= base;
}
x += int((pow((double)base, digits)-1) / (base-1)) - 1;
return x;
}
// Algorithm: converting integer values to/from alphabetic autonumbers
// The alphabetic autonumbers are grouped into blocks where each
// block represents autonumbers with same number of digits. The size
// of a block of d digts = 26^d. Now assigning a sequece number (an integer)
// to each autonumber in blocks. This number in fact is the integer
// value (internal) of the autonumber.
//
// block 1: [a, b, c, ..., z]
// seq num: [0, 1, 2, 25]
//
// block 2: [aa, ab, ac, ..., zz]
// seq num: [26, 27, 28, 701]
//
// In general, the 1st sequence number in a block for d digits:
// x = int((pow(26, d)-1) / (26-1)) - 1;
//
// given an integer x, its number of ditigs when converted to an autonumber:
// digits = int(log((26-1)*x + 26) / log(26));
const char* autoNumberAlphabetic::intToAlpha(int x, enum CaseType a_case)
{
if ( x < 0 ) {
MESSAGE(cerr, "Negaitve alphabetic autonumber value");
throw(CASTHCREXCEPT hardCopyRendererException());
}
int digits = int(log((double)(base-1)*x + base) / log((double)base));
if ( digits > 50 ) {
MESSAGE(cerr, "alphabetic autonumber value too large");
throw(CASTHCREXCEPT hardCopyRendererException());
}
//debug(cerr, digits);
//debug(cerr, (pow(base, digits)-1) / (25) -1);
x -= int((pow((double)base, digits)-1) / (base-1)) - 1;
char* letters =
(a_case == UPPER ) ? f_upperCaseLetters : f_lowerCaseLetters;
int y, z;
static char buf[51], buf1[51];
int i =0;
while (1) {
y = x % base;
z = x / base;
buf1[i++] = letters[y];
if ( z == 0 )
break;
x = z;
}
int k;
for (k=0; k<digits-i; k++ )
buf[k] = letters[0];
int n;
for (n=0; n<i; n++ )
buf[k+n] = buf1[n];
buf[k+n] = 0;
//debug(cerr, buf);
return buf;
}
void autoNumberAlphabetic::setNextValue()
{
if (f_serial_nums.entries() && f_values.entries())
{
if (f_serial_nums.top() >= 2)
f_values.top() += f_delta;
}
}
const char* autoNumberAlphabetic::getValue()
{
char* ptr = f_buf.get_base();
int ptrlen = f_buf.buf_sz();
if (f_values.entries())
snprintf(ptr, ptrlen, "%s", form("%s%s%s", f_prefix,
intToAlpha(f_values.top(), f_case), f_postfix));
else
*ptr = 0;
return ptr;
}
//////////////////////////////////////////////////
//
//////////////////////////////////////////////////
char autoNumberRoman::RomanNumberBuf[256];
autoNumberRoman::autoNumberRoman(
const char* nm,
int delta,
CaseType ct,
const char* InitialValue, const char* prefix, const char* postfix
) :
autoNumberCased(nm, ROMAN, delta, ct, prefix, postfix)
{
f_initialValue = RomanToArabic(InitialValue);
f_values.push(f_initialValue);
f_serial_nums.push(0);
}
autoNumberRoman::~autoNumberRoman()
{
}
void autoNumberRoman::setNextValue()
{
if (f_serial_nums.entries() && f_values.entries())
{
if (f_serial_nums.top() >= 2) {
f_values.top() += f_delta;
if (f_values.top() < 1) {
MESSAGE(cerr, "Value too small.");
throw(CASTHCREXCEPT hardCopyRendererException());
}
}
}
}
const char* autoNumberRoman::getValue()
{
char* ptr;
if (f_values.entries())
return ArabicToRoman(f_values.top());
else {
ptr = f_buf.get_base();
*ptr = 0;
}
return ptr;
}
int autoNumberRoman::getDigit(const char*& p)
{
int x = 0;
switch ( p[0] ) {
case 'I':
case 'i':
if ( p[1] != 0 && p[1] == 'V' ) {
p++;
x = 4;
} else
x = 1;
break;
case 'V':
case 'v':
x = 5;
break;
case 'X':
case 'x':
if ( p[1] != 0 && p[1] == 'I' ) {
x = 9;
p++;
} else
x = 10;
break;
case 'L': //50
case 'l':
if ( p[1] != 0 && p[1] == 'X' ) {
x = 40;
p++;
} else
x = 50;
break;
case 'C': // 100
case 'c':
if ( p[1] != 0 && p[1] == 'X' ) {
x = 90;
p++;
} else
x = 100;
break;
case 'D': // 500
case 'd':
if ( p[1] != 0 && p[1] == 'C' ) {
x = 400;
p++;
} else
x = 500;
break;
case 'M': //1000
case 'm':
if ( p[1] != 0 && p[1] == 'C' ) {
x = 900;
p++;
} else
x = 1000;
break;
default:
MESSAGE(cerr, "unknown roman numeral letter");
throw(CASTHCREXCEPT hardCopyRendererException());
}
p++;
return x;
}
int autoNumberRoman::RomanToArabic(const char* romanString)
{
int x = 0;
const char* bound = romanString + strlen(romanString);
const char* p = (char*)romanString;
while ( p != bound ) {
x += getDigit(p);
}
return x;
}
const char* romanCardinals[4][9] =
{
{ "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX" },
{ "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC" },
{ "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM" },
{ "M", "MM", "MMM", "MV", "V", "VM", "VMM", "VMMM", "MX" }
};
const char*
autoNumberRoman::ArabicToRoman(int x)
{
unsigned int len, slen;
RomanNumberBuf[0] = 0;
if ( x > 3999 ) {
MESSAGE(cerr, "Value too large.");
throw(CASTHCREXCEPT hardCopyRendererException());
}
char* buf = form("%d", x);
int j=strlen(buf)-1;
for ( unsigned int i=0; i<strlen(buf); i++ ) {
if ( buf[i] != '0' )
{
const char* romanCardinal = romanCardinals[j][buf[i]-'1'];
char precise_romanCardinal[8];
int k;
if (f_case == UPPER) {
for (k=0; romanCardinal[k]; k++)
precise_romanCardinal[k] = romanCardinal[k];
precise_romanCardinal[k] = 0;
}
else {
for (k=0; romanCardinal[k]; k++)
precise_romanCardinal[k] = tolower(romanCardinal[k]);
precise_romanCardinal[k] = 0;
}
slen = strlen(RomanNumberBuf);
len = MIN(strlen(precise_romanCardinal), 256 - 1 - slen);
*((char *) memcpy(RomanNumberBuf + slen,
precise_romanCardinal, len) + len) = '\0';
}
j--;
}
return RomanNumberBuf;
}
////////////////////////////////////////////////////
//
////////////////////////////////////////////////////
unsigned int
autoNumberListT::operator==(const autoNumberListT&)
{
return false;
}

View File

@@ -1,186 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: autoNumber.h /main/6 1996/10/08 19:24:51 cde-hal $ */
#ifndef _autoNumber_h
#define _autoNumber_h 1
#ifndef CDE_NEXT
#else
#include "dti_cc/CC_Slist.h"
#include "dti_cc/CC_Stack.h"
#endif
#include "utility/buffer.h"
#include "FPExceptions.h"
class autoNumber : public Destructable
{
public:
enum autoNumberType { NUMERIC, ALPHABETIC, ROMAN };
autoNumber(const char* nm, enum autoNumberType, int delta, const char* prefix, const char* postfix);
virtual ~autoNumber();
void setNumTagsSeen();
virtual const char* getValue() = 0;
virtual void setNextValue() = 0;
virtual void reset();
void push();
void pop();
unsigned int operator==(const autoNumber&);
friend ostream& operator<<(ostream&, const autoNumber&) ;
protected:
static buffer f_buf;
char* f_name;
enum autoNumberType f_type;
int f_delta;
char* f_prefix;
char* f_postfix;
int f_initialValue;
Stack<int> f_values;
Stack<int> f_serial_nums;
};
class autoNumberNumeric : public autoNumber
{
public:
autoNumberNumeric (const char* name, int delta, int initialValue, const char* prefix, const char* postfix);
~autoNumberNumeric();
void setNextValue() ;
const char* getValue() ;
};
class autoNumberCased : public autoNumber
{
public:
enum CaseType { UPPER, LOWER};
autoNumberCased(const char* name,
enum autoNumberType,
int delta,
CaseType,
const char* prefix,
const char* postfix
);
~autoNumberCased();
protected:
CaseType f_case;
};
//////////////////////////////////////////////////////
// Sequence example:
// a, b, ..., z,
// aa, ab, az,
// ba, bb, bz,
// ... ...
//////////////////////////////////////////////////////
class autoNumberAlphabetic : public autoNumberCased
{
private:
static const int f_base;
static char f_lowerCaseLetters[26];
static char f_upperCaseLetters[26];
public:
autoNumberAlphabetic
(const char* name,
int delta,
CaseType,
const char* initialValue,
const char* prefix,
const char* postfix
);
~autoNumberAlphabetic();
void setNextValue() ;
const char* getValue() ;
// convert an integer to an alphabetic autonumber
// Example
// a <- 0, b <- 1, ..., z <- 25
// aa <- 26, ab <- 27, ..., az <- 51
static const char* intToAlpha(int, enum CaseType);
// convert an alphabetic autonumber to an integer
// Example
// a -> 0, b -> 1, ..., z -> 25
// aa -> 26, ab -> 27, ..., az -> 51
static int alphaToInt(const char*, enum CaseType);
};
class autoNumberRoman : public autoNumberCased
{
private:
static char RomanNumberBuf[256];
private:
static int getDigit(const char*&);
public:
autoNumberRoman
(const char* name,
int delta,
CaseType,
const char* initialValue,
const char* prefix,
const char* postfix
);
~autoNumberRoman();
void setNextValue() ;
const char* getValue() ;
static int RomanToArabic(const char*);
// ArabicToRoman needs to be non-static because of the requirement of
// case sensitiveness
const char* ArabicToRoman(int);
};
#ifndef CDE_NEXT
class autoNumberListT : public CC_TPtrSlist<autoNumber>
#else
class autoNumberListT : public CC_TPtrSlist<autoNumber>
#endif
{
public:
autoNumberListT() {};
virtual ~autoNumberListT() {};
unsigned int operator==(const autoNumberListT&);
} ;
#endif

View File

@@ -1,466 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $TOG: autoNumberFP.C /main/7 1998/04/17 11:47:29 mgreess $ */
#include "autoNumberFP.h"
#include "StyleSheet/Const.h"
#include "StyleSheet/Expression.h"
autoNumberFP gAutoNumberFP;
#ifndef CDE_NEXT
typedef CC_TPtrSlistIterator<autoNumber> autoNumberListIteratorT;
unsigned ANP_StringHash(const CC_String& str)
{
return str.hash();
}
#else
typedef CC_TPtrSlistIterator<autoNumber> autoNumberListIteratorT;
unsigned ANP_StringHash(const CC_String& str)
{
return str.hash();
}
#endif
///////////////////////////////////////////////
// static member initialization
///////////////////////////////////////////////
/*
f_autoNumberSet_t autoNumberFP::f_autoNumberSet(ANP_StringHash);
f_resetControlList_t autoNumberFP::f_resetControlList(ANP_StringHash);
f_registerList_t autoNumberFP::f_registerList(ANP_StringHash);
*/
///////////////////////////////////////////////
//
///////////////////////////////////////////////
autoNumberFP::autoNumberFP() :
f_autoNumberSet(ANP_StringHash),
f_resetControlList(ANP_StringHash),
f_registerList(ANP_StringHash)
{
}
autoNumberFP::~autoNumberFP()
{
f_autoNumberSet.clearAndDestroy();
f_resetControlList.clearAndDestroy();
f_registerList.clearAndDestroy();
}
const char* autoNumberFP::stringToCharPtr(const FeatureValue* f)
{
if ( f ) {
if ( f -> type() == FeatureValue::string ) {
const char* x = *f;
return x;
} else
throw(CASTHCREXCEPT hardCopyRendererException());
}
return 0;
}
#if 0
// reset autonumbers
void autoNumberFP::resetAutoNumbers(const char* name)
{
CC_String key(name);
autoNumberListT* anList = f_resetControlList.findValue(&key);
if ( anList == 0 )
return;
autoNumberListIteratorT l_iter(*anList);
while ( ++l_iter ) {
l_iter.key() -> reset();
}
}
#endif
void
autoNumberFP::pushAutoNumbers(const char* giname)
{
if (giname && *giname)
{
CC_String key(giname);
autoNumberListT* anList = f_resetControlList.findValue(&key);
if (anList)
{
autoNumberListIteratorT l_iter(*anList);
while ( ++l_iter )
l_iter.key()->push();
}
}
}
void
autoNumberFP::popAutoNumbers(const char* giname)
{
if (giname && *giname)
{
CC_String key(giname);
autoNumberListT* anList = f_resetControlList.findValue(&key);
if (anList)
{
autoNumberListIteratorT l_iter(*anList);
while ( ++l_iter )
l_iter.key()->pop();
}
}
}
// update autonumbers
void autoNumberFP::updateAutoNumbers(const char* name)
{
CC_String key(name);
autoNumberListT* anList = f_registerList.findValue(&key);
if ( anList == 0 )
return;
autoNumberListIteratorT l_iter(*anList);
while ( ++l_iter ) {
l_iter.key() -> setNextValue();
}
}
//////////////////////////////////////////////////////////////////////////
//
// Array fields:
// Type, InitValue, Delta, RegisterList, ControlList, [Prefix], [PostFix]
//
// Type, Pretfix and Postfix are strings.
// RegisterList and ControlList are array.
// InitValue and Delta are integers.
// Prefix and Postfix are optional
//////////////////////////////////////////////////////////////////////////
void
autoNumberFP::defineAutoNumber(const char* nm, const FeatureValue* f)
{
if ( f -> type() != FeatureValue::array ) {
debug(cerr, f -> type());
cerr << "Autonumber: should use an array to define.\n";
throw(CASTHCREXCEPT hardCopyRendererException());
}
FeatureValueArray* fa = (FeatureValueArray*)f;
if ( fa -> length() != 5 ) {
cerr << "Autonumber: invalid number of arguments.\n";
throw(CASTHCREXCEPT hardCopyRendererException());
}
// name
const char* name = nm;
// type
if ( (*fa)[0] -> type() != FeatureValue::string ) {
cerr << "Autonumber: type should be a string.\n";
throw(CASTHCREXCEPT hardCopyRendererException());
}
const char* type = stringToCharPtr((*fa)[0]);
// init value
if ( (*fa)[1] -> type() != FeatureValue::string ) {
cerr << "Autonumber: initial value should be a string.\n";
throw(CASTHCREXCEPT hardCopyRendererException());
}
const char* initvalue = stringToCharPtr((*fa)[1]);
// delta
if ( (*fa)[2] -> type() != FeatureValue::string ) {
cerr << "Autonumber: delta value should be a string.\n";
throw(CASTHCREXCEPT hardCopyRendererException());
}
int delta = atoi(stringToCharPtr((*fa)[2]));
// register list
FeatureValueArray* registerList = 0;
if ( (*fa)[3] -> type() != FeatureValue::array ) {
cerr << "Autonumber: counter list should be an array\n.";
throw(CASTHCREXCEPT hardCopyRendererException());
} else {
registerList = (FeatureValueArray*)(*fa)[3];
}
// control list
FeatureValueArray* controlList = 0;
if ( (*fa)[4] -> type() != FeatureValue::array ) {
cerr << "Autonumber: reset list should be an array\n.";
throw(CASTHCREXCEPT hardCopyRendererException());
} else {
controlList = (FeatureValueArray*)(*fa)[4];
}
// prefix
const char* prefix = "";
// postfix
const char* postfix = "";
//////////////////////////////////
// create the autonumber object
//////////////////////////////////
autoNumber* an = 0;
if ( strcasecmp(type, AUTO_NUMBER_NUMERIC) == 0 )
an = new autoNumberNumeric(
name, delta, atoi(initvalue), prefix, postfix
);
else
if ( strcasecmp(type, AUTO_NUMBER_ALPHABETIC_UPPERCASE) == 0 ) {
an = new autoNumberAlphabetic(
name, delta, autoNumberCased::UPPER, initvalue, prefix, postfix
);
} else
if ( strcasecmp(type, AUTO_NUMBER_ALPHABETIC_LOWERCASE) == 0 ) {
an = new autoNumberAlphabetic(
name, delta, autoNumberCased::LOWER, initvalue, prefix, postfix
);
} else
if ( strcasecmp(type, AUTO_NUMBER_ROMAN_UPPERCASE) == 0 )
an = new autoNumberRoman(
name, delta, autoNumberCased::UPPER, initvalue, prefix, postfix
);
else
if ( strcasecmp(type, AUTO_NUMBER_ROMAN_LOWERCASE) == 0 )
an = new autoNumberRoman(
name, delta, autoNumberCased::LOWER, initvalue, prefix, postfix
);
else {
MESSAGE(cerr, form("unknown type: %s", type));
cerr << form("Autonumber: unknown type %s.", type) << "\n";
throw(CASTHCREXCEPT hardCopyRendererException());
}
//////////////////////////
// log the new autonumber
//////////////////////////
CC_String *key = new CC_String(name);
if ( f_autoNumberSet.findValue(key) ) {
delete key;
delete an;
return;
} else
f_autoNumberSet.insertKeyAndValue(key, an);
///////////////////////////////
// log into reset control list
///////////////////////////////
const char* gi = 0;
autoNumberListT* anList = 0;
unsigned int i;
for (i=0; i<controlList -> length(); i++ ) {
gi = stringToCharPtr((*controlList)[i]);
key = new CC_String(gi);
anList = f_resetControlList.findValue(key);
if ( anList == 0 ) {
anList = new autoNumberListT();
f_resetControlList.insertKeyAndValue(key, anList);
} else
delete key;
anList -> append(an);
}
////////////////////////////////
// log into register list
////////////////////////////////
for (i=0; i<registerList -> length(); i++ ) {
gi = stringToCharPtr((*registerList)[i]);
key = new CC_String(gi);
anList = f_registerList.findValue(key);
if ( anList == 0 ) {
anList = new autoNumberListT();
f_registerList.insertKeyAndValue(key, anList);
} else
delete key;
anList -> append(an);
}
}
void autoNumberFP::setSeenTagStatus(const char* tagName)
{
CC_String key(tagName);
autoNumberListT* anList = f_registerList.findValue(&key);
if ( anList == 0 )
return;
autoNumberListIteratorT next(*anList);
while ( ++next ) {
next.key() -> setNumTagsSeen();
}
}
FeatureValue*
autoNumberFP::evaluate(const char* varName)
{
CC_String key(varName);
autoNumber* an = f_autoNumberSet.findValue(&key);
if ( an == 0 ) {
MESSAGE(cerr, form("Warning: unknown autonumber name %s.", varName));
return 0;
} else
return new FeatureValueString(an -> getValue());
}
unsigned int
autoNumberFP::accept(const char* name, const Expression* expr)
{
FeatureValue* fv = 0;
mtry
{
fv = expr -> evaluate();
}
mcatch_any()
{
return false;
}
end_try;
/*
debug(cerr, name);
fv -> print(cerr);
*/
if ( fv -> type() != FeatureValue::array ) {
delete fv;
return false;
}
FeatureValueArray* fvArray = (FeatureValueArray*) fv;
/*
debug(cerr, fvArray -> length());
debug(cerr, fvArray -> name());
*/
if ( fvArray -> length() >= 1 &&
strcasecmp(fvArray -> name(), AUTO_NUMBER) == 0
)
{
defineAutoNumber(name, fv);
delete fv;
return true;
} else {
delete fv;
return false;
}
}
void
autoNumberFP::beginElement(const Element& element)
{
const char* giname = element.gi().name();
if (giname && *giname)
{
pushAutoNumbers(giname);
setSeenTagStatus(giname);
updateAutoNumbers(giname);
}
#ifdef DEBUG
else
abort();
#endif
}
void
autoNumberFP::endElement(const Symbol& sym)
{
const char* giname = sym.name();
if (giname && *giname)
{
popAutoNumbers(giname);
}
#ifdef DEBUG
else
abort();
#endif
}
#if 0
void autoNumberFP::preEvaluate(const Element& element)
{
setSeenTagStatus(element.gi().name());
updateAutoNumbers(element.gi().name());
}
void autoNumberFP::postEvaluate(const Element& element)
{
resetAutoNumbers(element.gi().name());
}
#endif
void autoNumberFP::clear()
{
f_autoNumberSet.clearAndDestroy();
f_resetControlList.clearAndDestroy();
f_registerList.clearAndDestroy();
}
// reset All autonumbers
void autoNumberFP::resetAllAutoNumbers()
{
hashTableIterator<CC_String, autoNumberListT> l_rc_iterator(f_resetControlList);
while ( ++l_rc_iterator ) {
autoNumberListT* anList = l_rc_iterator.value();
autoNumberListIteratorT l_iter(*anList);
while ( ++l_iter ) {
l_iter.key() -> reset();
}
}
}

View File

@@ -1,102 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: autoNumberFP.h /main/7 1996/10/08 19:25:47 cde-hal $ */
#ifndef _autoNumber_fp_h
#define _autoNumber_fp_h 1
#ifndef CDE_NEXT
#else
#include "dti_cc/CC_String.h"
#include "dti_cc/cc_hdict.h"
#endif
#include "StyleSheet/SymTab.h"
#include "StyleSheet/Element.h"
#include "StyleSheet/FeatureValue.h"
#include "HardCopy/autoNumber.h"
#ifndef CDE_NEXT
typedef hashTable<CC_String, autoNumber> f_autoNumberSet_t ;
typedef hashTable<CC_String, autoNumberListT> f_resetControlList_t;
typedef hashTable<CC_String, autoNumberListT> f_registerList_t;
#else
typedef hashTable<CC_String, autoNumber> f_autoNumberSet_t ;
typedef hashTable<CC_String, autoNumberListT> f_resetControlList_t;
typedef hashTable<CC_String, autoNumberListT> f_registerList_t;
#endif
class autoNumberFP
{
private:
// autoNumber FPs that are known through their names
f_autoNumberSet_t f_autoNumberSet;
// Inverted reset control list.
// A reset control list records a list of tags that
// once are met, the autonumber the list is associated with
// will be reset to its initial value.
// Each <String, autoNumberList> pair in the dictionary has the
// meaning that when the tag with String GI is encounted in the doucument,
// all autonumber in the autoNumberList will reset.
f_resetControlList_t f_resetControlList;
// Each <String, autoNumberList> pair in the dictionary has the
// meaning that all autonumber in the autoNumberList are defined
// in the style sheet under tag with String GI.
f_registerList_t f_registerList;
private:
void pushAutoNumbers(const char *);
void popAutoNumbers (const char *);
void updateAutoNumbers(const char*);
void defineAutoNumber(const char*, const FeatureValue*);
void setSeenTagStatus(const char* tagName);
const char* stringToCharPtr(const FeatureValue* f);
public:
autoNumberFP();
~autoNumberFP();
FeatureValue* evaluate(const char* varName) ;
unsigned int accept(const char*, const Expression*);
void beginElement(const Element &);
void endElement (const Symbol &);
void clear();
void resetAllAutoNumbers();
};
extern autoNumberFP gAutoNumberFP;
#endif

View File

@@ -1,31 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: lout_limits.h /main/3 1996/06/11 17:04:59 cde-hal $ */
#ifndef _lout_limit_
#define _lout_limit_ 1
#define LOUT_MAX_CHARS_PER_LINE 2000
#endif

View File

@@ -1,235 +0,0 @@
XCOMM $TOG: Imakefile /main/18 1998/08/10 15:51:59 mgreess $
XCOMM ** WARNING **
XCOMM
XCOMM The files named here may appear in many different Imakefiles.
XCOMM If you add or remove a file, be sure to update all locations.
XCOMM It's unfortunate, but all this redundancy serves a purpose.
XCOMM
XCOMM Other possible locations are:
XCOMM .../lib/DtMmdb/Imakefile
XCOMM .../lib/DtMmdb/<subdir>/Imakefile
XCOMM .../programs/dtinfo/mmdb/Imakefile
XCOMM .../programs/dtinfo/mmdb/<subdir>/Imakefile
#define IHaveSubdirs
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)' 'CXXDEBUGFLAGS=$(CXXDEBUGFLAGS)'
XCOMM This directory has the source for both C and C++ versions of this
XCOMM library. Only the C version is built as libDtMmdb. Check in
XCOMM .../programs/dtinfo/mmdb also to find out if files are really
XCOMM obsolete.
MMDB_SUBDIRS = HardCopy StyleSheet dti_cc
#ifdef SharedDtMmdbReqs
#ifdef SunArchitecture
REQUIREDLIBS = SharedDtMmdbReqs
#ifndef HasGcc2
SHLIBLDFLAGS = -G
#endif
#else
REQUIREDLIBS = SharedDtMmdbReqs
#endif
#endif
SUBDIRS = \
api btree \
btree_berkeley compression \
diskhash dstr \
dti_excs dynhash \
hmphf index \
mgrs misc \
object oliasdb \
schema storage \
utility
DONES = \
api/DONE btree/DONE \
btree_berkeley/DONE compression/DONE \
diskhash/DONE dstr/DONE \
dti_excs/DONE dynhash/DONE \
hmphf/DONE index/DONE \
mgrs/DONE misc/DONE \
object/DONE oliasdb/DONE \
schema/DONE storage/DONE \
utility/DONE
EXTRALIBRARYDEPS = $(DONES)
XCOMM redefine TopLevelProject to build DtInfo with standard CDE config dir
#undef TopLevelProject
#define TopLevelProject DtInfo
IMAKE_DEF_DTINFO = -DTopLevelProject=TopLevelProject \
-DProjectTmplFile='<DtInfo.tmpl>' \
-DProjectRulesFile='<DtInfo.rules>'
MakeSubdirs($(SUBDIRS))
ForceSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
NamedTargetSubdirs(install_buildtools,$(SUBDIRS),\
install_buildtools,,install_buildtools)
#define DoNormalLib NormalLibDtMmdb
#define DoSharedLib SharedLibDtMmdb
#define DoDebugLib DebugLibDtMmdb
#define DoProfileLib ProfileLibDtMmdb
#define LibName DtMmdb
#define SoRev SODTMMDBREV
#define LibHeaders NO
#define LargePICTable YES
#define CplusplusSource YES
/*
* N.B.: All .o's should be built in the subdirectories.
*/
API_OBJS = \
api/base.o api/info_base.o api/info_lib.o \
api/smart_ptr.o api/transaction.o api/utility.o
BTREE_OBJS = btree/mmdb_btree.o
#if !defined(AIXArchitecture)
EXTRA_BTREE_BERKELEY_OBJS = btree_berkeley/memmove.o
#endif
BTREE_BERKELEY_OBJS = \
btree_berkeley/bt_close.o btree_berkeley/bt_conv.o \
btree_berkeley/bt_debug.o btree_berkeley/bt_delete.o \
btree_berkeley/bt_get.o btree_berkeley/bt_open.o \
btree_berkeley/bt_overflow.o btree_berkeley/bt_page.o \
btree_berkeley/bt_put.o btree_berkeley/bt_search.o \
btree_berkeley/bt_seq.o btree_berkeley/bt_split.o \
btree_berkeley/bt_stack.o btree_berkeley/bt_utils.o \
btree_berkeley/mktemp.o btree_berkeley/realloc.o \
btree_berkeley/snprintf.o $(EXTRA_BTREE_BERKELEY_OBJS) \
btree_berkeley/mpool.o btree_berkeley/db.o
COMPRESSION_OBJS = \
compression/abs_agent.o compression/zip.o \
compression/huffman.o compression/trie.o \
compression/code.o compression/lzss.o \
compression/sgml.o compression/ps.o
DISKHASH_OBJS = \
diskhash/disk_bucket.o diskhash/bucket_array.o \
diskhash/disk_hash.o
DSTR_OBJS = \
dstr/set.o dstr/bset.o \
dstr/slist.o dstr/dlist_cell.o \
dstr/dlist.o dstr/heap.o \
dstr/void_ptr_array.o dstr/void_ptr_stack.o \
dstr/memory_pool.o dstr/dstr_test.o \
dstr/index_agent.o dstr/token_stack.o \
dstr/slist_char_ptr_cell.o
DTI_EXCS_OBJS = \
dti_excs/Jump_Environment.o dti_excs/Exceptions.o \
dti_excs/Exception.o dti_excs/Destructable.o \
dti_excs/terminate.o dti_excs/init.o
DYNHASH_OBJS = dynhash/data_t.o dynhash/imp_bucket.o dynhash/imp_die.o
HMPHF_OBJS = \
hmphf/buckets.o hmphf/mphf_funcs.o hmphf/mphf_hash_table.o \
hmphf/params.o hmphf/pattern.o hmphf/sorter.o
INDEX_OBJS = \
index/btree_index.o index/dyn_disk_index.o \
index/dyn_index.o index/dyn_memory_index.o \
index/fast_mphf.o index/hash.o \
index/index.o index/inv_lists.o \
index/mphf_index.o
MGRS_OBJS = mgrs/managers.o mgrs/misc.o mgrs/query_mgr.o mgrs/template_mgr.o
MISC_OBJS = misc/unique_id.o
OBJECT_OBJS = \
object/composite.o object/compressed_pstring.o \
object/cset.o object/dl_list.o \
object/dl_list_cell.o object/handler.o \
object/integer.o object/long_pstring.o \
object/oid.o object/oid_list.o \
object/oid_t.o object/primitive.o \
object/pstring.o object/random_gen.o \
object/root.o object/short_list.o \
object/tuple.o
OLIASDB_OBJS = \
oliasdb/asciiIn_filters.o oliasdb/collectionIterator.o \
oliasdb/dlp_hd.o oliasdb/dlp_test.o \
oliasdb/doc_hd.o oliasdb/doc_test.o \
oliasdb/graphic_hd.o oliasdb/graphic_test.o \
oliasdb/loc_test.o oliasdb/locator_hd.o \
oliasdb/mark.o oliasdb/mark_base.o \
oliasdb/mark_test.o oliasdb/mmdb.o \
oliasdb/node_hd.o oliasdb/node_test.o \
oliasdb/olias_funcs.o oliasdb/olias_test.o \
oliasdb/stylesheet_hd.o oliasdb/stylesheet_test.o \
oliasdb/toc_hd.o oliasdb/toc_test.o \
oliasdb/user_base.o \
oliasdb/c_api_book.o oliasdb/c_api_book_test.o \
oliasdb/c_api_bookcase.o oliasdb/c_api_bookcase_test.o \
oliasdb/c_api_common.o \
oliasdb/c_api_dlp.o oliasdb/c_api_dlp_test.o \
oliasdb/c_api_graphic.o oliasdb/c_api_graphic_test.o \
oliasdb/c_api_infolib.o oliasdb/c_api_infolib_test.o \
oliasdb/c_api_locator.o oliasdb/c_api_locator_test.o \
oliasdb/c_api_pure_virtual.o \
oliasdb/c_api_section.o oliasdb/c_api_section_test.o \
oliasdb/c_api_stylesheet.o oliasdb/c_api_stylesheet_test.o \
oliasdb/c_api_toc.o oliasdb/c_api_toc_test.o
SCHEMA_OBJS = \
schema/desc.o schema/store_desc.o \
schema/object_dict.o schema/stored_object_desc.o \
schema/index_desc.o schema/inv_desc.o \
schema/agent_desc.o schema/container_desc.o \
schema/sheet.o schema/token.o
STORAGE_OBJS = \
storage/abs_storage.o storage/chunks_index.o \
storage/heap_comp_funcs.o storage/lru.o \
storage/page.o storage/page_cache.o \
storage/page_rep.o storage/page_storage.o \
storage/rep_cell.o storage/rep_policy.o \
storage/store_test.o storage/unixf_storage.o \
storage/version.o storage/vm_storage.o
UTILITY_OBJS = \
utility/funcs.o utility/ostring.o \
utility/pm_random.o utility/atoi_pearson.o \
utility/xtime.o utility/buffer.o \
utility/atoi_larson.o utility/atomic_lock.o \
utility/rw_lock.o utility/atoi_fast.o \
utility/filter.o utility/mmdb_exception.o \
utility/randomize.o \
utility/streambuf.o utility/charbuf.o utility/filebuf.o \
utility/stringstream.o utility/iostream.o utility/fstream.o \
utility/stream.o utility/string.o utility/ios.o
OBJS = $(API_OBJS) $(BTREE_OBJS) \
$(BTREE_BERKELEY_OBJS) $(COMPRESSION_OBJS) \
$(DISKHASH_OBJS) $(DSTR_OBJS) \
$(DTI_EXCS_OBJS) $(DYNHASH_OBJS) \
$(HMPHF_OBJS) $(INDEX_OBJS) \
$(MGRS_OBJS) $(MISC_OBJS) \
$(OBJECT_OBJS) $(OLIASDB_OBJS) \
$(SCHEMA_OBJS) $(STORAGE_OBJS) \
$(UTILITY_OBJS)
XCOMM All dependent libraries are shared, no need to tell the linker twice.
STATIC =
DYNAMIC =
#include <Library.tmpl>
XCOMM Variables to switch on debug mode temporarily
XCOMM CDEBUGFLAGS = -g -DDEBUG
XCOMM CXXDEBUGFLAGS = -g -DDEBUG

View File

@@ -1,49 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = HardCopy \
StyleSheet \
api \
btree \
btree_berkeley \
compression \
diskhash \
dstr \
dti_cc \
dti_excs \
dynhash \
hmphf \
index \
mgrs \
misc \
object \
oliasdb \
schema \
storage \
utility
lib_LTLIBRARIES = libDtMmdb.la
libDtMmdb_la_SOURCES =
libDtMmdb_la_LIBADD = HardCopy/libHardCopy.la \
StyleSheet/libStyleSheet.la \
api/libapi.la \
btree/libbtree.la \
btree_berkeley/libbtree_berkeley.la \
compression/libcompression.la \
diskhash/libdiskhash.la \
dstr/libdstr.la \
dti_cc/libdti_cc.la \
dti_excs/libdti_excs.la \
dynhash/libdynhash.la \
hmphf/libhmphf.la \
index/libindex.la \
mgrs/libmgrs.la \
misc/libmisc.la \
object/libobject.la \
oliasdb/liboliasdb.la \
schema/libschema.la \
storage/libstorage.la \
utility/libutility.la
libDtMmdb_la_LDFLAGS = -version-info 2:1:0

View File

@@ -1,59 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: Attribute.cc /main/4 1996/06/11 17:05:20 cde-hal $
#include "Attribute.h"
// /////////////////////////////////////////////////////////////////////////
// Attribute
// /////////////////////////////////////////////////////////////////////////
Attribute::Attribute(const Symbol &name, char *value)
: f_name(name),
f_value(value)
{
}
Attribute::~Attribute()
{
delete f_value ;
}
bool
Attribute::operator==(const Attribute &attr) const
{
/*
cerr << "Attribute::operator==\n";
cerr << f_name << "\n";
cerr << attr.f_name << "\n";
cerr << "<" << f_name.name() << ">\n";
cerr << "<" << attr.f_name.name() << ">\n";
cerr << attr.name().operator==(f_name) << "\n";
*/
return f_name == attr.name();
}
ostream &
Attribute::print(ostream &o) const
{
return o << f_name << '=' << f_value ;
}

View File

@@ -1,60 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: Attribute.h /main/3 1996/06/11 17:05:27 cde-hal $ */
#ifndef _Attribute_h
#define _Attribute_h
#include "SymTab.h"
/* **************************************************************
class Attribute
a name/value pairing
************************************************************** */
class Attribute
{
public:
Attribute(const Symbol &name, char *value = 0);
~Attribute();
const Symbol &name() const { return f_name; }
bool operator==(const Attribute &) const ;
const char *value() const { return f_value ; }
ostream &print(ostream &) const;
private:
Symbol f_name;
char *f_value ;
};
inline
ostream &operator<<(ostream &o, const Attribute &a)
{
return a.print(o);
}
#endif /* _Attribute_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,64 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: AttributeList.cc /main/4 1996/06/11 17:05:32 cde-hal $
#include "AttributeList.h"
// /////////////////////////////////////////////////////////////////////////
// AttributeList
// /////////////////////////////////////////////////////////////////////////
AttributeList::AttributeList()
: CC_TPtrSlist<Attribute> ()
{
}
AttributeList::~AttributeList()
{
clearAndDestroy();
}
const Attribute*
AttributeList::lookup(const Symbol &name) const
{
Attribute attr(name);
return find(&attr);
}
void
AttributeList::add(Attribute *attr)
{
append(attr);
}
ostream &
AttributeList::print(ostream &o) const
{
CC_TPtrSlistIterator<Attribute> next(*(CC_TPtrSlist<Attribute>*)this);
while (++next)
o << ' ' << *next.key() ;
return o;
}

View File

@@ -1,58 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: AttributeList.h /main/3 1996/06/11 17:05:38 cde-hal $ */
#ifndef _AttributeList_h
#define _AttributeList_h
#include "Element.h"
#include "Attribute.h"
/* **************************************************************
class AttributeList
A linked list of Attributes
************************************************************** */
class AttributeList : private CC_TPtrSlist<Attribute>
{
public:
AttributeList();
virtual ~AttributeList();
void add(Attribute *);
const Attribute *lookup(const Symbol &name) const;
ostream &print(ostream &) const ;
};
inline
ostream &operator<<(ostream &o, const AttributeList &attrlist)
{
return attrlist.print(o);
}
#endif /* _AttributeList_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,196 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $TOG: BitVector.C /main/4 1998/04/17 11:47:51 mgreess $
#include "BitVector.h"
#include "Debug.h"
#include "StyleSheetExceptions.h"
#define wordWithMSBSet (0x1 << (WORD_SIZE-1))
#define BIT_TEST(x, y) ( ((x) & (y)) == (y) )
#define RESET_BIT(x, y) x &= (~(y))
#define SET_BIT(x, y) x |= (y)
unsigned int posRecord::operator ==(const posRecord&)
{
MESSAGE(cerr, "posRecord::operator ==() should not be called");
throw(CASTBEEXCEPT badEvaluationException());
return 0;
}
BitVector::BitVector(int bits, unsigned int initValue) :
f_bits(bits), f_words(bits/WORD_SIZE+1), f_positionArray(0)
{
f_array = new unsigned int[f_words];
setAllBitsTo(initValue);
}
void BitVector::setAllBitsTo(unsigned int initValue)
{
unsigned int fill = ( initValue == 0 ) ? 0x0 : ~0x0;
for ( unsigned int i=0; i<f_words; i++ )
f_array[i]=fill;
}
BitVector::~BitVector()
{
delete [] f_array;
delete f_positionArray;
}
void BitVector::setTo(BitVector& v)
{
if ( f_words != v.f_words ) {
delete [] f_array;
f_array = new unsigned int[v.f_words];
}
f_bits = v.f_bits;
f_words = v.f_words;
for ( unsigned int i=0; i<f_words; i++ )
f_array[i]=v.f_array[i];
}
void BitVector::setBitTo(int i, unsigned int x)
{
unsigned int wordIndex = i / WORD_SIZE;
unsigned int bitIndex = i % WORD_SIZE;
if ( x == 1 ) {
if ( wordIndex < f_words - 1 )
SET_BIT(f_array[wordIndex], (0x1 << bitIndex));
else
SET_BIT(f_array[wordIndex],
(0x1 << (WORD_SIZE - f_bits % WORD_SIZE + bitIndex))
);
} else {
if ( wordIndex < f_words - 1 )
RESET_BIT(f_array[wordIndex], (0x1 << bitIndex));
else
RESET_BIT(f_array[wordIndex],
(0x1 << (WORD_SIZE - f_bits % WORD_SIZE + bitIndex))
);
}
}
void BitVector::recordPositions(unsigned int PTPos, unsigned int BITPos)
{
if ( f_positionArray == 0 )
f_positionArray = new positionArrayT;
f_positionArray -> append(posRecord(PTPos, BITPos));
}
unsigned int BitVector::getBit(int i)
{
unsigned int wordIndex = i / WORD_SIZE;
unsigned int bitIndex = i % WORD_SIZE;
if ( wordIndex < f_words - 1 )
return BIT_TEST((int)f_array[wordIndex], (0x1 << bitIndex)) ? 1 : 0;
else
return BIT_TEST((int)f_array[wordIndex],
(0x1 << (WORD_SIZE - f_bits % WORD_SIZE + bitIndex))
) ? 1 : 0;
}
BitVector& BitVector::operator &=(BitVector& b)
{
for ( unsigned int i=0; i<f_words; i++ )
f_array[i] &= b.f_array[i];
return *this;
}
BitVector& BitVector::operator ^=(BitVector& b)
{
for ( unsigned int i=0; i<f_words; i++ )
f_array[i] ^= b.f_array[i];
return *this;
}
BitVector& BitVector::operator |=(BitVector& b)
{
for ( unsigned int i=0; i<f_words; i++ )
f_array[i] |= b.f_array[i];
return *this;
}
BitVector& BitVector::shiftRightOneBit()
{
unsigned int msb = 0;
unsigned int lsb = 0;
for ( unsigned int i=0; i<f_words; i++ ) {
lsb = ( BIT_TEST(f_array[i], 0x1) ) ? 0x1 : 0x0;
f_array[i] = f_array[i] >> 1;
f_array[i] |= msb;
msb = lsb;
}
SET_BIT(f_array[0], wordWithMSBSet);
return *this;
}
BitVector& BitVector::shiftLeftOneBit()
{
unsigned int msb = 0;
unsigned int lsb = 0;
for ( int i=f_words-1; i>=0; i++ ) {
msb = (BIT_TEST((int)f_array[i], wordWithMSBSet)) ? wordWithMSBSet : 0x0;
f_array[i] = f_array[i] << 1;
f_array[i] |= lsb;
lsb = msb;
}
return *this;
}
ostream& operator<<(ostream& out, BitVector& bv)
{
for ( int i=bv.f_bits-1; i>=0; i-- ) {
out << bv.getBit(i) ;
}
out << "\n";
posRecord x;
if ( bv.f_positionArray ) {
positionArrayIteratorT l_positionNext(*bv.f_positionArray);
while (++l_positionNext) {
x = l_positionNext.key();
out << x.pathTermPos << "." << x.bitPos << " ";
}
}
out << "\n";
return out;
}

View File

@@ -1,96 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: BitVector.h /main/4 1996/08/21 15:49:59 drk $ */
#ifndef _BitVector_h
#define _BitVector_h 1
#include <sstream>
#include <ostream>
using namespace std;
#ifndef CDE_NEXT
#else
//#include <StyleSheet/cde_next.h>
#include "dti_cc/CC_Slist.h"
#endif
#define WORD_SIZE 32
class posRecord
{
public:
posRecord(unsigned int x = 0, unsigned int y = 0) :
pathTermPos(x), bitPos(y) {};
~posRecord() {};
unsigned int operator ==(const posRecord&);
public:
unsigned int pathTermPos;
unsigned int bitPos;
};
typedef CC_TValSlist<posRecord> positionArrayT;
typedef CC_TValSlistIterator<posRecord> positionArrayIteratorT;
///////////////////////////////////////////////////////
// A storage/manipulation efficient bit vector class
///////////////////////////////////////////////////////
class BitVector
{
unsigned int *f_array;
unsigned int f_bits;
unsigned int f_words;
positionArrayT *f_positionArray;
public:
BitVector(int bits, unsigned int initValue);
~BitVector();
//
// bits range: 0 .. bits-1
// the 0th bit is LSB, the (bits-1)th bit is MSB
//
void setAllBitsTo(unsigned int);
void setTo(BitVector&);
void recordPositions(unsigned int pathTermPos, unsigned int BitPos);
positionArrayT* positionArray() { return f_positionArray; };
void setBitTo(int i, unsigned int);
unsigned int getBit(int i);
BitVector& operator &=(BitVector&);
BitVector& operator ^=(BitVector&);
BitVector& operator |=(BitVector&);
// Note: the MSB is set to 1 after each shiftRightOneBit() call.
BitVector& shiftRightOneBit();
BitVector& shiftLeftOneBit();
friend ostream& operator<<(ostream&, BitVector&);
};
#endif

View File

@@ -1,156 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
#ifndef _name_consts_h
#define _name_consts_h 1
#define BREAK "BREAK"
#define LINE_BREAK "LINE"
#define COLUMN_BREAK "COLUMN"
#define PAGE_BREAK "PAGE"
#define LINE_AFTER_BREAK "LINEAFTER"
#define COLUMN_AFTER_BREAK "COLUMNAFTER"
#define PAGE_AFTER_BREAK "PAGEAFTER"
#define FONT "FONT"
#define FONT_FAMILY "FAMILY"
#define FONT_WEIGHT "WEIGHT"
#define FONT_SLANT "SLANT"
#define FONT_SIZE "SIZE"
#define FONT_XLFD "XLFD"
#define FONT_SUBSCRIPT "SUBSCRIPT"
#define FONT_SUPERSCRIPT "SUPERSCRIPT"
#define FONT_WEIGHT_MEDIUM "MEDIUM"
#define FONT_WEIGHT_BOLD "BOLD"
#define FONT_SLANT_ROMAN "ROMAN"
#define FONT_SLANT_ITALIC "ITALIC"
#define FONT_FAMILY_HELVETICA "HELVETICA"
#define FOOTNOTES "FOOTNOTE"
#define PARA "PARA"
#define COLUMNS "COLUMNS"
#define ONE_COLUMN "ONE"
#define TWO_COLUMN "TWO"
#define LEADING "LEADING"
#define GRAPHIC "GRAPHIC"
#define GRAPHIC_TYPE "GRTYPE"
#define GRAPHIC_ALIGN "ALIGN"
#define GRAPHIC_ALIGN_MIDDLE "INLINE"
#define GRAPHIC_ALIGN_BLOCK "BLOCK"
#define GRAPHIC_ALIGN_TOP "TOP"
#define GRAPHIC_ALIGN_BOTTOM "BOTTOM"
#define HEADERS "HEADER"
#define FOOTERS "FOOTER"
#define HEADER "CONTENT"
#define FOOTER "CONTENT"
#define HIGHLIGHT "HIGHLIGHT"
#define HIGHLIGHT_BOXED "BOXED"
#define HIGHLIGHT_STRIKE "STRIKE-THROUGH"
#define HIGHLIGHT_OVERLINE "OVERLINE"
#define HIGHLIGHT_UNDERLINE "UNDERLINE"
#define INDENT "INDENT"
#define IGNORE "IGNORE"
#define LAYOUT "LAYOUT"
#define LAYOUT_WIDTH "WIDTH"
#define LAYOUT_HEIGHT "HEIGHT"
#define LAYOUT_LEFT "LEFT"
#define LAYOUT_RIGHT "RIGHT"
#define LAYOUT_TOP "TOP"
#define LAYOUT_BOTTOM "BOTTOM"
#define LAYOUT_CENTERED "CENTERED"
#define LINE_WRAPPING "WRAP"
#define WRAP_CHAR "CHAR"
#define WRAP_WORD "WORD"
#define WRAP_NONE "NONE"
#define WRAP_HYPHENATION "HYPHENATION"
#define LOCATOR "LOCATOR"
#define MARGIN "MARGIN"
#define MARGIN_LEFT "LEFT"
#define MARGIN_RIGHT "RIGHT"
#define MARGIN_TOP "TOP"
#define MARGIN_BOTTOM "BOTTOM"
#define MEDIA "MEDIUM"
#define MEDIA_SIZE "SIZE"
#define MEDIA_SIZE_USLETTER "LETTER"
#define MEDIA_SIZE_USLEGAL "LEGAL"
#define MEDIA_SIZE_TABLOID "TABLOID"
#define MEDIA_SIZE_LEDGER "LEDGER"
#define MEDIA_SIZE_STATEMENT "STATEMENT"
#define MEDIA_SIZE_Executive "EXECUTIVE"
#define MEDIA_SIZE_A3 "A3"
#define MEDIA_SIZE_A4 "A4"
#define MEDIA_SIZE_A5 "A5"
#define MEDIA_SIZE_B4 "B4"
#define MEDIA_SIZE_B5 "B5"
#define MEDIA_SIZE_FOLIO "FOLIO"
#define MEDIA_SIZE_QUARTO "QUARTO"
#define MEDIA_ORIENTATION "ORIENTATION"
#define MEDIA_ORIENTATION_PORTRAIT "PORTRAIT"
#define MEDIA_ORIENTATION_LANDSCAPE "LANDSCAPE"
#define PREFIX "PREFIX"
#define PREFIX_CONTENT "CONTENT"
#define PREFIX_POSITION "POSITION"
#define POSTFIX "SUFFIX"
#define POSTFIX "SUFFIX"
#define POSTFIX_CONTENT "CONTENT"
#define POSTFIX_POSITION "POSITION"
#define QUADDING "QUADDING"
#define QUADDING_ASIS "ASIS"
#define QUADDING_LEFT "LEFT"
#define QUADDING_RIGHT "RIGHT"
#define QUADDING_FULL "FULL"
#define QUADDING_CENTERED "CENTERED"
#define TAB "TAB"
#define AUTO_NUMBER "AUTONUMBER"
#define AUTO_NUMBER_NUMERIC "ARABIC"
#define AUTO_NUMBER_ALPHABETIC_UPPERCASE "UCALPHA"
#define AUTO_NUMBER_ALPHABETIC_LOWERCASE "LCALPHA"
#define AUTO_NUMBER_ROMAN_UPPERCASE "UCROMAN"
#define AUTO_NUMBER_ROMAN_LOWERCASE "LCROMAN"
#endif

View File

@@ -1,73 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: Debug.h /main/3 1996/06/11 17:06:00 cde-hal $
*
* Copyright (c) 1992 HaL Computer Systems, Inc. All rights reserved.
* UNPUBLISHED -- rights reserved under the Copyright Laws of the United
* States. Use of a copyright notice is precautionary only and does not
* imply publication or disclosure.
*
* This software contains confidential information and trade secrets of HaL
* Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
* without the prior express written permission of HaL Computer Systems, Inc.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject to
* restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
* Technical Data and Computer Software clause at DFARS 252.227-7013.
* HaL Computer Systems, Inc.
* 1315 Dell Avenue, Campbell, CA 95008
*
*/
#ifndef _debug_h
#define _debug_h 1
#include <iostream>
using namespace std;
#ifdef DEBUG
#define ON_DEBUG(stmt) stmt
#else
#define ON_DEBUG(stmt)
#endif
#ifdef DEBUG
#if !defined ( __STDC__) && !defined (hpux)
#define debug(s, x) s << "x" << " = " << (x) << "\n"
#else
#define debug(s, x) s << #x << " = " << (x) << "\n"
#endif
#define MESSAGE(s, x) s << x << "\n"
#else
#define debug(s,x)
#define MESSAGE(s,x)
#endif
#endif

View File

@@ -1,675 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* Copyright (c) 1995 FUJITSU LIMITED */
/* All Rights Reserved */
/* $TOG: DocParser.C /main/16 1998/04/17 11:48:07 mgreess $ */
#ifdef DEBUG
#include "assert.h"
#endif
#include "Debug.h"
#include "StyleSheetExceptions.h"
#include "DocParser.h"
#include "Resolver.h"
#include "Element.h"
#include "AttributeList.h"
#define DATA_BUF_SIZ 4096
#if defined(SC3)
static ostrstream& terminate(ostrstream& ost)
{
char* pstring = ost.str();
*(pstring + ost.pcount()) = '\0';
return ost;
}
#endif
DocParser::DocParser(Resolver &r)
: f_ignoring_element(0), f_resolver(r),
#if defined(SC3)
f_buffer(new char[DATA_BUF_SIZ]),
f_output(f_buffer, DATA_BUF_SIZ)
#else
f_streambuf(new stringbuf()),
f_output()
#endif
{
}
DocParser::~DocParser()
{
#if defined(SC3)
if (f_buffer) delete[] f_buffer;
#else
// this causes a free memory read when f_output is deleted as part of this
// object...nothing we can do about it
delete f_streambuf ;
#endif
}
unsigned int
DocParser::parse(istream &input)
{
f_resolver.Begin();
unsigned int ok = rawParse(input);
f_resolver.End();
return ok;
}
unsigned int
DocParser::rawParse(istream &input)
{
string data;
input.unsetf(ios::skipws);
f_ignoring_element = 0 ;
switch(read_tag(input, f_output))
{
case StartTag:
{
#if defined(SC3)
Symbol name(gElemSymTab->intern(terminate(f_output).str()));
f_output.rdbuf()->freeze(0);
#else
data = f_output.str().c_str();
/*
MESSAGE(cerr, "StartTag case:");
debug(cerr, f_output.str().size());
debug(cerr, data.c_str());
*/
Symbol name(gElemSymTab->intern(data.c_str()));
#endif
process(input, f_output, name, 1, 1);
}
break;
case EndTag:
case AttributeSection:
case OliasAttribute:
throw(CASTDPUTEXCEPT docParserUnexpectedTag());
break;
case NoTag:
throw(CASTDPUDEXCEPT docParserUnexpectedData());
break;
}
return 1;
}
void
update_last_seen_child_name(Symbol*& last_seen_child_name, unsigned int& child_relative_sibling_number, const Symbol& new_child_name)
{
if ( last_seen_child_name == 0 ||
!(*last_seen_child_name == Symbol(new_child_name))
)
{
delete last_seen_child_name ;
last_seen_child_name = new Symbol(new_child_name);
child_relative_sibling_number= 1;
} else
child_relative_sibling_number++;
return;
}
void
DocParser::process(istream &input, ostringstream &output,
const Symbol &name,
unsigned int sibling_number, unsigned int this_sibling_number)
{
ON_DEBUG(cerr << "process(" << name << ") -> " << sibling_number << endl);
Symbol* last_seen_child_name = 0;
unsigned int child_relative_sibling_number = 0;
unsigned int child = 1 ; // sibling numbers for child elements
#if !defined(SC3)
string pstring;
#endif
string data;
char c ;
while ((input >> c) && (c == '\n'));
input.putback(c);
if (input.eof())
throw(CASTDPUEEXCEPT docParserUnexpectedEof());
int ignore = 0 ;
mtry
{
// process whatever comes right after start tag
TagType tt = read_tag(input, output);
switch (tt)
{
case StartTag:
{
ON_DEBUG(cerr << "beginElement" << endl);
// have to begin this element before processing child elements
if (!f_ignoring_element)
{
ignore = f_resolver.beginElement(new Element(name,
sibling_number, 0,
0,
this_sibling_number));
f_ignoring_element = ignore ;
}
/////////////////////////////
// first child of this node
/////////////////////////////
#if defined(SC3)
Symbol name(gElemSymTab->intern(terminate(f_output).str()));
update_last_seen_child_name(last_seen_child_name,
child_relative_sibling_number, name);
f_output.rdbuf()->freeze(0);
process(input, output, name, child++, child_relative_sibling_number);
#else
data = f_output.str().c_str();
//#if !defined(SC3)
// data[f_output.str().size()] = '\0';
//#endif
Symbol name(gElemSymTab->intern(data.c_str()));
update_last_seen_child_name(last_seen_child_name,
child_relative_sibling_number, name);
process(input, output, name,
child++, child_relative_sibling_number);
#endif
}
break;
case EndTag:
// hit an end tag right after start tag
#ifdef DEBUG
{
#if defined(SC3)
data = terminate(f_output).str();
f_output.rdbuf()->freeze(0);
#else
data = f_output.str().c_str();
//#ifdef _IBMR2
//#if !defined(SC3)
// data[f_output.str().size()] = '\0';
//#endif
#endif
cerr << "EndTag: " << data.c_str() << endl;
assert(gElemSymTab->intern(data.c_str()) == name);
}
#endif
// this node
if (!f_ignoring_element)
{
int ignore = f_resolver.beginElement(new Element(name,
sibling_number,
0, 0, this_sibling_number));
if (!ignore)
f_resolver.endElement(name);
}
return ; // EXIT FUNCTION
break;
case AttributeSection:
{
#if !defined(SC3) && !defined(_IBMR2) && !defined(__linux__) && \
!defined(CSRG_BASED) && !defined(sun)
volatile
#endif
AttributeList *attrs = 0;
#if !defined(SC3) && !defined(_IBMR2) && !defined(__linux__) && \
!defined(CSRG_BASED) && !defined(sun)
volatile
#endif
AttributeList *olias_attrs = 0;
mtry
{
process_attributes(input, output, attrs, olias_attrs);
if (!f_ignoring_element)
{
//////////////////////////////
// this node with attributes
//////////////////////////////
ignore = f_resolver.beginElement(new Element(name,
sibling_number,
attrs,
olias_attrs,
this_sibling_number
));
f_ignoring_element = ignore ;
}
}
mcatch_any()
{
/*
delete attrs ;
delete olias_attrs ;
*/
attrs = 0 ;
olias_attrs = 0 ;
}
end_try;
}
break;
case OliasAttribute:
throw(CASTDPUTEXCEPT docParserUnexpectedTag());
break;
case NoTag:
{
if (!f_ignoring_element)
{
// this node
ignore = f_resolver.beginElement(new Element(name,
sibling_number,
0, 0, this_sibling_number));
f_ignoring_element = ignore ;
}
// process data
read_data(input, output);
if (!f_ignoring_element)
{
// the str() call seems to add the null byte to the stream
// and increment the pcount, so we must make sure it gets
// called first
#if defined(SC3)
char *pstring = terminate(f_output).str();
int size = f_output.pcount();
f_resolver.data(pstring, size);
f_output.rdbuf()->freeze(0);
#else
pstring = f_output.str().c_str();
int size = pstring.size() + 1;
f_resolver.data(pstring.c_str(), size);
#endif
}
}
break;
}
while ((tt = read_tag(input, output)) != EndTag)
switch (tt)
{
case StartTag:
{
/////////////////////////////
// second child and beyond.
/////////////////////////////
data = f_output.str().c_str();
#if defined(SC3)
f_output.rdbuf()->freeze(0);
#endif
/*
MESSAGE(cerr, "StartTag case2");
debug(cerr, data);
debug(cerr, f_output.str().size());
*/
Symbol name(gElemSymTab->intern(data.c_str()));
update_last_seen_child_name(last_seen_child_name,
child_relative_sibling_number, name);
process(input, output, name, child++, child_relative_sibling_number);
}
break;
case EndTag: // should never get this
break;
// we have already processed these for this tag
case AttributeSection:
case OliasAttribute:
throw(CASTDPUTEXCEPT docParserUnexpectedTag());
break;
case NoTag:
{
read_data(input, output);
if (!f_ignoring_element)
{
// the str() call seems to add the null byte to the stream
// and increment the pcount, so we must make sure it gets
// called first
#if defined(SC3)
char *pstring = f_output.str();
int size = f_output.pcount();
*(pstring + size) = 0;
f_resolver.data(pstring, size);
f_output.rdbuf()->freeze(0);
#else
pstring = f_output.str().c_str();
int size = pstring.size() + 1;
f_resolver.data(pstring.c_str(), size);
#endif
}
}
}
#ifdef DEBUG
{
#if defined(SC3)
data = terminate(f_output).str();
f_output.rdbuf()->freeze(0);
#else
data = f_output.str().c_str();
#endif
cerr << "EndTag: " << data.c_str() << endl;
assert(gElemSymTab->intern(data.c_str()) == name);
}
#endif
// hit end tag, end processing
if (!f_ignoring_element)
f_resolver.endElement(name);
// if we set ignore flag, unset it
if (ignore)
f_ignoring_element = 0;
}
mcatch_any()
{
rethrow;
}
end_try;
ON_DEBUG(cerr << "exit process: " << name << endl);
delete last_seen_child_name;
}
void
DocParser::process_attributes(istream &input, ostringstream &output,
AttributeList *&attrs,
AttributeList *&olias_attrs)
{
#if !defined(SC3)
string theData;
#endif
TagType tt ;
Attribute* newAttribute = 0;
AttributeList* orig_attrs = attrs;
AttributeList* orig_olias_attrs = olias_attrs;
mtry {
while ((tt = read_tag(input,output)) != NoTag)
{
switch (tt)
{
case StartTag:
{
#if !defined(SC3)
theData = f_output.str().c_str();
#endif
if (!attrs)
attrs = new AttributeList ;
newAttribute =
process_attribute(input, output,
#if defined(SC3)
gSymTab->intern(terminate(f_output).str()),
gSymTab->intern(f_streambuf->str()),
#else
gSymTab->intern(theData.c_str()),
#endif
StartTag
);
attrs->add(newAttribute);
break;
}
case EndTag:
return ; // EXIT FUNCTION
case AttributeSection:
throw(CASTDPUTEXCEPT docParserUnexpectedTag());
break;
case OliasAttribute:
#if !defined(SC3)
theData = f_output.str().c_str();
#endif
// mirrors attribute
if (!olias_attrs)
olias_attrs = new AttributeList ;
newAttribute =
process_attribute(input, output,
#if defined(SC3)
gSymTab->intern(terminate(f_output).str()),
gSymTab->intern(f_streambuf->str()),
#else
gSymTab->intern(theData.c_str()),
#endif
OliasAttribute
);
olias_attrs->add(newAttribute);
break;
case NoTag:
throw(CASTDPUDEXCEPT docParserUnexpectedData());
break;
}
}
}
mcatch_any()
{
delete newAttribute;
if ( orig_attrs == 0 ) {
delete attrs;
attrs = 0;
}
if ( orig_olias_attrs == 0 ) {
delete olias_attrs;
olias_attrs = 0;
}
rethrow;
}
end_try;
}
Attribute *
DocParser::process_attribute(istream &input, ostringstream &output,
const Symbol &name, TagType tt)
{
string data;
//ON_DEBUG(cerr << "process_attribute: " << name << endl);
// If the attribute is OLIAS internal, we use DocParser's
// read_data(). This is to prevent the attribte value
// from change in a call to specific renderer engine's
// read_data().
//
// Example: LoutDocparser::read_data() quotes any '.' char
// which changes the graphic locator value if the element
// is OLIAS internal attribute #GRAPHIC.
if ( tt == OliasAttribute ) {
DocParser::read_data(input, output);
} else
(void)read_data(input, output);
#if defined(SC3)
char *data = f_output.str();
*(data + f_output.pcount()) = 0;
f_output.rdbuf()->freeze(0);
Attribute *attr = new Attribute(name, strdup(data));
#else
data = f_output.str().c_str();
Attribute *attr = new Attribute(name, strdup(data.c_str()));
#endif
switch (read_tag(input, output))
{
case StartTag:
case AttributeSection:
case OliasAttribute:
delete attr ;
throw(CASTDPUTEXCEPT docParserUnexpectedTag());
break;
case NoTag:
delete attr;
throw(CASTDPUDEXCEPT docParserUnexpectedData());
break;
case EndTag:
break;
}
return attr ;
}
DocParser::TagType
DocParser::read_tag(istream &input, ostringstream &output)
{
output.seekp(streampos(0));
TagType tt = StartTag;
char c ;
// strip newlines before/after tags
while ((input >> c) && (c == '\n'));
if (input.eof())
throw(CASTDPUEEXCEPT docParserUnexpectedEof());
if (c != '<')
{
input.putback(c);
return NoTag;
}
input >> c ;
switch (c)
{
case '/':
tt = EndTag ;
break;
case '#':
input >> c;
if (c == '>')
return AttributeSection ; // EXIT
else
{
tt = OliasAttribute ;
output << c; // keep char we just read
}
break;
case '>':
throw(CASTUTEXCEPT unknownTagException());
// NOT REACHED
break;
default:
output << c ; // keep char we just read
break;
}
// get (remainder of) tag name
while ((input >> c) && (c != '>'))
output << c ;
output << ends;
return tt ;
}
void
DocParser::read_data(istream &input, ostringstream &output)
{
char c ;
output.seekp(streampos(0));
while ((input >> c) && (c != '<'))
{
// handle entities
if (c == '&')
{
char tmpbuf[64];
unsigned int tmplen = 0;
while ((input >> c ) && (c != ';'))
{
tmpbuf[tmplen++] = c ;
if (tmplen > 63)
{
cerr << "Temp Buf overflow (ampersand problem)" << endl;
throw(CASTEXCEPT Exception());
}
}
if (input.eof())
throw(CASTDPUEEXCEPT docParserUnexpectedEof());
tmpbuf[tmplen] = 0 ;
#ifdef ENTITY_DEBUG
cerr << "Entity: " << tmpbuf << endl;
#endif
if ((!strcmp(tmpbuf, "hardreturn")) ||
(!strcmp(tmpbuf, "lnfeed")))
c = '\n';
else
if ((!strcmp(tmpbuf, "lang")) ||
(!strcmp(tmpbuf, "lt")))
c = '<' ;
else
if (!strcmp(tmpbuf, "amp"))
c = '&' ;
else
if (!strcmp(tmpbuf, "nbsp")) // non-break space
{
if (MB_CUR_MAX > 1) output << 0xC2;
c = (char)0xA0;
}
else
c = ' ';
}
output << c;
}
output << ends;
// can never run out of input while reading data, tags must be balanced
if (input.eof())
throw(CASTDPUEEXCEPT docParserUnexpectedEof());
input.putback(c);
}

View File

@@ -1,92 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: DocParser.h /main/6 1996/06/11 17:06:11 cde-hal $ */
/* Copyright (c) 1995 FUJITSU LIMITED */
/* All Rights Reserved */
#include <iostream>
#include <sstream>
using namespace std;
#include "SymTab.h"
#include "dti_excs/Exceptions.hh"
class Resolver;
class Attribute;
class AttributeList;
// parse SGML like documents
// attributes follow elements in an olias section
// <ELEMENT>
// <#><attr_1>value</>
// <attr_2>value</>
// <#olias_attr>value</>
// </>
// Element data here
// </ELEMENT>
class Element ;
class DocParser : public Destructable
{
public:
enum TagType { StartTag, EndTag, AttributeSection, OliasAttribute, NoTag };
DocParser(Resolver &);
virtual ~DocParser();
// returns a boolean
unsigned int parse(istream &);
// parse without calling Begin() and End() on the renderer.
unsigned int rawParse(istream &);
protected:
virtual void read_data(istream &, ostringstream &);
private:
void process(istream &, ostringstream &, const Symbol &tagname,
unsigned int sibling_number,
unsigned int relative_sibling_number);
TagType read_tag(istream &, ostringstream &);
void process_entity(istream &, ostringstream &);
void process_attributes(istream &, ostringstream &,
AttributeList *&attrs,
AttributeList *&olias_attrs);
Attribute *process_attribute(istream &, ostringstream &, const Symbol &name, TagType);
private:
unsigned int f_ignoring_element ;
Resolver &f_resolver;
#if defined(SC3)
char* const f_buffer;
ostrstream f_output;
#else
stringbuf *f_streambuf;
ostringstream f_output;
#endif
};

View File

@@ -1,141 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $TOG: Element.C /main/5 1998/04/17 11:48:25 mgreess $
#include <iostream>
using namespace std;
#include <stdlib.h>
#include "StyleSheetExceptions.h"
#include "Element.h"
#include "AttributeList.h"
// /////////////////////////////////////////////////////////////////////////
// Element
// /////////////////////////////////////////////////////////////////////////
#define OLIAS_SIBLING_INFO "LAST"
Element::Element(const Element& element)
:
f_gi(element.f_gi),
f_sibling_number(element.f_sibling_number),
f_attributes(element.f_attributes),
f_olias_attributes(element.f_olias_attributes),
f_freeAttrLists(false),
f_relative_sibling_number(element.f_relative_sibling_number),
f_last_child(element.f_last_child),
f_relatively_last_child(element.f_relatively_last_child)
{
}
Element::Element(const Symbol& gi,
unsigned int sibling_number,
AttributeList *attlist,
AttributeList *olias_attributes,
unsigned int relative_sibling_number
)
: f_gi(gi),
f_sibling_number(sibling_number),
f_attributes(attlist),
f_olias_attributes(olias_attributes),
f_freeAttrLists(true),
f_relative_sibling_number(relative_sibling_number)
{
f_last_child = 0;
f_relatively_last_child = 0;
Symbol name(gSymTab->intern(OLIAS_SIBLING_INFO));
const Attribute* x = get_olias_attribute(name);
if ( x && x -> value() ) {
int code = atoi(x -> value());
switch (code) {
case 0:
f_last_child = 0;
f_relatively_last_child = 0;
break;
case 1:
f_last_child = 0;
f_relatively_last_child = 1;
break;
case 2:
f_last_child = 1;
f_relatively_last_child = 1;
break;
default:
throw(CASTEXCEPT Exception());
}
}
}
Element::~Element()
{
if ( f_freeAttrLists == true ) {
delete f_olias_attributes;
delete f_attributes;
}
}
const Attribute *
Element::get_attribute(const Symbol &name) const
{
if (f_attributes)
return f_attributes->lookup(name);
return 0 ;
}
const Attribute *
Element::get_olias_attribute(const Symbol &name) const
{
if (f_olias_attributes)
return f_olias_attributes->lookup(name);
return 0 ;
}
ostream &
Element::print(ostream &o) const
{
o << '<' << f_gi ;
#ifdef SIBLING_DEBUG
o << "[" << this->f_sibling_number << "]";
o << "[" << this->f_relative_sibling_number<< "]";
o << "[" << this-> f_last_child << "]";
o << "[" << this-> f_relatively_last_child<< "]";
#endif
if (f_attributes)
o << *f_attributes ;
if (f_olias_attributes)
o << " #" << *f_olias_attributes ;
o << '>' ;
return o;
}

View File

@@ -1,93 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: Element.h /main/5 1996/08/21 15:50:08 drk $ */
#ifndef _Element_h
#define _Element_h
#ifndef CDE_NEXT
#else
#include "dti_cc/CC_Slist.h"
#endif
#include "SymTab.h"
/* **************************************************************
class Element
this is the structure passed from the node parser to the Resolver.
It contains the Element GI, and the attribute list for the element
************************************************************** */
class Attribute;
class AttributeList;
class Element
{
public:
Element(const Element&);
Element(const Symbol &gi,
unsigned int sibling_number = 0,
AttributeList *attrs = 0,
AttributeList *olias_attrs = 0,
unsigned int relative_sibling_number = 0
);
~Element();
const Symbol &gi() const { return f_gi ; }
const Attribute *get_attribute(const Symbol &name) const ;
const Attribute *get_olias_attribute(const Symbol &name) const;
unsigned int sibling_number() const { return f_sibling_number ; }
unsigned int relative_sibling_number() const
{ return f_relative_sibling_number; }
int last_child() const { return f_last_child; }
int relatively_last_child() const
{ return f_relatively_last_child; }
ostream &print(ostream &) const ;
private:
Symbol f_gi ;
unsigned int f_sibling_number ; // counting all children of a parent
AttributeList *f_attributes;
AttributeList *f_olias_attributes;
unsigned int f_freeAttrLists;
unsigned int f_relative_sibling_number ; // counting all
// consecutive children
// of same types of a
// parent
int f_last_child;
int f_relatively_last_child;
};
inline
ostream &operator<<(ostream &o, const Element &e)
{
return e.print(o);
}
#endif /* _Element_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,435 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $TOG: Expression.C /main/9 1998/04/17 11:48:40 mgreess $
#include "Attribute.h"
#include "AttributeList.h"
#include "Expression.h"
#include "FeatureValue.h"
#include "ResolverStack.h"
#include "StyleSheetExceptions.h"
#include "VariableTable.h"
#include "Renderer.h"
#include "Debug.h"
#include <sstream>
#include "HardCopy/autoNumberFP.h"
extern const Element *gCurrentElement;
extern const FeatureSet *gCurrentLocalSet;
extern const FeatureSet *gParentCompleteSet;
Expression::Expression(TermNode *root)
: f_root(root)
{
}
Expression::Expression(const Expression &e)
: f_root(e.f_root->clone())
{
}
ConstantNode::ConstantNode(FeatureValue *v)
: f_value(v)
{
}
VariableNode::VariableNode(const Symbol &name)
: f_name(name)
{
}
CompositeVariableNode::CompositeVariableNode()
: f_items(4)
{
}
CompositeVariableNode::CompositeVariableNode(size_t capac)
: f_items(capac)
{
}
CompositeVariableNode::~CompositeVariableNode()
{
f_items.clearAndDestroy();
}
void
CompositeVariableNode::prependItem(const Symbol& item)
{
f_items.prepend(new Symbol(item));
}
void
CompositeVariableNode::appendItem(const Symbol& item)
{
f_items.append(new Symbol(item));
}
const Symbol*
CompositeVariableNode::convertableToVariable()
{
const Symbol* x = 0;
if ( f_items.entries() == 1 ) {
x = f_items.first();
if ( gVariableTable -> exists(*x) )
return x;
}
return 0;
}
BinaryOperatorNode::BinaryOperatorNode(operatorType t,
TermNode *left, TermNode *right)
: f_operator(t), f_left(left), f_right(right)
{
}
BinaryOperatorNode::~BinaryOperatorNode()
{
delete f_left ;
delete f_right;
}
SgmlAttributeNode::SgmlAttributeNode(const Symbol &name)
: f_name(name)
{
}
FeatureValue *
Expression::evaluate() const
{
return f_root->evaluate();
}
Expression::~Expression()
{
delete f_root ;
}
TermNode::~TermNode()
{
}
ConstantNode::~ConstantNode()
{
delete f_value ;
}
FeatureValue *
BinaryOperatorNode::evaluate() const
{
// calculate children trees and then have feature value do the operation
#if !defined(SC3) && !defined(_IBMR2) && !defined(__linux__) && \
!defined(CSRG_BASED) && !defined(sun)
volatile
#endif
FeatureValue *left = 0;
#if !defined(SC3) && !defined(_IBMR2) && !defined(__linux__) && \
!defined(CSRG_BASED) && !defined(sun)
volatile
#endif
FeatureValue *right = 0;
#if !defined(SC3) && !defined(_IBMR2) && !defined(__linux__) && \
!defined(CSRG_BASED) && !defined(sun)
volatile
#endif
FeatureValue *result = 0;
mtry
{
left = f_left->evaluate();
right = f_right->evaluate();
switch (f_operator)
{
case PLUS:
result = *left + *right ;
break;
case MINUS:
result = *left - *right ;
break;
case TIMES:
result = *left * *right ;
break;
case DIVIDE:
result = *left / *right ;
break;
}
}
mcatch_any()
{
delete left ;
delete right ;
delete result ;
rethrow;
}
end_try ;
delete left ;
delete right ;
return result ;
}
FeatureValue *
VariableNode::evaluate() const
{
// this could be a feature or a variable
// first look in the parent feature set
// NOTE: actual operation should be to look in the local feature set first
// before going to the parent unless the inherit operator was used. Not sure
// how to do this, because at this point, we are trying to evaluate the
// current feature set
// see if item exists in parent feature hierarchy, and if not, then we go to
// the variable table
//MESSAGE(cerr, "VariableNode::evaluate()");
//f_name.print(cerr);
FeatureValue *variable_value = gVariableTable->lookup(f_name).evaluate();
//debug(cerr, int(variable_value));
if (!variable_value)
throw(CASTUVEXCEPT undefinedVariableException(f_name));
// have to evaluate it in case it contains expressions or other variables
// etc.
FeatureValue *return_variable = 0;
mtry
{
return_variable = variable_value->evaluate() ;
}
mcatch_any()
{
delete return_variable;
delete variable_value ;
rethrow;
}
end_try;
//MESSAGE(cerr, "VariableNode::evaluate() completes");
delete variable_value ;
return return_variable;
}
FeatureValue *
CompositeVariableNode::evaluate() const
{
/*
MESSAGE(cerr, "CompositeVariableNode::evaluate():");
print(cerr);
cerr << "\n";
f_items[0] -> print(cerr);
MESSAGE(cerr, "");
*/
//debug(cerr, int(gCurrentLocalSet));
//debug(cerr, int(gParentCompleteSet));
const Feature *f = 0;
if ( gCurrentLocalSet )
f = gCurrentLocalSet->deep_lookup(f_items) ;
//debug(cerr, int(f));
if (!f && gParentCompleteSet )
f = gParentCompleteSet->deep_lookup(f_items);
//debug(cerr, int(f));
//if ( f == 0 && gRenderer ) {
if ( f == 0 ) {
FeatureValue* fv = gAutoNumberFP.evaluate(f_items[0] -> name());
if ( fv == 0 ) {
//print(cerr);
throw(CASTBEEXCEPT badEvaluationException());
} else
return fv;
}
if (!f) {
//print(cerr);
throw(CASTBEEXCEPT badEvaluationException());
}
return f->evaluate();
}
FeatureValue *
ConstantNode::evaluate() const
{
//return f_value->clone();
return f_value->evaluate();
}
extern unsigned g_validation_mode;
#if defined(__FreeBSD__) && (__FreeBSD__ >= 10) && !defined(__llvm__)
__attribute__((optimize(0)))
#endif
FeatureValue *
SgmlAttributeNode::evaluate() const
{
if ( g_validation_mode == true ) {
throw(CASTUAEXCEPT undefinedAttributeException(f_name));
}
const Attribute *attr = gCurrentElement->get_attribute(f_name);
if (attr)
return new FeatureValueString(attr->value());
throw(CASTUAEXCEPT undefinedAttributeException(f_name));
return 0 ;
}
// ////////////////////////////////////////////////////////////////////////
// Printing
// ////////////////////////////////////////////////////////////////////////
ostream &operator<<(ostream &o, const Expression &e)
{
return e.print(o);
}
ostream &operator<< (ostream &o, const TermNode &t)
{
return t.print(o);
}
ostream &
Expression::print(ostream &o) const
{
return o << *f_root ;
}
ostream &
VariableNode::print(ostream &o) const
{
return o << f_name ;
}
ostream &
BinaryOperatorNode::print(ostream &o) const
{
o << "(" << *f_left << ' ';
switch (f_operator)
{
case PLUS:
o << '+' ;
break;
case MINUS:
o << '-';
break;
case TIMES:
o << '*' ;
break;
case DIVIDE:
o << '/';
break;
}
return o << ' ' << *f_right << ')' ;
}
ostream &
SgmlAttributeNode::print(ostream &o) const
{
return o << '@' << f_name ;
}
ostream &
ConstantNode::print(ostream &o) const
{
return o << *f_value ;
}
ostream &
CompositeVariableNode::print(ostream &o) const
{
int length = f_items.entries();
for (int i = 0; i < length; i++)
{
o << *f_items[i] ;
if (i < length - 1)
o << "." ;
}
return o ;
}
// /////////////////////////////////////////////////////////////////////////
// cloning
// /////////////////////////////////////////////////////////////////////////
TermNode *
VariableNode::clone() const
{
return new VariableNode(f_name);
}
TermNode *
CompositeVariableNode::clone() const
{
int nitems = f_items.entries();
CompositeVariableNode *node = new CompositeVariableNode(nitems);
for (int i = 0; i < nitems; i++)
node->appendItem(*f_items(i));
return node ;
}
TermNode *
BinaryOperatorNode::clone() const
{
return new BinaryOperatorNode(f_operator, f_left->clone(), f_right->clone());
}
TermNode *
SgmlAttributeNode::clone() const
{
return new SgmlAttributeNode(f_name);
}
TermNode *
ConstantNode::clone() const
{
return new ConstantNode(f_value->clone());
}

View File

@@ -1,176 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: Expression.h /main/4 1996/08/21 15:50:17 drk $ */
#ifndef _Expression_h
#define _Expression_h
/* **************************************************************
Defines the tree for evaluating expressions given as feature values
in the Style Sheet
* ************************************************************** */
#include "SymTab.h"
#ifndef CDE_NEXT
typedef dlist_array<Symbol> f_items_t;
#else
#include "dti_cc/cc_povec.h"
typedef dlist_array<Symbol> f_items_t;
#endif
class FeatureValue;
class TermNode;
// /////////////////////////////////////////////////////////////////////////
// class Expression
//
// holds root of expression tree
// /////////////////////////////////////////////////////////////////////////
class Expression
{
public:
Expression(TermNode *root);
Expression(const Expression&);
virtual ~Expression();
virtual FeatureValue *evaluate() const;
ostream &print(ostream &) const;
private:
TermNode* f_root;
};
class TermNode
{
public:
virtual ~TermNode();
virtual FeatureValue *evaluate() const = 0;
virtual ostream &print(ostream &) const = 0;
virtual TermNode *clone() const = 0;
};
class VariableNode: public TermNode
{
// for single name variables eg: "DEFAULT_FONT"
public:
VariableNode(const Symbol& name);
virtual FeatureValue *evaluate() const;
ostream &print(ostream &) const;
virtual TermNode *clone() const;
private:
Symbol f_name;
};
class CompositeVariableNode : public TermNode
{
// for feature path variables (font.size)
// eg: font: { size: font.size }
public:
CompositeVariableNode();
CompositeVariableNode(size_t capac); /* if we know how many items to expect */
~CompositeVariableNode();
virtual FeatureValue *evaluate() const ;
ostream &print(ostream &) const;
virtual TermNode *clone() const;
void prependItem(const Symbol& item);
void appendItem(const Symbol& item);
const Symbol* convertableToVariable();
private:
//dlist_array<Symbol> f_items;
f_items_t f_items;
};
class BinaryOperatorNode: public TermNode
{
public:
enum operatorType { PLUS, MINUS, TIMES, DIVIDE };
BinaryOperatorNode(operatorType, TermNode* left, TermNode* right);
~BinaryOperatorNode();
virtual TermNode *clone() const;
virtual FeatureValue *evaluate() const;
ostream &print(ostream &) const;
private:
operatorType f_operator ;
TermNode *f_left;
TermNode *f_right;
};
class SgmlAttributeNode: public TermNode
{
public:
SgmlAttributeNode(const Symbol& name);
SgmlAttributeNode();
virtual FeatureValue *evaluate() const ;
ostream &print(ostream &) const;
virtual TermNode *clone() const;
private:
Symbol f_name;
};
class ConstantNode: public TermNode
{
public:
ConstantNode(FeatureValue*);
~ConstantNode();
virtual FeatureValue *evaluate() const;
ostream &print(ostream &) const;
virtual TermNode *clone() const;
private:
FeatureValue *f_value;
};
ostream &operator <<(ostream &, const Expression &);
ostream &operator <<(ostream &, const TermNode &);
#endif /* _Expression_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,90 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: Feature.cc /main/3 1996/06/11 17:06:39 cde-hal $
#include "SymTab.h"
#include "Feature.h"
#include "FeatureValue.h"
#include <assert.h>
#include <stdarg.h>
Feature::Feature(const Symbol &name, FeatureValue *value)
: f_name(name),
f_value(value)
{
}
Feature::Feature(const Feature &orig_feature)
: f_name(orig_feature.name()),
f_value(orig_feature.value()->clone())
{
}
unsigned int Feature::operator==(const Feature &f )
{
return f.name() == f_name;
}
Feature::~Feature()
{
delete f_value ;
}
FeatureValue *
Feature::evaluate() const
{
return f_value->evaluate();
}
// /////////////////////////////////////////////////////////////////////////
// Printing
// /////////////////////////////////////////////////////////////////////////
ostream &operator << (ostream &o, const Feature &f)
{
return f.print(o);
}
ostream &
Feature::print(ostream &o) const
{
return o << f_name << ": " << *f_value ;
}
void
Feature::merge(const Feature &feature_to_merge)
{
assert(f_name == feature_to_merge.name());
if (*f_value == *feature_to_merge.value())
;
else
{
FeatureValue *new_value = f_value->merge(*feature_to_merge.value());
delete f_value ;
f_value = new_value ;
}
}

View File

@@ -1,157 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: Feature.h /main/4 1996/08/21 15:50:21 drk $ */
#ifndef _Feature_h
#define _Feature_h
#include <sstream>
#ifndef CDE_NEXT
#else
#include "dti_cc/CC_Slist.h"
#include "dti_cc/cc_povec.h"
#endif
#include "SymTab.h"
class Element;
class Expression;
class FeatureValue;
class VariableTable;
class ResolverStackElement ;
class Symbol;
/*
#ifndef CDE_NEXT
class dlist_array<Symbol> ;
#else
class dlist_array<Symbol> ;
#endif
*/
/* **************************************************************
* class Feature
a symbol, value pairing where symbol is the feature name
* ************************************************************** */
class Feature
{
public:
Feature(const Symbol &, FeatureValue *);
Feature(const Feature &);
~Feature();
const Symbol &name() const { return f_name ; }
const FeatureValue *value() const { return f_value ; }
FeatureValue *evaluate() const;
// destructively modifies f_value
void merge(const Feature &);
ostream &print(ostream &) const ;
unsigned int operator==(const Feature&);
private:
void assembleChainFeatures(FeatureValue* x);
private:
Symbol f_name ;
FeatureValue *f_value;
};
/* **************************************************************
* class FeatureSet
FeatureSet is is a list of features and their values. Features are
represented by symbols. Values can be strings, numbers (int or real)
or FeatureSet
* ************************************************************** */
#ifndef CDE_NEXT
class FeatureSet : public CC_TPtrSlist<Feature>
#else
class FeatureSet : public CC_TPtrSlist<Feature>
#endif
{
public:
FeatureSet();
FeatureSet(const FeatureSet &); /* copy */
FeatureSet(const FeatureSet &,
const FeatureSet &); /* merge */
virtual ~FeatureSet();
void add(Feature *);
const Feature *lookup(const Symbol *) const ;
const Feature *lookup(const Symbol &) const;
const Feature *lookup(const char *) const;
// find a chain, eg for "prefix.font.size" use */
// deep_lookup("prefix","font","size", 0);
// returns 0 if not found
const Feature *deep_lookup(const char * ...) const ;
const Feature *deep_lookup(const Symbol * ...) const ;
#ifndef CDE_NEXT
const Feature *deep_lookup(const dlist_array<Symbol> &) const ;
#else
const Feature *deep_lookup(const dlist_array<Symbol> &) const ;
#endif
// remve a feature that is specified by a chain
void removeFeature(const char * ...) ;
// returns new feature set with all unresolved expressions resolved
FeatureSet *evaluate() const;
// evaluate self and place answers into result_set, returns result set
FeatureSet *evaluate(FeatureSet *result_set) const ;
unsigned int operator == (const FeatureSet &) const ;
ostream &print(ostream &) const ;
private:
static unsigned int f_print_indent_level ;
};
/* **************************************************************
* Printing
* ************************************************************** */
ostream &operator << (ostream &o, const Feature &f);
ostream &operator << (ostream &o, const FeatureSet &f);
#endif /* _Feature_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,589 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $TOG: FeatureDefDictionary.C /main/4 1998/04/17 11:48:58 mgreess $
#include "StyleSheet/FeatureDefDictionary.h"
#include "StyleSheet/Debug.h"
#include "StyleSheet/StyleSheetExceptions.h"
#include "utility/const.h"
#include "utility/funcs.h"
#include <iostream>
using namespace std;
featureDefDictionary* g_FeatureDefDictionary = 0;
extern void report_error_location();
extern def_list_t* g_def_list;
extern FILE *defParserin;
extern int defParserparse();
istream* g_defParserin = 0;
unsigned g_validation_mode = false;
unsigned g_hasSemanticError = false;
ostream& out_tabs(ostream& out, int tabs)
{
for (int i=0; i<tabs; i++)
out << "\t";
return out;
}
TypeValues::TypeValues(char* t, defv_t* dv) :
f_type(t), f_default_values(dv)
{
}
TypeValues::~TypeValues()
{
if ( f_default_values ) {
f_default_values -> clearAndDestroy();
delete f_default_values;
}
}
unsigned int TypeValues::operator==(const TypeValues& def)
{
return !f_type.compareTo(def.f_type, CC_String::ignoreCase);
}
ostream& operator <<(ostream& out, TypeValues& tvs)
{
return tvs.print(out, 0);
}
unsigned TypeValues::check(const FeatureValue* fv)
{
/*
MESSAGE(cerr, "TypeValues::check()");
debug(cerr, fv -> type());
*/
// type check
switch ( fv -> type() ) {
case FeatureValue::real:
case FeatureValue::integer:
//debug(cerr, f_type.data());
if ( strcasecmp(f_type.data(), "REAL") == 0 ||
strcasecmp(f_type.data(), "INTEGER") == 0
)
break;
else
return false;
case FeatureValue::string:
//debug(cerr, f_type.data());
if ( strcasecmp(f_type.data(), "STRING") == 0 ||
strcasecmp(f_type.data(), "STRING_PREFIX") == 0
)
break;
else
return false;
case FeatureValue::symbol:
case FeatureValue::expression:
case FeatureValue::featureset:
return false;
//debug(cerr, f_type.data());
case FeatureValue::dimension:
if ( strcasecmp(f_type.data(), "DIMENSION") == 0 ||
strcasecmp(f_type.data(), "DIMENSION_PIXEL") == 0
)
break;
else
return false;
case FeatureValue::array:
//debug(cerr, f_type.data());
if ( strcasecmp(f_type.data(), "ARRAY") == 0 )
break;
else
return false;
}
// value check
if ( f_default_values == 0 ) {
//MESSAGE(cerr, "check() Passed");
return true;
}
defv_iterator_t next(*f_default_values);
const char* x, *y;
while (++next) {
/////////////////////////////////////////////////////////////
// trap string type as FeatureValueString::operator==() uses
// case sensitive comparsion
/////////////////////////////////////////////////////////////
if ( fv -> type() == FeatureValue::string &&
next.key() -> type() == FeatureValue::string )
{
x = *((FeatureValueString*)next.key());
y = *(FeatureValueString*)fv;
//debug(cerr, x);
//debug(cerr, y);
if ( strcasecmp(f_type.data(), "STRING_PREFIX") == 0 ) {
if ( strncasecmp(x, y, strlen(x)) == 0 )
return true;
} else {
if ( strcasecmp(x, y) == 0 )
return true;
}
} else
if ( next.key() -> operator==(*fv) == true ) {
//MESSAGE(cerr, "check() Passed");
return true ;
}
}
return false;
}
ostream& TypeValues::print(ostream& out, int tabs) const
{
out_tabs(out, tabs) << f_type << "\n";
if ( f_default_values ) {
defv_iterator_t NextValue (*f_default_values);
while (++NextValue) {
out_tabs(out, tabs+1) << *(NextValue.key()) << "\n";
}
}
return out;
}
unsigned fhash(const FeatureDef& key)
{
return key.name() -> hash();
}
FeatureDef::FeatureDef(const char* name) : f_name(name)
{
}
FeatureDef::~FeatureDef()
{
}
ostream& operator << (ostream& out, FeatureDef& def)
{
return def.print(out, 0);
}
unsigned int FeatureDef::operator==(const FeatureDef& def)
{
//debug(cerr, f_name);
//debug(cerr, def.f_name);
// unsigned ok = ! f_name.compareTo(def.f_name, CC_String::ignoreCase);
//debug(cerr, ok);
//return ok;
return !f_name.compareTo(def.f_name, CC_String::ignoreCase);
}
FeatureDefComposite::FeatureDefComposite(const char* name, def_list_t* dl) :
FeatureDef(name), f_components(dl)
{
}
FeatureDefComposite::~FeatureDefComposite()
{
if ( f_components ) {
f_components -> clearAndDestroy();
delete f_components;
}
}
CC_Boolean compareFunc(FeatureDef* fd, void* nm)
{
if ( strcasecmp( fd -> name() -> data(), (char*)nm ) == 0 )
return TRUE;
else
return FALSE;
}
// return true:
// fv confirms to the spec of a component of this def.
// return false:
// otherwise
unsigned FeatureDefComposite::checkContent(const Feature* fv) const
{
/*
const FeatureDef* def = getComponentDef((fv->name()).name());
if ( def == 0 )
return false;
if ( def -> type() != FeatureDef::PRIMITIVE )
return false;
return ((FeatureDefPrimitive*)def) -> checkContent(fv);
*/
return true;
}
const FeatureDef* FeatureDefComposite::getComponentDef(const char* nm) const
{
if ( f_components == 0 )
return 0;
else {
FeatureDef* def = f_components -> find(compareFunc, (void*)nm);
if ( def )
return def;
else {
if ( f_components -> first() -> type() == WILDCARD )
return f_components -> first();
else
return 0;
}
//return f_components -> find(compareFunc, "*");
}
}
ostream& FeatureDefComposite::print(ostream& out, int tabs) const
{
out_tabs(out, tabs) << f_name << "\n";
if ( f_components ) {
def_list_iterator_t NextComponent(*f_components);
while (++NextComponent) {
NextComponent.key() -> print(out, tabs+1) << "\n";
}
}
return out;
}
FeatureDefPrimitive::FeatureDefPrimitive(const char* name, type_values_list_t* tvl) :
FeatureDef(name), f_typeValuesList(tvl)
{
}
FeatureDefPrimitive::~FeatureDefPrimitive()
{
if ( f_typeValuesList ) {
f_typeValuesList -> clearAndDestroy();
delete f_typeValuesList;
}
}
unsigned FeatureDefPrimitive::checkContent(const Feature* f) const
{
/*
MESSAGE(cerr, "FeatureDefPrimitive::checkContent");
f -> print(cerr);
MESSAGE(cerr, "");
debug(cerr, *(this -> name()));
MESSAGE(cerr, "");
*/
if ( f_typeValuesList == 0 ) {
report_error_location();
cerr << "No type definition.\n";
return false;
}
FeatureValue * fv = 0;
mtry {
fv = f -> evaluate();
}
mcatch (undefinedAttributeException&, e) {
return true;
}
mcatch (undefinedVariableException&, e) {
report_error_location();
cerr << "Undefined variable error.\n";
return false;
}
/*
mcatch (badCastException&, e) {
report_error_location();
cerr << "Evaluating expression error.\n";
return false;
}
mcatch (badEvaluationException&, e) {
report_error_location();
cerr << "Evaluating expression error.\n";
return false;
}
*/
mcatch_any() {
//report_error_location();
//cerr << "There might be an error in the expression.\n";
return true;
}
end_try;
/*
debug(cerr, int(fv));
fv -> print(cerr);
MESSAGE(cerr, "");
*/
if ( fv == 0 ) {
report_error_location();
cerr << "Error in evaluating an expression.\n";
return false;
}
type_values_list_iterator_t next(*f_typeValuesList);
while ( ++ next ) {
if ( next.key() -> check(fv) == true ) {
delete fv;
return true ;
}
}
delete fv;
report_error_location();
cerr << form("Unmatched feature type or illegal feature value: %s.\n",
(f -> name()).name()
);
return false;
}
ostream& FeatureDefPrimitive::print(ostream& out, int tabs) const
{
out_tabs(out, tabs) << f_name << "\n";
if ( f_typeValuesList ) {
type_values_list_iterator_t NextValue (*f_typeValuesList);
while (++NextValue) {
NextValue.key() -> print(out, tabs+1) << "\n";
}
}
return out;
}
unsigned FeatureDefReference::checkContent(const Feature* fv) const
{
return false;
}
ostream& FeatureDefReference::print(ostream& out, int tabs) const
{
out_tabs(out, tabs) << f_name << "\n";
return out;
}
unsigned FeatureDefWildCard::checkContent(const Feature* fv) const
{
return true;
}
ostream& FeatureDefWildCard::print(ostream& out, int tabs) const
{
out_tabs(out, tabs) << f_name << "\n";
return out;
}
featureDefDictionary::featureDefDictionary() : f_def_list(0)
{
}
featureDefDictionary::~featureDefDictionary()
{
if ( f_def_list ) {
f_def_list -> clearAndDestroy();
delete f_def_list;
}
}
void
featureDefDictionary::addFeatureDefs(def_list_t* fdefs)
{
f_def_list = fdefs;
if ( f_def_list == 0 )
throw(CASTEXCEPT Exception());
}
const FeatureDef*
featureDefDictionary::getDef(const char* nm)
{
//debug(cerr, nm);
FeatureDefReference key((char*)nm);
return f_def_list -> find(&key);
/*
FeatureDef* def = 0;
def = f_def_list -> find(&key);
debug(cerr, int(def));
return def;
*/
}
const FeatureDef*
featureDefDictionary::getDef(const Feature* f)
{
return getDef((f -> name()).name());
}
unsigned
featureDefDictionary::checkSemantics(const FeatureSet* fs)
{
/*
MESSAGE(cerr, "check feature set:");
fs -> print(cerr);
MESSAGE(cerr, "");
*/
const FeatureDef* def = 0;
const Feature *f = 0;
CC_TPtrSlistIterator<Feature> next(*(CC_TPtrSlist<Feature>*)fs);
while (++next) {
f = next.key();
def = getDef(f);
if ( def == 0 ) {
report_error_location();
cerr << form("Unknown feature name %s.\n",
((next.key()) -> name()).name());
return false;
}
if ( _checkSemantics(f, def) == false )
return false;
}
return true;
}
unsigned
featureDefDictionary::_checkSemantics(const Feature* f, const FeatureDef* def)
{
const FeatureSet *featureset = 0;
const Feature *child_f= 0;
/*
MESSAGE(cerr, "_checkSemantics");
f -> print(cerr);
MESSAGE(cerr, "");
def -> print(cerr, 0);
MESSAGE(cerr, "");
*/
const FeatureDef* child_def = 0;
if ( def -> checkContent(f) == false ) {
return false;
}
if (f -> value()->type() == FeatureValue::featureset &&
def -> type() == FeatureDef::COMPOSITE )
{
//MESSAGE(cerr, "it is a feature set");
featureset =
((const FeatureValueFeatureSet *)(f -> value()))->value();
CC_TPtrSlistIterator<Feature> next(*(CC_TPtrSlist<Feature>*)featureset);
const char* nm;
while ( ++ next ) {
nm = ((next.key()) -> name()).name();
/*
debug(cerr, nm);
report_error_location();
*/
child_def = ((FeatureDefComposite*)def) -> getComponentDef(nm);
//debug(cerr, int(child_def));
if ( child_def == 0 ) {
report_error_location();
cerr << form("%s is a undefined feature.\n", nm);
return false;
}
switch ( child_def -> type() ) {
case FeatureDef::REFERENCE:
child_def = getDef(child_def -> name() -> data());
break;
case FeatureDef::WILDCARD:
child_def = getDef(nm);
break;
default:
break;
}
child_f = next.key();
if ( _checkSemantics(child_f, child_def) == false )
return false;
}
return true;
}
return true;
}
istream& operator >>(istream& in, featureDefDictionary& dict)
{
g_defParserin = &in;
int ok = defParserparse();
if ( ok != 0 ) {
MESSAGE(cerr, "bad feature definition file");
throw(CASTEXCEPT Exception());
}
dict.addFeatureDefs(g_def_list);
return in;
}
ostream& operator <<(ostream& out, featureDefDictionary& dict)
{
def_list_iterator_t Next(*dict.f_def_list);
while (++Next) {
//debug(cerr, int(Next.key()));
out << *Next.key() << "\n";
}
return out;
}

View File

@@ -1,215 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: FeatureDefDictionary.h /main/4 1996/08/21 15:50:25 drk $ */
#ifndef _featureNameDictionary_h
#define _featureNameDictionary_h
#ifndef CDE_NEXT
#else
//#include "StyleSheet/cde_next.h"
#include "dti_cc/CC_Slist.h"
#include "dti_cc/cc_hdict.h"
#include "dti_cc/CC_String.h"
#endif
#include "StyleSheet/Types.h"
#include "StyleSheet/SymTab.h"
#include "StyleSheet/FeatureValue.h"
#include "StyleSheet/Feature.h"
#include "StyleSheet/StyleSheetExceptions.h"
typedef CC_TPtrSlist<FeatureValue> defv_t;
typedef CC_TPtrSlistIterator<FeatureValue> defv_iterator_t;
class TypeValues : public Destructable
{
public:
enum feature_t {real, integer, string, featureset, unit} ;
enum unit_t { INCH=0, PICA=1, POINT=2, CM=3, PIXEL=4, NONE=5 };
TypeValues(char* type, defv_t*);
~TypeValues();
unsigned int operator==(const TypeValues&);
unsigned check(const FeatureValue*);
friend ostream& operator <<(ostream&, TypeValues&);
ostream& print(ostream&, int tabs) const;
protected:
CC_String f_type;
defv_t* f_default_values;
protected:
};
class FeatureDef;
typedef CC_TPtrSlist<FeatureDef> def_list_t;
typedef CC_TPtrSlistIterator<FeatureDef> def_list_iterator_t;
typedef CC_TPtrSlist<TypeValues> type_values_list_t;
typedef CC_TPtrSlistIterator<TypeValues> type_values_list_iterator_t;
class FeatureDef : public Destructable
{
public:
FeatureDef(const char* name);
virtual ~FeatureDef();
unsigned int operator==(const FeatureDef&);
friend ostream& operator <<(ostream&, FeatureDef&) ;
enum def_type_t { PRIMITIVE, COMPOSITE, REFERENCE, WILDCARD };
virtual unsigned type() const = 0;
virtual const CC_String* name() const { return &f_name; };
virtual ostream& print(ostream&, int tabs) const= 0;
virtual unsigned checkContent(const Feature*) const = 0;
protected:
CC_String f_name;
protected:
};
class FeatureDefComposite : public FeatureDef
{
public:
FeatureDefComposite(const char* name, def_list_t*);
~FeatureDefComposite();
unsigned checkContent(const Feature*)const ;
const FeatureDef* getComponentDef(const char*) const;
unsigned type() const { return COMPOSITE; };
protected:
def_list_t* f_components;
protected:
virtual ostream& print(ostream&, int tabs) const;
}
;
class FeatureDefPrimitive: public FeatureDef
{
public:
FeatureDefPrimitive(const char* name, type_values_list_t* tvslist);
~FeatureDefPrimitive();
unsigned type() const { return PRIMITIVE; };
unsigned checkContent(const Feature*)const ;
protected:
type_values_list_t* f_typeValuesList;
protected:
virtual ostream& print(ostream&, int tabs) const;
}
;
class FeatureDefReference : public FeatureDef
{
public:
FeatureDefReference(const char* name) : FeatureDef(name) {};
~FeatureDefReference() {};
unsigned type() const { return REFERENCE; };
unsigned checkContent(const Feature*)const ;
protected:
protected:
virtual ostream& print(ostream&, int tabs) const;
}
;
class FeatureDefWildCard : public FeatureDef
{
public:
FeatureDefWildCard(const char* name) : FeatureDef(name) {};
~FeatureDefWildCard() {};
unsigned type() const { return WILDCARD; };
unsigned checkContent(const Feature*)const ;
protected:
protected:
virtual ostream& print(ostream&, int tabs) const;
}
;
//typedef hashTable<FeatureDef, FeatureDef> featureDefDictionary_t;
//typedef hashTableIterator<FeatureDef, FeatureDef> featureDefDictionary_iterator_t;
class featureDefDictionary : public Destructable
{
protected:
def_list_t* f_def_list;
protected:
const FeatureDef* getDef(const char*);
const FeatureDef* getDef(const Feature*);
//const FeatureDef* getDef(const Feature*, const Feature*);
unsigned _checkSemantics(const Feature* f, const FeatureDef*);
public:
featureDefDictionary();
~featureDefDictionary();
void addFeatureDefs(def_list_t*);
unsigned checkSemantics(const FeatureSet*);
//format:
//
// featureName
// ComponentName : Type [: Default Values (',' separated)]
// ComponentName : Type [: Default Values (',' separated)]
// featureName
// ComponentName : Type [: Default Values (',' separated)]
// ComponentName : Type [: Default Values (',' separated)]
//
// Example:
// font
// size : Unit
// weight : String : "medium", "bold"
//
friend istream& operator >>(istream&, featureDefDictionary&);
friend ostream& operator <<(ostream&, featureDefDictionary&);
};
#endif

View File

@@ -1,345 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: FeatureSet.cc /main/5 1996/08/05 16:18:55 cde-hal $
#include <stdarg.h>
#include <assert.h>
#include "Feature.h"
#include "FeatureValue.h"
#include "StyleSheetExceptions.h"
#include "Debug.h"
unsigned int FeatureSet::f_print_indent_level = 0 ;
ostream &operator << (ostream &o, const FeatureSet &f)
{
return f.print(o);
}
FeatureSet::~FeatureSet()
{
clearAndDestroy(); // clean up memory
}
FeatureSet::FeatureSet()
{
}
FeatureSet::FeatureSet(const FeatureSet &orig_set)
{
// cast to non const
CC_TPtrSlistIterator<Feature> next(*(CC_TPtrSlist<Feature>*) &orig_set) ;
// make a copy of each item and add it to our list
while (++next)
append(new Feature(*next.key()));
}
FeatureSet *
FeatureSet::evaluate() const
{
// I do not yet understand how this evaluate is working well. - TK
#ifdef FS_EVAL_DEBUG
fprintf(stderr, "(DEBUG) FeatureSet::evaluate() called.\n");
#endif
return evaluate(new FeatureSet);
}
FeatureSet *
FeatureSet::evaluate(FeatureSet *result_set) const
{
CC_TPtrSlistIterator<Feature> next(*(FeatureSet*)this);
// cause each feature to evaluate itself
while(++next)
{
FeatureValue *value ;
mtry
{
value = next.key()->evaluate();
result_set->append(new Feature(next.key()->name(),
value));
}
mcatch_noarg(badEvaluationException&)
{
/* do nothing...we just ignore any that will not evaluate */
}
end_try;
}
return result_set ;
}
FeatureSet::FeatureSet(const FeatureSet &base,
const FeatureSet &mixin)
{
Feature dummy = Feature(gSymTab->intern("FAMILY"),0);
int contains_family = mixin.contains(&dummy);
// first duplicate the baseline
CC_TPtrSlistIterator<Feature> base_i(*(CC_TPtrSlist<Feature>*)&base) ;
// make a copy of each item and add it to our list
while (++base_i) {
if (! (contains_family &&
base_i.key()->name() == gSymTab->intern("FAMILY")))
append(new Feature(*base_i.key()));
}
// now merge in mixin
CC_TPtrSlistIterator<Feature> next(*(CC_TPtrSlist<Feature>*)&mixin);
while (++next)
{
if (next.key()->name() == gSymTab->intern("FAMILY"))
append(new Feature(*next.key()));
else {
Feature* mfeature = 0;
mfeature = find(next.key());
#if 0
cout << "Merging: \n" << *next.key() << endl << "into:" << endl;
if (mfeature)
cout << *mfeature << endl;
else
cout << "(nil)" << endl;
#endif
if (mfeature)
mfeature->merge(*next.key()); // merge it if already exists
else
append(new Feature(*next.key())); // else add it if not there
}
}
}
ostream &
FeatureSet::print(ostream &o) const
{
// cast to non-const to get iterator
CC_TPtrSlistIterator<Feature> next(*(CC_TPtrSlist<Feature>*)this);
unsigned int i;
for (i = 0 ; i < f_print_indent_level; i++)
o << " " ;
o << "{" << endl;
f_print_indent_level++;
while (++next)
{
for (unsigned int i = 0 ; i < f_print_indent_level; i++)
o << " " ;
o << *next.key() << endl ;
}
--f_print_indent_level;
for (i = 0 ; i < f_print_indent_level ; i++)
o << " " ;
o << "}" << endl;
return o;
}
void
FeatureSet::add(Feature *f)
{
append(f);
}
unsigned int
FeatureSet::operator==(const FeatureSet &fs) const
{
return &fs == this ;
}
const Feature*
FeatureSet::lookup(const Symbol *symbol) const
{
return lookup(*symbol);
}
const Feature *
FeatureSet::lookup(const Symbol &name) const
{
Feature tmp(name, 0);
return find(&tmp);
}
const Feature *
FeatureSet::lookup(const char *name) const
{
Feature tmp(gSymTab->intern(name),0);
return find(&tmp);
}
const Feature *
FeatureSet::deep_lookup(const char *first_name ...) const
{
const Feature *feature = lookup(first_name);
if (!feature)
return 0;
const FeatureSet *featureset = 0;
va_list ap;
va_start(ap, first_name);
for (;;)
{
const char *p = va_arg(ap, char*);
if (p == 0)
break;
if (feature->value()->type() != FeatureValue::featureset)
{
va_end(ap);
return 0 ;
}
featureset = ((const FeatureValueFeatureSet *)feature->value())->value();
feature = featureset->lookup(p);
if (!feature)
{
va_end(ap);
return 0;
}
}
va_end(ap);
return feature ;
}
const Feature *
FeatureSet::deep_lookup(const Symbol *first_name ...) const
{
const Feature *feature = lookup(*first_name);
if (!feature)
return 0;
const FeatureSet *featureset = 0;
va_list ap;
va_start(ap, first_name);
for (;;)
{
const Symbol *sym = va_arg(ap, const Symbol *);
if (sym == 0)
break;
if (feature->value()->type() != FeatureValue::featureset)
{
va_end(ap);
return 0 ;
}
featureset = ((const FeatureValueFeatureSet *)feature->value())->value();
feature = featureset->lookup(*sym);
if (!feature)
{
va_end(ap);
return 0;
}
}
va_end(ap);
return feature ;
}
const Feature *
FeatureSet::deep_lookup(const dlist_array<Symbol> &vec) const
{
unsigned int index = 0;
const Feature *feature = lookup(*vec[index++]);
if (!feature)
return 0;
const FeatureSet *set = 0;
unsigned int entries = vec.entries();
for (; index < entries ; index++ )
{
if (feature->value()->type() != FeatureValue::featureset)
return 0 ;
set = ((const FeatureValueFeatureSet *)feature->value())->value();
feature = set->lookup(*vec[index++]);
if (!feature)
return 0 ;
}
return feature ;
}
void
FeatureSet::removeFeature(const char *first_name ...)
{
const Feature *feature = lookup(first_name);
if (!feature)
return ;
FeatureSet *featureset = this;
va_list ap;
va_start(ap, first_name);
for (;;)
{
const char *p = va_arg(ap, char*);
if (p == 0)
break;
if (feature->value()->type() != FeatureValue::featureset)
{
va_end(ap);
return ;
}
featureset = (FeatureSet*)
(((const FeatureValueFeatureSet *)feature->value())->value());
feature = featureset->lookup(p);
if (!feature)
{
va_end(ap);
return ;
}
}
va_end(ap);
delete (featureset -> remove((Feature *)feature));
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,656 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: FeatureValue.h /main/5 1996/08/21 15:50:29 drk $ */
#ifndef _FeatureValue_h
#define _FeatureValue_h
//#include "Feature.h"
#ifndef CDE_NEXT
#else
#include "dti_cc/cc_pvect.h"
#endif
#include <string.h>
#if 0
// SWM -- COMMENT THIS OUT -- MMDB utility/funcs.h defines this
#ifdef _IBMR2
extern "C" int strcasecmp(const char*, const char*);
#endif
#endif
class FeatureValue;
class FeatureSet;
class Expression;
ostream &operator << (ostream &, const FeatureValue &);
/* **************************************************************
* class FeatureValue
* ************************************************************** */
class FeatureValueDimension;
class FeatureValueExpression;
class FeatureValueFeatureSet;
class FeatureValueInt;
class FeatureValueReal;
class FeatureValueString;
class FeatureValueSymbol;
class FeatureValueArray;
class FeatureValue
{
public:
enum FeatureType { real, integer, string, symbol, expression, featureset, dimension, array } ;
enum Unit { INCH=0, PICA=1, POINT=2, CM=3, PIXEL=4, NONE=5 };
FeatureValue (FeatureType type) : f_type(type) {}
virtual ~FeatureValue();
const FeatureType type() const { return f_type ; }
virtual FeatureValue *clone() const = 0; /* deep copy */
virtual FeatureValue *evaluate() const;
virtual unsigned int operator==(const FeatureValue &) const;
virtual unsigned int operator==(const FeatureValueInt &) const;
virtual unsigned int operator==(const FeatureValueString &) const;
virtual unsigned int operator==(const FeatureValueReal &) const;
virtual unsigned int operator==(const FeatureValueSymbol &) const;
// produce a new object which is a merge with this object and the parameter
virtual FeatureValue *merge(const FeatureValue &);
// these should return a FeatureValue of the appropriate type
// the operations are resolved vi double dispatching
// all non-numeric types will use zero for their value unless they
// are the denominator in a division operation, then they will use a
// value of 1
virtual FeatureValue *operator+(const FeatureValue&) const ;
virtual FeatureValue *operator-(const FeatureValue&) const ;
virtual FeatureValue *operator*(const FeatureValue&) const ;
virtual FeatureValue *operator/(const FeatureValue&) const ;
virtual FeatureValue *operator+(const FeatureValueInt&) const ;
virtual FeatureValue *operator-(const FeatureValueInt&) const ;
virtual FeatureValue *operator*(const FeatureValueInt&) const ;
virtual FeatureValue *operator/(const FeatureValueInt&) const ;
virtual FeatureValue *operator+(const FeatureValueReal&) const ;
virtual FeatureValue *operator-(const FeatureValueReal&) const ;
virtual FeatureValue *operator*(const FeatureValueReal&) const ;
virtual FeatureValue *operator/(const FeatureValueReal&) const ;
virtual FeatureValue *operator+(const FeatureValueDimension&) const ;
virtual FeatureValue *operator-(const FeatureValueDimension&) const ;
virtual FeatureValue *operator*(const FeatureValueDimension&) const ;
virtual FeatureValue *operator/(const FeatureValueDimension&) const ;
virtual FeatureValue *operator+(const FeatureValueExpression&) const ;
virtual FeatureValue *operator-(const FeatureValueExpression&) const ;
virtual FeatureValue *operator*(const FeatureValueExpression&) const ;
virtual FeatureValue *operator/(const FeatureValueExpression&) const ;
virtual FeatureValue *operator+(const int i) const ; /* returns this + i */
virtual FeatureValue *operator-(const int i) const ; /* returns this - i */
virtual FeatureValue *operator*(const int i) const ; /* returns this * i */
virtual FeatureValue *operator/(const int i) const ; /* returns this / i */
virtual FeatureValue *operator+(const float f) const ; /* returns this + f */
virtual FeatureValue *operator-(const float f) const ; /* returns this - f */
virtual FeatureValue *operator*(const float f) const ; /* returns this * f */
virtual FeatureValue *operator/(const float f) const ; /* returns this / f */
virtual FeatureValue *rdiv(const FeatureValue &) const ;
virtual FeatureValue *rsub(const FeatureValue &) const ;
virtual FeatureValue *rdiv(const FeatureValueInt &) const ;
virtual FeatureValue *rsub(const FeatureValueInt &) const ;
virtual FeatureValue *rdiv(const FeatureValueReal &) const ;
virtual FeatureValue *rsub(const FeatureValueReal &) const ;
virtual FeatureValue *rdiv(const FeatureValueExpression &) const ;
virtual FeatureValue *rsub(const FeatureValueExpression &) const ;
virtual FeatureValue *rdiv(const FeatureValueDimension &) const ;
virtual FeatureValue *rsub(const FeatureValueDimension &) const ;
virtual FeatureValue *rdiv(const int) const ;
virtual FeatureValue *rsub(const int) const ;
virtual FeatureValue *rdiv(const float) const ;
virtual FeatureValue *rsub(const float) const ;
virtual operator float() const;
virtual operator int() const;
virtual operator const char *() const;
virtual operator const FeatureSet * () const ;
virtual ostream &print(ostream&) const = 0;
virtual FeatureValue *doConvert(Unit) const ;
virtual FeatureValue *convertTo(Unit) const ;
virtual FeatureValue *convertTo(Unit from,
Unit to) const ;
private:
FeatureType f_type;
};
class FeatureValueReal : public FeatureValue
{
public:
FeatureValueReal(float value)
: FeatureValue(real), f_value(value)
{}
FeatureValueReal(const FeatureValueReal &);
virtual FeatureValue *clone() const; /* deep copy */
// operators
virtual unsigned int operator==(const FeatureValue &) const;
virtual unsigned int operator==(const FeatureValueInt &) const;
virtual unsigned int operator==(const FeatureValueString &) const;
virtual unsigned int operator==(const FeatureValueReal &) const;
virtual unsigned int operator==(const FeatureValueSymbol &) const;
virtual FeatureValue *operator+(const FeatureValueInt&) const ;
virtual FeatureValue *operator-(const FeatureValueInt&) const ;
virtual FeatureValue *operator*(const FeatureValueInt&) const ;
virtual FeatureValue *operator/(const FeatureValueInt&) const ;
virtual FeatureValue *operator+(const FeatureValueReal&) const ;
virtual FeatureValue *operator-(const FeatureValueReal&) const ;
virtual FeatureValue *operator*(const FeatureValueReal&) const ;
virtual FeatureValue *operator/(const FeatureValueReal&) const ;
virtual FeatureValue *operator+(const FeatureValueDimension&) const ;
virtual FeatureValue *operator-(const FeatureValueDimension&) const ;
virtual FeatureValue *operator*(const FeatureValueDimension&) const ;
virtual FeatureValue *operator/(const FeatureValueDimension&) const ;
virtual FeatureValue *operator+(const FeatureValueExpression&) const ;
virtual FeatureValue *operator-(const FeatureValueExpression&) const ;
virtual FeatureValue *operator*(const FeatureValueExpression&) const ;
virtual FeatureValue *operator/(const FeatureValueExpression&) const ;
virtual FeatureValue *operator+(const FeatureValue&) const ;
virtual FeatureValue *operator-(const FeatureValue&) const ;
virtual FeatureValue *operator*(const FeatureValue&) const ;
virtual FeatureValue *operator/(const FeatureValue&) const ;
virtual FeatureValue *operator+(const int i) const ; /* returns this + i */
virtual FeatureValue *operator-(const int i) const ; /* returns this - i */
virtual FeatureValue *operator*(const int i) const ; /* returns this * i */
virtual FeatureValue *operator/(const int i) const ; /* returns this / i */
virtual FeatureValue *operator+(const float f) const ; /* returns this + f */
virtual FeatureValue *operator-(const float f) const ; /* returns this - f */
virtual FeatureValue *operator*(const float f) const ; /* returns this * f */
virtual FeatureValue *operator/(const float f) const ; /* returns this / f */
virtual FeatureValue *rdiv(const FeatureValue &) const ;
virtual FeatureValue *rsub(const FeatureValue &) const ;
virtual FeatureValue *rdiv(const FeatureValueInt &) const ;
virtual FeatureValue *rsub(const FeatureValueInt &) const ;
virtual FeatureValue *rdiv(const FeatureValueReal &) const ;
virtual FeatureValue *rsub(const FeatureValueReal &) const ;
virtual FeatureValue *rdiv(const FeatureValueExpression &) const ;
virtual FeatureValue *rsub(const FeatureValueExpression &) const ;
virtual FeatureValue *rdiv(const FeatureValueDimension &) const ;
virtual FeatureValue *rsub(const FeatureValueDimension &) const ;
virtual FeatureValue *rdiv(const int) const ;
virtual FeatureValue *rsub(const int) const ;
virtual FeatureValue *rdiv(const float) const ;
virtual FeatureValue *rsub(const float) const ;
virtual FeatureValue *convertTo(Unit) const ;
virtual FeatureValue *convertTo(Unit from,
Unit to) const ;
virtual FeatureValue *doConvert(Unit) const ;
virtual operator float() const;
virtual operator int() const;
virtual operator const char *() const;
virtual ostream& print(ostream&) const;
private:
float f_value ;
};
class FeatureValueInt : public FeatureValue
{
public:
FeatureValueInt(int value)
: FeatureValue(integer), f_value(value)
{}
FeatureValueInt(const FeatureValueInt &);
virtual FeatureValue *clone() const; /* deep copy */
// operators
virtual unsigned int operator==(const FeatureValue &) const;
virtual unsigned int operator==(const FeatureValueInt &) const;
virtual unsigned int operator==(const FeatureValueString &) const;
virtual unsigned int operator==(const FeatureValueReal &) const;
virtual unsigned int operator==(const FeatureValueSymbol &) const;
virtual FeatureValue *operator+(const FeatureValue&) const ;
virtual FeatureValue *operator-(const FeatureValue&) const ;
virtual FeatureValue *operator*(const FeatureValue&) const ;
virtual FeatureValue *operator/(const FeatureValue&) const ;
virtual FeatureValue *operator+(const FeatureValueInt&) const ;
virtual FeatureValue *operator-(const FeatureValueInt&) const ;
virtual FeatureValue *operator*(const FeatureValueInt&) const ;
virtual FeatureValue *operator/(const FeatureValueInt&) const ;
virtual FeatureValue *operator+(const FeatureValueReal&) const ;
virtual FeatureValue *operator-(const FeatureValueReal&) const ;
virtual FeatureValue *operator*(const FeatureValueReal&) const ;
virtual FeatureValue *operator/(const FeatureValueReal&) const ;
virtual FeatureValue *operator+(const FeatureValueDimension&) const ;
virtual FeatureValue *operator-(const FeatureValueDimension&) const ;
virtual FeatureValue *operator*(const FeatureValueDimension&) const ;
virtual FeatureValue *operator/(const FeatureValueDimension&) const ;
virtual FeatureValue *operator+(const FeatureValueExpression&) const ;
virtual FeatureValue *operator-(const FeatureValueExpression&) const ;
virtual FeatureValue *operator*(const FeatureValueExpression&) const ;
virtual FeatureValue *operator/(const FeatureValueExpression&) const ;
virtual FeatureValue *operator+(const int i) const ; /* returns this + i */
virtual FeatureValue *operator-(const int i) const ; /* returns this - i */
virtual FeatureValue *operator*(const int i) const ; /* returns this * i */
virtual FeatureValue *operator/(const int i) const ; /* returns this / i */
virtual FeatureValue *operator+(const float f) const ; /* returns this + f */
virtual FeatureValue *operator-(const float f) const ; /* returns this - f */
virtual FeatureValue *operator*(const float f) const ; /* returns this * f */
virtual FeatureValue *operator/(const float f) const ; /* returns this / f */
virtual FeatureValue *rdiv(const FeatureValue &) const ;
virtual FeatureValue *rsub(const FeatureValue &) const ;
virtual FeatureValue *rdiv(const FeatureValueInt &) const ;
virtual FeatureValue *rsub(const FeatureValueInt &) const ;
virtual FeatureValue *rdiv(const FeatureValueReal &) const ;
virtual FeatureValue *rsub(const FeatureValueReal &) const ;
virtual FeatureValue *rdiv(const FeatureValueExpression &) const ;
virtual FeatureValue *rsub(const FeatureValueExpression &) const ;
virtual FeatureValue *rdiv(const FeatureValueDimension &) const ;
virtual FeatureValue *rsub(const FeatureValueDimension &) const ;
virtual FeatureValue *rdiv(const int) const ;
virtual FeatureValue *rsub(const int) const ;
virtual FeatureValue *rdiv(const float) const ;
virtual FeatureValue *rsub(const float) const ;
virtual FeatureValue *convertTo(Unit) const ;
virtual FeatureValue *convertTo(Unit from, Unit to) const ;
virtual FeatureValue *doConvert(Unit) const ;
virtual operator float() const;
virtual operator int() const;
virtual operator const char *() const;
virtual ostream& print(ostream&) const;
private:
int f_value ;
};
class FeatureValueString : public FeatureValue
{
public:
FeatureValueString(const char *value)
: FeatureValue(string), f_value(value)
{}
FeatureValueString(const FeatureValueString &);
~FeatureValueString();
virtual FeatureValue *clone() const ; /* deep copy */
virtual unsigned int operator==(const FeatureValue &) const;
virtual unsigned int operator==(const FeatureValueInt &) const;
virtual unsigned int operator==(const FeatureValueString &) const;
virtual unsigned int operator==(const FeatureValueReal &) const;
virtual unsigned int operator==(const FeatureValueSymbol &) const;
// ops for string concatenation
// this -> operator+(const FeatureValueExpression&) evaluates
// the argument and then call this -> operator+(const FeatureValue&).
virtual FeatureValue *operator+(const FeatureValue&) const ;
virtual FeatureValue *operator+(const FeatureValueExpression&) const ;
// call FeatureValue::operator+ directly.
virtual FeatureValue *operator+(const FeatureValueInt&) const ;
virtual FeatureValue *operator+(const FeatureValueReal&) const ;
virtual FeatureValue *operator+(const FeatureValueDimension&) const ;
virtual FeatureValue *operator+(const int i) const ;
virtual FeatureValue *operator+(const float f) const ;
virtual operator float() const;
virtual operator int() const;
virtual operator const char *() const;
virtual ostream& print(ostream&) const;
private:
#ifndef CDE_NEXT
CC_String f_value ;
#else
CC_String f_value ;
#endif
};
class FeatureValueSymbol : public FeatureValue
{
public:
FeatureValueSymbol(const Symbol &value)
: FeatureValue(symbol), f_value(value)
{}
FeatureValueSymbol(const FeatureValueSymbol&);
virtual FeatureValue *clone() const ; /* deep copy */
virtual unsigned int operator==(const FeatureValue &) const;
virtual unsigned int operator==(const FeatureValueInt &) const;
virtual unsigned int operator==(const FeatureValueString &) const;
virtual unsigned int operator==(const FeatureValueReal &) const;
virtual unsigned int operator==(const FeatureValueSymbol &) const;
virtual operator float() const;
virtual operator int() const;
virtual operator const char *() const;
virtual ostream& print(ostream&) const;
private:
Symbol f_value;
};
class FeatureValueExpression : public FeatureValue
{
public:
FeatureValueExpression(Expression *);
FeatureValueExpression(const FeatureValueExpression&);
~FeatureValueExpression();
virtual FeatureValue *clone() const ; /* deep copy */
virtual FeatureValue *evaluate() const;
// operators
virtual FeatureValue *operator+(const FeatureValue&) const ;
virtual FeatureValue *operator-(const FeatureValue&) const ;
virtual FeatureValue *operator*(const FeatureValue&) const ;
virtual FeatureValue *operator/(const FeatureValue&) const ;
virtual FeatureValue *operator+(const FeatureValueInt&) const ;
virtual FeatureValue *operator-(const FeatureValueInt&) const ;
virtual FeatureValue *operator*(const FeatureValueInt&) const ;
virtual FeatureValue *operator/(const FeatureValueInt&) const ;
virtual FeatureValue *operator+(const FeatureValueReal&) const ;
virtual FeatureValue *operator-(const FeatureValueReal&) const ;
virtual FeatureValue *operator*(const FeatureValueReal&) const ;
virtual FeatureValue *operator/(const FeatureValueReal&) const ;
virtual FeatureValue *operator+(const FeatureValueDimension&) const ;
virtual FeatureValue *operator-(const FeatureValueDimension&) const ;
virtual FeatureValue *operator*(const FeatureValueDimension&) const ;
virtual FeatureValue *operator/(const FeatureValueDimension&) const ;
virtual FeatureValue *operator+(const FeatureValueExpression&) const ;
virtual FeatureValue *operator-(const FeatureValueExpression&) const ;
virtual FeatureValue *operator*(const FeatureValueExpression&) const ;
virtual FeatureValue *operator/(const FeatureValueExpression&) const ;
virtual FeatureValue *operator+(const int i) const ; /* returns this + i */
virtual FeatureValue *operator-(const int i) const ; /* returns this - i */
virtual FeatureValue *operator*(const int i) const ; /* returns this * i */
virtual FeatureValue *operator/(const int i) const ; /* returns this / i */
virtual FeatureValue *operator+(const float f) const ; /* returns this + f */
virtual FeatureValue *operator-(const float f) const ; /* returns this - f */
virtual FeatureValue *operator*(const float f) const ; /* returns this * f */
virtual FeatureValue *operator/(const float f) const ; /* returns this / f */
virtual FeatureValue *rdiv(const FeatureValue &) const ;
virtual FeatureValue *rsub(const FeatureValue &) const ;
virtual FeatureValue *rdiv(const FeatureValueInt &) const ;
virtual FeatureValue *rsub(const FeatureValueInt &) const ;
virtual FeatureValue *rdiv(const FeatureValueReal &) const ;
virtual FeatureValue *rsub(const FeatureValueReal &) const ;
virtual FeatureValue *rdiv(const FeatureValueExpression &) const ;
virtual FeatureValue *rsub(const FeatureValueExpression &) const ;
virtual FeatureValue *rdiv(const FeatureValueDimension &) const ;
virtual FeatureValue *rsub(const FeatureValueDimension &) const ;
virtual FeatureValue *rdiv(const int) const ;
virtual FeatureValue *rsub(const int) const ;
virtual FeatureValue *rdiv(const float) const ;
virtual FeatureValue *rsub(const float) const ;
virtual operator float() const;
virtual operator int() const;
virtual operator const char *() const;
virtual ostream& print(ostream&) const;
private:
Expression *f_value;
};
class FeatureValueFeatureSet : public FeatureValue
{
public:
FeatureValueFeatureSet(FeatureSet *);
FeatureValueFeatureSet(const FeatureValueFeatureSet&);
~FeatureValueFeatureSet();
const FeatureSet *value() const { return f_value ; }
virtual FeatureValue *evaluate() const;
virtual FeatureValue *clone() const; /* deep copy */
virtual FeatureValue *merge(const FeatureValue &f);
virtual ostream& print(ostream&) const;
virtual operator const FeatureSet *() const ;
private:
FeatureSet *f_value;
};
#ifndef CDE_NEXT
typedef pointer_vector<FeatureValue> ArrayType;
#else
typedef pointer_vector<FeatureValue> ArrayType;
#endif
class FeatureValueArray: public FeatureValue, public ArrayType
{
public:
FeatureValueArray(const char* array_name, int size);
FeatureValueArray(const FeatureValueArray&);
~FeatureValueArray();
virtual FeatureValue *evaluate() const;
virtual FeatureValue *clone() const
{ return new FeatureValueArray(*this); }; /* deep copy */
virtual ostream& print(ostream&) const;
const char* name() { return f_name; };
private:
char* f_name;
};
class FeatureValueDimension : public FeatureValue
{
public:
FeatureValueDimension(FeatureValue *value, const char* unit_string);
FeatureValueDimension(FeatureValue *value, Unit unit);
FeatureValueDimension(float value, const char* unit_string) ;
FeatureValueDimension(float value, Unit unit) :
FeatureValue(dimension), f_value(0),
f_cachedValue(value), f_unit(unit) {};
FeatureValueDimension(const FeatureValueDimension&);
~FeatureValueDimension();
virtual FeatureValue *clone() const; /* deep copy */
virtual FeatureValue *evaluate() const ;
// operators
virtual FeatureValue *operator+(const FeatureValue&) const ;
virtual FeatureValue *operator-(const FeatureValue&) const ;
virtual FeatureValue *operator*(const FeatureValue&) const ;
virtual FeatureValue *operator/(const FeatureValue&) const ;
virtual FeatureValue *operator+(const FeatureValueInt&) const ;
virtual FeatureValue *operator-(const FeatureValueInt&) const ;
virtual FeatureValue *operator*(const FeatureValueInt&) const ;
virtual FeatureValue *operator/(const FeatureValueInt&) const ;
virtual FeatureValue *operator+(const FeatureValueReal&) const ;
virtual FeatureValue *operator-(const FeatureValueReal&) const ;
virtual FeatureValue *operator*(const FeatureValueReal&) const ;
virtual FeatureValue *operator/(const FeatureValueReal&) const ;
virtual FeatureValue *operator+(const FeatureValueDimension&) const ;
virtual FeatureValue *operator-(const FeatureValueDimension&) const ;
virtual FeatureValue *operator*(const FeatureValueDimension&) const ;
virtual FeatureValue *operator/(const FeatureValueDimension&) const ;
virtual FeatureValue *operator+(const FeatureValueExpression&) const ;
virtual FeatureValue *operator-(const FeatureValueExpression&) const ;
virtual FeatureValue *operator*(const FeatureValueExpression&) const ;
virtual FeatureValue *operator/(const FeatureValueExpression&) const ;
virtual FeatureValue *operator+(const int i) const ; /* returns this + i */
virtual FeatureValue *operator-(const int i) const ; /* returns this - i */
virtual FeatureValue *operator*(const int i) const ; /* returns this * i */
virtual FeatureValue *operator/(const int i) const ; /* returns this / i */
virtual FeatureValue *operator+(const float f) const ; /* returns this + f */
virtual FeatureValue *operator-(const float f) const ; /* returns this - f */
virtual FeatureValue *operator*(const float f) const ; /* returns this * f */
virtual FeatureValue *operator/(const float f) const ; /* returns this / f */
virtual FeatureValue *rdiv(const FeatureValue &) const ;
virtual FeatureValue *rsub(const FeatureValue &) const ;
virtual FeatureValue *rdiv(const FeatureValueInt &) const ;
virtual FeatureValue *rsub(const FeatureValueInt &) const ;
virtual FeatureValue *rdiv(const FeatureValueReal &) const ;
virtual FeatureValue *rsub(const FeatureValueReal &) const ;
virtual FeatureValue *rdiv(const FeatureValueExpression &) const ;
virtual FeatureValue *rsub(const FeatureValueExpression &) const ;
virtual FeatureValue *rdiv(const FeatureValueDimension &) const ;
virtual FeatureValue *rsub(const FeatureValueDimension &) const ;
virtual FeatureValue *rdiv(const int) const ;
virtual FeatureValue *rsub(const int) const ;
virtual FeatureValue *rdiv(const float) const ;
virtual FeatureValue *rsub(const float) const ;
virtual FeatureValue *convertTo(Unit) const ;
virtual FeatureValue *convertTo(Unit from, Unit to) const ;
virtual FeatureValue *doConvert(Unit) const ;
virtual operator float() const;
virtual operator int() const;
virtual operator const char *() const;
float getValue(Unit);
FeatureValue *value() { return f_value ; }
Unit unit() { return f_unit ; }
virtual ostream& print(ostream&) const;
private:
FeatureValue *f_value ;
float f_cachedValue;
Unit f_unit ;
private:
float convert(float y, Unit dimensionOfy, Unit dimensionOfReturn);
Unit convertToUnit(const char*);
};
#endif /* _FeatureValue_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,55 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
noinst_LTLIBRARIES = libStyleSheet.la
libStyleSheet_la_CXXFLAGS = -DEXPAND_TEMPLATES -DCDE_NEXT -I..
libStyleSheet_la_SOURCES = Attribute.C \
AttributeList.C \
BitVector.C \
DocParser.C \
Element.C \
Expression.C \
Feature.C \
FeatureDefDictionary.C \
FeatureSet.C \
FeatureValue.C \
PathQualifier.C \
PathTable.C \
RendererHCV.C \
Resolver.C \
ResolverStack.C \
SSPath.C \
SSTemplates.C \
StyleSheet.C \
StyleSheetExceptions.C \
SymTab.C \
VariableTable.C \
defParser.C \
defToken.C \
style.C \
tokenStyle.C
AM_YFLAGS = -l -d
AM_LFLAGS = -8 -s
CLEANFILES = defParser.C \
defParser.tab.h \
defToken.C \
style.C \
style.tab.h \
tokenStyle.C
defParser.C: defParser.yy
$(YACC) $(AM_YFLAGS) -p defParser -b defParser $<
mv defParser.tab.c $@
defToken.C: defToken.ll
$(LEX) $(AM_LFLAGS) -P defParser -o $@ $<
style.C: style.yy
$(YACC) $(AM_YFLAGS) -p style -b style $<
mv style.tab.c style.C
tokenStyle.C: tokenStyle.ll
$(LEX) $(AM_LFLAGS) -P style -o $@ $<

View File

@@ -1,150 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: PQTest.cc /main/3 1996/06/11 17:07:26 cde-hal $
#include <iostream>
using namespace std;
#include "SymTab.h"
#include "PathQualifier.h"
#include "Element.h"
#include "Attribute.h"
#include "AttributeList.h"
void
styleerror(char *)
{
// bogus
abort();
}
class Renderer;
Renderer *gRenderer = 0;
main()
{
SymbolTable symtab ;
Attribute *attr1a = new Attribute(symtab.intern("attr1a"),"one-a");
Attribute *attr1b = new Attribute(symtab.intern("attr1b"),"one-b");
AttributeList *alist1 = new AttributeList ;
alist1->add(attr1a);
alist1->add(attr1b);
Element one(symtab.intern("One"), 1, alist1, 0);
Element two(symtab.intern("Two"), 2, 0, 0);
PQPosition posn_eq(PQEqual, 1);
PQPosition posn_neq(PQNotEqual, 1);
// /////////////////////////////////////////////////////////////////////////
// Test Position
// /////////////////////////////////////////////////////////////////////////
/* -------- Test Position Equal -------- */
cout << posn_eq.evaluate (one) << endl; // 1
cout << posn_eq.evaluate (two) << endl; // 0
cout << "---" << endl;
/* -------- Test Position Not Equal -------- */
cout << posn_neq.evaluate (one) << endl; // 0
cout << posn_neq.evaluate (two) << endl; // 1
cout << "---" << endl;
// ///////////////////////////////////////////////////////////////////////
// Test Attribute Comparison
// ///////////////////////////////////////////////////////////////////////
PQAttributeSelector pqas_eqa(symtab.intern("attr1a"), PQEqual, "one-a");
PQAttributeSelector pqas_eqb(symtab.intern("attr1a"), PQEqual, "one-b");
PQAttributeSelector pqas_neqa(symtab.intern("attr1a"), PQNotEqual, "one-a");
PQAttributeSelector pqas_neqb(symtab.intern("attr1a"), PQNotEqual, "one-b");
PQAttributeSelector pqas_eqa2(symtab.intern("attr2a"), PQEqual, "one-a");
PQAttributeSelector pqas_eqb2(symtab.intern("attr2a"), PQEqual, "one-b");
PQAttributeSelector pqas_neqa2(symtab.intern("attr2a"), PQNotEqual, "one-a");
PQAttributeSelector pqas_neqb2(symtab.intern("attr2a"), PQNotEqual, "one-b");
cout << pqas_eqa.evaluate(one) << endl ; // 1
cout << pqas_eqa.evaluate(two) << endl ; // 0
cout << pqas_eqb.evaluate(one) << endl ; // 0
cout << pqas_eqb.evaluate(two) << endl ; // 0
cout << pqas_neqa.evaluate(one) << endl ; // 0
cout << pqas_neqa.evaluate(two) << endl ; // 1
cout << pqas_neqb.evaluate(one) << endl ; // 1
cout << pqas_neqb.evaluate(two) << endl ; // 1
cout << pqas_eqa2.evaluate(one) << endl ; // 0
cout << pqas_eqa2.evaluate(two) << endl ; // 0
cout << pqas_eqb2.evaluate(one) << endl ; // 0
cout << pqas_eqb2.evaluate(two) << endl ; // 0
cout << pqas_neqa2.evaluate(one) << endl ; // 1
cout << pqas_neqa2.evaluate(two) << endl ; // 1
cout << pqas_neqb2.evaluate(one) << endl ; // 1
cout << pqas_neqb2.evaluate(two) << endl ; // 1
cout << "****" << endl;
// ///////////////////////////////////////////////////////////////////////
// composite
// ///////////////////////////////////////////////////////////////////////
// position = 1 and attr(attr1a) == "one-a"
PQPosition *p1 = new PQPosition(PQEqual, 1);
PQAttributeSelector *a1 = new PQAttributeSelector(symtab.intern("attr1a"),
PQEqual, "one-a");
PQAttributeSelector *a2 = new PQAttributeSelector(symtab.intern("attr1a"),
PQEqual, "value");
PQLogExpr l1 (p1, PQand, a1);
PQLogExpr l2 (p1, PQor, a1);
PQLogExpr l3 (p1, PQand, a2);
PQLogExpr l4 (p1, PQor, a2);
cout << l1.evaluate(one) << endl ; // 1
cout << l1.evaluate(two) << endl ; // 0
cout << l2.evaluate(one) << endl ; // 1
cout << l2.evaluate(two) << endl ; // 0
cout << l3.evaluate(one) << endl ; // 0
cout << l3.evaluate(two) << endl ; // 0
cout << l4.evaluate(one) << endl ; // 1
cout << l4.evaluate(two) << endl ; // 0
cout << "..." << endl;
cout << PQNot(&l4).evaluate(one) << endl ; // 0
cout << PQNot(&l4).evaluate(two) << endl ; // 1
}

View File

@@ -1,39 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: ParserConst.h /main/3 1996/06/11 17:07:41 cde-hal $ */
#ifndef _parsar_const_h
#define _parsar_const_h 1
#define EQUAL 0
#define NOT_EQUAL 1
#define LESS_OR_EQUAL 0
#define LESS 1
#define GREATER_OR_EQUAL 2
#define GREATER 3
#define PARSER_TRUE 0
#define PARSER_FALSE 1
#endif

View File

@@ -1,189 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: PathQualifier.cc /main/4 1996/06/11 17:07:46 cde-hal $
#include "PathQualifier.h"
#include "Element.h"
#include "Attribute.h"
#include "Debug.h"
PQExpr::~PQExpr()
{
// empty
}
PQAttributeSelector::~PQAttributeSelector()
{
// empty
}
PQLogExpr::~PQLogExpr()
{
delete f_left ;
delete f_right ;
}
PQNot::PQNot(PQExpr *expr)
: f_expr(expr)
{
}
PQNot::~PQNot()
{
delete f_expr;
}
PQBoolean
PQNot::evaluate(const Element &element)
{
return (f_expr->evaluate(element) == PQTrue) ? PQFalse : PQTrue ;
}
PQPosition::PQPosition(PQEqOp optype, int position)
: f_optype(optype),
f_position(position)
{
}
PQBoolean
PQPosition::evaluate(const Element &element)
{
switch ( f_optype ) {
case PQEqual:
if ( f_position == (int) element.sibling_number() ||
( f_position==-1 && element.last_child() )
)
return PQTrue;
else
return PQFalse;
break;
default:
if ( f_position==-1 ) {
if ( element.last_child() == 0 )
return PQTrue;
else
return PQFalse;
} else
if ( f_position != (int) element.sibling_number() )
return PQTrue;
else
return PQFalse;
break;
}
}
PQSibling::PQSibling(PQEqOp optype, int sib)
: f_optype(optype),
f_sibling(sib)
{
}
PQBoolean
PQSibling::evaluate(const Element &element)
{
switch ( f_optype ) {
case PQEqual:
if ( f_sibling == (int) element.relative_sibling_number() ||
( f_sibling ==-1 && element.relatively_last_child() )
)
return PQTrue;
else
return PQFalse;
break;
default:
if ( f_sibling ==-1 ) {
if ( element.relatively_last_child() == 0 )
return PQTrue;
else
return PQFalse;
} else
if ( f_sibling != (int) element.relative_sibling_number() )
return PQTrue;
else
return PQFalse;
break;
}
}
PQAttributeSelector::PQAttributeSelector(const Symbol &attrname,
PQEqOp op,
const CC_String &string)
: f_optype(op),
f_attribute(attrname),
f_string(string)
{
debug(cerr, op);
}
PQBoolean
PQAttributeSelector::evaluate(const Element &element)
{
PQBoolean return_value = PQFalse ;
// see if attribute exists first
const Attribute *attr = element.get_attribute(f_attribute);
if (attr)
{
// comparison value of 0 means strings are equal
int comparison = f_string.compareTo(attr->value());
if (((f_optype == PQEqual) && (comparison == 0)) ||
((f_optype == PQNotEqual) && (comparison != 0)))
{
return_value = PQTrue ;
}
}
else
{
// not attribute, but if operator is not equal, we should return true
if (f_optype == PQNotEqual)
return_value = PQTrue ;
}
return return_value ;
}
PQLogExpr::PQLogExpr(PQExpr *left, PQLogOp op, PQExpr *right)
: f_optype(op),
f_left(left),
f_right(right)
{
}
PQBoolean
PQLogExpr::evaluate(const Element &element)
{
PQBoolean left_value = f_left->evaluate(element);
if ((left_value == PQTrue) && (f_optype == PQor))
return PQTrue ;
if ((left_value == PQFalse) && (f_optype == PQand))
return PQFalse ;
return f_right->evaluate(element);
}

View File

@@ -1,126 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: PathQualifier.h /main/5 1996/08/21 15:50:33 drk $ */
#ifndef _PathQualifier_h
#define _PathQualifier_h
#ifndef CDE_NEXT
#else
#include "dti_cc/CC_String.h"
#endif
#include "SymTab.h"
// PathEXPR = PathTERM | PathTERM log PathTERM
// PathTERM = position | attribute-selector
// position = posn eqop number
// attribute-selector = attribute eqop string
// log = and | or
class Element;
class Symbol ;
enum PQEqOp { PQEqual, PQNotEqual };
enum PQBoolean { PQFalse, PQTrue };
enum PQLogOp { PQand, PQor };
class PQExpr
{
public:
virtual ~PQExpr();
virtual PQBoolean evaluate(const Element &) = 0;
};
class PQNot : public PQExpr
{
public:
PQNot(PQExpr *);
~PQNot();
virtual PQBoolean evaluate(const Element &);
private:
PQExpr *f_expr;
};
class PQPosition : public PQExpr
{
public:
PQPosition(PQEqOp optype, int position);
virtual PQBoolean evaluate(const Element &);
private:
PQEqOp f_optype;
int f_position ;
};
class PQSibling: public PQExpr
{
public:
PQSibling(PQEqOp optype, int sibling);
virtual PQBoolean evaluate(const Element &);
private:
PQEqOp f_optype;
int f_sibling;
};
class PQAttributeSelector : public PQExpr
{
public:
PQAttributeSelector(const Symbol &attrname, PQEqOp, const CC_String &string);
~PQAttributeSelector();
virtual PQBoolean evaluate(const Element &);
private:
PQEqOp f_optype ;
Symbol f_attribute;
CC_String f_string ;
};
class PQLogExpr : public PQExpr
{
public:
PQLogExpr(PQExpr *left, PQLogOp op, PQExpr *right);
~PQLogExpr();
virtual PQBoolean evaluate(const Element &);
private:
PQLogOp f_optype ;
PQExpr *f_left ;
PQExpr *f_right ;
};
#endif /* _PathQualifier_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,605 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: PathTable.cc /main/4 1996/06/11 17:07:57 cde-hal $
#include "PathTable.h"
#include "Debug.h"
#include "Feature.h"
#include "utility/debug.h"
extern SymbolTable* gElemSymTab;
unsigned int letterHash(const LetterType& x)
{
return x;
}
EncodedPath::~EncodedPath()
{
delete [] f_array ;
f_SVectors.clearAndDestroy();
delete f_copyOfS;
}
EncodedPath::EncodedPath(SSPath* p, unsigned int asPattern) :
f_size(p -> entries()), f_patternSize(0), f_SVectors(letterHash),
f_wildCard(gElemSymTab -> wildCardId()),
f_unlimitedWildCard(gElemSymTab -> unlimitedWildCardId()),
f_copyOfS(new BitVector(WORD_SIZE, 0))
{
f_array = new LetterType[f_size];
CC_TPtrDlistIterator<PathTerm> l_pathIter(*p);
BitVector *l_bv = 0;
int i = 0;
while (++l_pathIter) {
//
// Count pattern size, excluding "*".
//
f_array[i] = (LetterType)((l_pathIter.key() -> symbol()).id());
if ( f_array[i] != f_unlimitedWildCard )
f_patternSize++;
i++;
}
if ( asPattern == true ) {
//
// Compute the S arrays.
// Examples pat = a b a c
// S(a) = 1 0 1 0
// S(b) = 0 0 0 0
// S(c) = 0 0 0 1
//
// pat = a ? a c
// S(a) = 1 1 1 0
// S(c) = 0 1 0 1
// S(?) = 0 1 0 0
//
// pat = a * a c
// S(a) = 1 1 0
// S(c) = 0 0 1
// S(*) = 1 0 0
//
l_pathIter.reset();
int j = patternLength()-1;
LetterType l_id;
// i records each PathTerm position in the list
int i=0;
while (++l_pathIter) {
l_id = (LetterType)((l_pathIter.key() -> symbol()).id());
l_bv = f_SVectors.findValue(&l_id);
if ( l_bv == 0 ) {
l_bv = new BitVector(patternLength(), 0);
f_SVectors.insertKeyAndValue(new LetterType(l_id), l_bv);
}
///////////////////////////////////////////////////
// reverse the order in the bit vector:
// MSB position ==> set LSB bit in the bit vector
///////////////////////////////////////////////////
if ( l_id != f_unlimitedWildCard ) {
l_bv -> setBitTo(j, 1);
//////////////////////////////////////////////////
// only set position when an expr is attatched
// to the term
//////////////////////////////////////////////////
if ( l_pathIter.key() -> pqexpr() && l_id != f_wildCard ) {
/*
MESSAGE(cerr, "==========");
debug(cerr, (void*)l_bv);
debug(cerr, *l_bv);
debug(cerr, i);
debug(cerr, j);
*/
l_bv -> recordPositions(i, j);
}
j--;
} else {
///////////////////////////////////////////////////
// do not set bits for unlimitedWildCards that
// begin or end the pattern
///////////////////////////////////////////////////
if ( j < patternLength() - 1 )
l_bv -> setBitTo(j+1, 1);
}
i++;
}
///////////////////////////////////////////////////
// special treatment to the ? symbols:
// OR S(?) back to each S's.
///////////////////////////////////////////////////
BitVector* l_BitVectorWildCard = f_SVectors.findValue(&f_wildCard);
hashTableIterator<LetterType, BitVector> l_SVIter(f_SVectors);
if ( l_BitVectorWildCard ) {
while (++l_SVIter) {
if ( *l_SVIter.key() != f_wildCard &&
*l_SVIter.key() != f_unlimitedWildCard
)
{
(*l_SVIter.value()) |= (*l_BitVectorWildCard);
}
}
}
/*
#ifdef DEBUG
l_SVIter.reset();
while (++l_SVIter) {
debug(cerr, (*l_SVIter.key()));
debug(cerr, (*l_SVIter.value()));
}
#endif
*/
}
}
unsigned int
_match(LetterType* pattern, int n,
LetterType* text, int m,
LetterType wildCard,
LetterType unlimitedWildCard
)
{
// A naive (brute force) string matching algorithm that handles
// wild card (?) and unlimited wild card (*) symbols.
unsigned int findMisMatch = false;
for ( int i=0; i<n; i++ ) { // over the "text" string
for ( int j=0; j<m; j++ ) { // over the pattern
if ( pattern[j] == wildCard ) {
continue;
} else
if ( pattern[j] == unlimitedWildCard ) {
for (;;) {
j++;
if ( j == m )
return true;
if ( pattern[j] != unlimitedWildCard )
break;
}
for ( int x=i+1; x<n; x++ ) {
if ( text[x] == pattern[j] )
if (
_match(
&pattern[j], m-j,
&text[x], n-x,
wildCard, unlimitedWildCard
) == true
)
return true;
}
} else {
if ( pattern[j] != text[i] ) {
findMisMatch = true;
break;
}
}
}
if ( findMisMatch == false )
return true;
}
return false;
}
unsigned int
EncodedPath::match(EncodedPath& text, SSPath* patternPath, SSPath* elementPath)
{
////////////////////////////////////////////////
// text: the encoded string for the element path
// elementPath: the element path
//
// this: the encoded string for the pattern string
// patternPath: the pattern path
////////////////////////////////////////////////
////////////////////////////////////////////////
// the unlimited wildcard vector
////////////////////////////////////////////////
BitVector* l_U = f_SVectors.findValue(&f_unlimitedWildCard);
if ( l_U && patternLength() == 0 )
return true;
////////////////////////////////////////////////
// the wildcard vector
////////////////////////////////////////////////
BitVector* l_W = f_SVectors.findValue(&f_wildCard);
// the S vector of each Letter, including that for '?'
BitVector* l_S = 0;
// the accumulated result vector
BitVector l_R(patternLength(), 0);
// placeholder for '*''s contribution
BitVector l_I(patternLength(), 0);
// hole position record of each path term in the pattern path
posRecord l_pr;
// expr pointer of each path term in the pattern path
PQExpr* expr = 0;
CC_TPtrDlistIterator<PathTerm>* elementPathNextPtr = 0;
if ( elementPath )
elementPathNextPtr = new CC_TPtrDlistIterator<PathTerm>(*elementPath);
// loop over text string
for ( int i=0; i<text.length(); i++) {
if ( elementPath )
++(*elementPathNextPtr);
//MESSAGE(cerr, "===================");
//debug(cerr, text.f_array[i]);
////////////////////////////////////////////////
// get this character's vector, including '?'s
////////////////////////////////////////////////
l_S = f_SVectors.findValue(&text.f_array[i]);
if ( l_S ) {
//debug(cerr, (void*)l_S);
//debug(cerr, *l_S);
//MESSAGE(cerr, "checking qualifies");
//////////////////////
// check qualifies.
//////////////////////
if ( patternPath && l_S -> positionArray() ) {
////////////////////
// get a copy of S
////////////////////
f_copyOfS -> setTo(*l_S);
//debug(cerr, *patternPath);
positionArrayIteratorT l_positionNext(*(l_S -> positionArray()));
while (++ l_positionNext) {
l_pr = l_positionNext.key();
//cerr << " calling patternPath -> fastGetAt(): " << (void*)patternPath << "l_pr.pathTermPos= " << l_pr.pathTermPos << endl;
expr = patternPath -> fastGetAt(l_pr.pathTermPos) -> pqexpr();
/*
debug(cerr, int(expr));
if ( expr ) {
MESSAGE(cerr, "qualify checking is needed.");
debug(cerr, *(elementPathNext -> key()));
}
*/
if ( expr &&
expr->evaluate(elementPathNextPtr->key()->element()) == PQFalse )
{
//MESSAGE(cerr, form("set position %d to 0", l_pr.bitPos));
f_copyOfS -> setBitTo(l_pr.bitPos, 0);
}
}
/////////////////////////////////////////
// make l_S point at its modified copy
/////////////////////////////////////////
l_S = f_copyOfS;
}
} else
l_S = l_W;
////////////////////////////////////////////////
// get unlimited wildcard's vector.
////////////////////////////////////////////////
if ( l_U ) {
l_I.setTo(l_R);
l_I &= (*l_U);
//MESSAGE(cerr, "l_I");
//debug(cerr, l_I);
}
////////////////////////////////////////////////
// shift the partial result vector right once
////////////////////////////////////////////////
l_R.shiftRightOneBit();
//MESSAGE(cerr, "after l_R >> 1");
//debug(cerr, l_R);
////////////////////////////////////////////////
// AND in this character's vector
////////////////////////////////////////////////
if ( l_S ) {
l_R &= (*l_S);
//debug(cerr, *l_S);
//MESSAGE(cerr, "after AND with l_S");
//debug(cerr, l_R);
} else {
///////////////////////////////////////////////
// this branch is impossible to reach.
///////////////////////////////////////////////
//MESSAGE(cerr, "l_R set all bits to 0");
l_R.setAllBitsTo(0);
}
///////////////////////////////////////////////
// OR in unlimited wild char's vector.
///////////////////////////////////////////////
if ( l_U ) {
l_R |= l_I;
//MESSAGE(cerr, "after OR with l_I");
//debug(cerr, l_R);
}
//debug(cerr, l_R);
//MESSAGE(cerr, "===================");
///////////////////////////////////////////////
// Use this test to get the first matched position
// if ( l_R.getBit(0) == 1 )
// return true;
///////////////////////////////////////////////
}
delete elementPathNextPtr;
///////////////////////////////////////////////
//
// the last symbol must match
//
///////////////////////////////////////////////
if ( l_R.getBit(0) == 1 )
return true;
else
return false;
}
basePathFeature::~basePathFeature()
{
delete f_path;
delete f_featureSet;
}
PathFeature::~PathFeature()
{
delete f_encodedPath ;
}
unsigned int basePathFeature::operator==(const basePathFeature& pf) const
{
cerr << "Warning: basePathFeature::operator==() called\n";
return true;
}
unsigned int PathFeature::operator==(const PathFeature& pf) const
{
cerr << "Warning: PathFeature::operator==() called\n";
return true;
}
void pathSelector(BitVector& bv)
{
}
unsigned int
PathFeature::match(SSPath& p)
{
EncodedPath l_ep(&p);
if ( f_path -> containSelector() == false )
return f_encodedPath -> match(l_ep, 0, 0);
else
return f_encodedPath -> match(l_ep, f_path, &p);
}
// /////////////////////////////////////////////////////////////////////////
//
// class PathTable
//
// /////////////////////////////////////////////////////////////////////////
unsigned symHashFunc(const Symbol& s)
{
return s.hash();
}
PathTable::PathTable()
: f_lastSymIndex(0),
f_lastSymIndexCount(0)
{
}
PathTable::~PathTable()
{
f_pathFeatureList.clearAndDestroy();
for (unsigned int i = 0 ; i < f_lastSymIndexCount; i++) {
//f_lastSymIndex[i].clearAndDestroy();
f_lastSymIndex[i] -> clear();
delete f_lastSymIndex[i];
}
delete f_lastSymIndex;
}
LetterType PathTable::findIndex(SSPath& p)
{
return (LetterType) ((p.last() -> symbol()).id());
}
void PathTable::initLastSymIndex()
{
f_lastSymIndexCount = gElemSymTab -> IdsAssigned()+1;
f_lastSymIndex = new CC_TPtrDlist_PathFeature_Ptr_T[f_lastSymIndexCount];
for (unsigned int i=0; i<f_lastSymIndexCount; i++)
f_lastSymIndex[i] = new CC_TPtrDlist<PathFeature>;
CC_TPtrDlistIterator<PathFeature> l_pfIter(f_pathFeatureList);
PathFeature* l_pathFeature = 0;
LetterType x;
while ( ++l_pfIter ) {
l_pathFeature = l_pfIter.key();
x = findIndex( *(l_pathFeature->path()) );
//f_lastSymIndex[x] -> prepend(l_pathFeature); // backward order
f_lastSymIndex[x] -> append(l_pathFeature); // select the matching rule
// in the same order rules
// appear in the
// stylesheet
}
}
FeatureSet* PathTable::getFeatureSet(SSPath& p)
{
if ( f_lastSymIndex == 0 ) {
initLastSymIndex();
}
int pids[3];
FeatureSet* fs[3];
fs[0] = getFeatureSet(findIndex(p), p, pids[0]);
fs[1] = getFeatureSet(gElemSymTab -> wildCardId(), p, pids[1]);
fs[2] = getFeatureSet(gElemSymTab -> unlimitedWildCardId(), p, pids[2]);
int index = 0;
int x = pids[0];
for ( int i=1; i<3; i++ ) {
if ( pids[i] > x )
index = i;
}
return fs[index];
}
FeatureSet*
PathTable::getFeatureSet(int bucketIndex, SSPath& p, int& pathId)
{
CC_TPtrDlistIterator<PathFeature> l_pathFeatureIter(*f_lastSymIndex[bucketIndex]);
l_pathFeatureIter.reset();
PathFeature* l_pathFeature = 0;
while ( ++l_pathFeatureIter ) {
l_pathFeature = l_pathFeatureIter.key();
//debug(cerr, *(l_pathFeature->path()));
//debug(cerr, *(l_pathFeature->featureSet()));
if ( l_pathFeature -> match(p) ) {
//MESSAGE(cerr, "match");
pathId = l_pathFeature -> id();
return l_pathFeature -> featureSet();
}
}
pathId = 0;
return 0;
}
void PathTable::addPathFeatureSet(PathFeature* x)
{
//MESSAGE(cerr, "addPathFeatureSet():");
//debug(cerr, *(x->path()));
//debug(cerr, *(x->featureSet()));
if ( x -> path() -> containSelector() )
x -> path() -> fastGetIndex();
EncodedPath* l_epath = new EncodedPath(x -> path(), true);
unsigned int id = f_pathFeatureList.entries()+1;
x -> setEncodedPath(l_epath);
x -> setID(id);
f_pathFeatureList.insert(x);
}
ostream& operator<<(ostream& out, PathTable& pt)
{
CC_TPtrDlistIterator<PathFeature> l_pfIter(pt.f_pathFeatureList);
PathFeature* l_pathFeature = 0;
while ( ++l_pfIter ) {
l_pathFeature = l_pfIter.key();
out << *(l_pathFeature)->path() << ' ' << *(l_pathFeature->featureSet())
<< endl;
#ifdef DEBUG
// this will cause errors if gTopOfStack is not set properly
FeatureSet *set = l_pathFeature->featureSet()->evaluate();
out << *set << endl;
delete set ;
#endif
}
return out;
}
void PathFeatureList::appendList(PathFeatureList& list)
{
PathFeatureListIterator l_Iter(list);
while ( ++ l_Iter ) {
append(l_Iter.key());
}
}
PathFeatureList::~PathFeatureList()
{
clearAndDestroy();
}

View File

@@ -1,176 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: PathTable.h /main/4 1996/08/21 15:50:37 drk $ */
#ifndef _PathTable_h
#define _PathTable_h
#ifndef CDE_NEXT
#else
#include "dti_cc/CC_Dlist.h"
#include "dti_cc/cc_hdict.h"
#endif
#include <sstream>
#include "Types.h"
#include "SymTab.h"
#include "SSPath.h"
#include "BitVector.h"
class Feature;
class FeatureSet;
#define OP_ONE "?"
#define OP_MANY "*"
typedef unsigned int LetterType;
class EncodedPath
{
int f_size;
int f_patternSize;
LetterType* f_array;
hashTable<LetterType, BitVector> f_SVectors;
LetterType f_wildCard;
LetterType f_unlimitedWildCard;
BitVector* f_copyOfS; // copy of S vector, used in match()
public:
EncodedPath(SSPath* p, unsigned int asPattern = false);
~EncodedPath();
int length() { return f_size; };
int patternLength() { return f_patternSize; };
unsigned int match(EncodedPath& p, SSPath* Pattern, SSPath* Elements);
}
;
class basePathFeature
{
protected:
SSPath* f_path;
FeatureSet* f_featureSet;
public:
basePathFeature(SSPath* p=0, FeatureSet* f=0):
f_path(p), f_featureSet(f) {};
~basePathFeature();
unsigned int operator==(const basePathFeature&) const;
SSPath* path() { return f_path; };
FeatureSet* featureSet() { return f_featureSet; };
void setPath(SSPath* p) { f_path = p; };
void setFeatureSet(FeatureSet* fs) { f_featureSet = fs; };
};
class PathFeature : public basePathFeature
{
unsigned int f_id;
EncodedPath* f_encodedPath;
public:
PathFeature(SSPath* p,FeatureSet* f,EncodedPath* e=0, unsigned int id=0):
basePathFeature(p, f), f_id(id), f_encodedPath(e) {};
~PathFeature();
EncodedPath* encodedPath() { return f_encodedPath; };
unsigned int id() { return f_id; };
void setEncodedPath(EncodedPath* e) { f_encodedPath = e; };
void setID(int x) { f_id = x; };
unsigned int operator==(const PathFeature&) const;
unsigned int match(SSPath& p);
};
class PathFeatureList : public CC_TPtrDlist<PathFeature>
{
public:
PathFeatureList() {};
virtual ~PathFeatureList();
void appendList(PathFeatureList&);
};
typedef CC_TPtrDlistIterator<PathFeature> PathFeatureListIterator;
// /////////////////////////////////////////////////////////////////////////
//
// class PathTable
//
// /////////////////////////////////////////////////////////////////////////
typedef CC_TPtrDlist<PathFeature>* CC_TPtrDlist_PathFeature_Ptr_T;
class PathTable
{
public:
PathTable();
~PathTable();
// add a path and associated raw feature set
// this should only be called by the style sheet parser to build this internal
// table
//
// Assume that the paths are passed in in left to right order. i.e.,
// in the order
// "TITLE SECTION"
// "TITLE CHAPTER"
// with the example shown above.
//
//void addPathFeatureSet(Path*, FeatureSet *rawFeatureSet);
void addPathFeatureSet(PathFeature*);
// returns a NULL value if no feature set is available at this point
// this "new"s a new feature set, and the caller is responsible for
// deleting the object
FeatureSet* getFeatureSet(SSPath&);
friend ostream& operator<<(ostream&, PathTable&);
private:
CC_TPtrDlist<PathFeature> f_pathFeatureList;
CC_TPtrDlist_PathFeature_Ptr_T *f_lastSymIndex;
unsigned int f_lastSymIndexCount ;
private:
void initLastSymIndex();
unsigned int findIndex(SSPath&);
FeatureSet* getFeatureSet(int bucketIndex, SSPath&, int& pathId);
};
extern PathTable* gPathTab;
#endif /* _PathTable_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,140 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: Renderer.h /main/3 1996/06/11 17:08:07 cde-hal $ */
#ifndef _Renderer_h
#define _Renderer_h 1
#include "Feature.h"
#include "dti_excs/Exceptions.hh"
/* **************************************************************
* class Renderer
the Renderer is responsible for taking the style sheet features
matched with an ELEMENT and using them to guide the drawing of the
ELEMENT data on the page
************************************************************** */
/* **************************************************************
The symbol table supplied is common to the Node Parser,
Style Sheet parser and the Renderer.
* ************************************************************** */
//class FeatureSet;
class Renderer : public Destructable
{
public:
Renderer() {};
virtual ~Renderer() {};
virtual FeatureSet *initialize() = 0; /* return default feature set */
/* -------- Begin Element -------- */
/* ************************************************************
* called when a new ELEMENT is found in the document
* FeatureSet is set of features and values that match with the
* ELEMENT as described in the style sheet
* ************************************************************ */
/* returns a non-zero value if element is to be ignored */
virtual unsigned int
BeginElement(const Element &element,
const FeatureSet &featureset,
const FeatureSet &complete,
const FeatureSet &parentComplete) = 0;
/* -------- Data -------- */
/* ************************************************************
* ELEMENT data passed in (usually text to be displayed)
* embedded ELEMENT children are passed in with BeginElement...
* ************************************************************ */
virtual void
data(const char *data, unsigned int size) = 0;
/* -------- End Element -------- */
/* ************************************************************
* End of ELEMENT processing (eg. postfixes, reset pointers etc.)
* ************************************************************ */
virtual void
EndElement(const Symbol &element_name) = 0 ;
/* ************************************************************
* Called BEFORE any data processing begins
* ************************************************************ */
virtual void Begin() = 0;
/* **************************************************************
* called after all data has been processed
* ************************************************************** */
virtual void End() = 0;
// These two functions allow a renderer to set up internal variable table.
/* **************************************************************
* pass a variable and a Expression to the renderer and let it decide
* whether to accept the variable and the Expression and put them into
* the internal variable table.
*
* non zero return value means that it has been entered into the internal
* table
*
* If gRenderer is set to null while style sheet is parsed, the
* accept() function will not be called from style.y.
* ************************************************************** */
virtual unsigned int accept(const char*, const Expression*) { return 0 ;}
/* ************************************************************
*
* evaluate the variable to a FeatureValue
*
* If gRenderer is set to null while the renderer is running, the
* evaluate() function will not be called.
* ************************************************************ */
virtual FeatureValue* evaluate(const char*) { return 0 ; }
/* **************************************************************
* notifies renderer that the local feature set will be evaluated.
* ************************************************************** */
virtual void preEvaluate(const Element &) {}
/* **************************************************************
* notifies renderer that the local feature set has been evaluated.
* ************************************************************** */
virtual void postEvaluate(const Element &) {}
protected:
};
#endif

View File

@@ -1,47 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: RendererHCV.cc /main/3 1996/06/11 17:08:12 cde-hal $
#include "RendererHCV.h"
RendererHCV::~RendererHCV()
{
f_autoNumberFP.clear();
}
FeatureValue* RendererHCV:: evaluate(const char* variable)
{
return f_autoNumberFP.evaluate(variable);
/*
FeatureValue* fv = f_autoNumberFP.evaluate(variable);
fv -> print(cerr);
return fv;
*/
}
unsigned int RendererHCV:: accept(const char* name, const Expression* expr)
{
return f_autoNumberFP.accept(name, expr);
}

View File

@@ -1,66 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: RendererHCV.h /main/3 1996/06/11 17:08:17 cde-hal $ */
#ifndef _RendererHCV_h
#define _RendererHCV_h 1
#include "Renderer.h"
#include "HardCopy/autoNumberFP.h"
// RendererHCV class is a simplified hardcopy renderer responsible
// for evaluating feature values specific to hardcopy engine. The
// feature values are used by the validator.
class RendererHCV : public Renderer
{
public:
RendererHCV() {};
~RendererHCV() ;
FeatureSet *initialize() { return 0; };
unsigned int
BeginElement(const Element &element,
const FeatureSet &featureset,
const FeatureSet &complete,
const FeatureSet &parentComplete) { return 0; };
void data(const char *data, unsigned int size) {} ;
void EndElement(const Symbol &element_name) {};
void Begin() {};
void End() {};
// These two functions allow a renderer to set up internal variable table.
unsigned int accept(const char*, const Expression*) ;
FeatureValue* evaluate(const char*) ;
void preEvaluate(const Element &) {};
void postEvaluate(const Element &) {};
protected:
autoNumberFP f_autoNumberFP;
};
#endif

View File

@@ -1,160 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: Resolver.C /main/5 1996/10/08 19:26:17 cde-hal $
#include "Debug.h"
#include "Resolver.h"
#include "ResolverStack.h"
#include "PathTable.h"
#include "Renderer.h"
#include "Element.h"
#include "Feature.h"
#include "HardCopy/autoNumberFP.h"
extern const Element *gCurrentElement ;
extern const FeatureSet *gCurrentLocalSet;
extern const FeatureSet *gParentCompleteSet;
Resolver::Resolver(PathTable& pTable, Renderer& r)
: f_pathTable(pTable),
f_Renderer(r),
f_resolverStack()
{
// have the Renderer install its default values as the bottom item on the
// Stack
FeatureSet *default_features = f_Renderer.initialize();
ResolverStackElement *default_element =
new ResolverStackElement(new Element(gSymTab->intern("!"),0 , 0, 0),
0,
default_features);
f_resolverStack.push(default_element);
}
Resolver::~Resolver()
{
}
void
Resolver::Begin()
{
// can do any node pre-processing here
f_Renderer.Begin();
}
void
Resolver::End()
{
// can do any node post-processing here
f_Renderer.End();
gAutoNumberFP.resetAllAutoNumbers();
}
unsigned int
Resolver::beginElement(Element *element)
{
//ON_DEBUG(element -> print(cerr));
// get raw feature set
f_path.append(new PathTerm(*element));
FeatureSet *rawLocalFeatureSet = f_pathTable.getFeatureSet(f_path);
// get parent details
ResolverStackElement* parent = f_resolverStack.top();
// qifc:
// when rawLocalFeatureSet != 0 to call f_Renderer.preEvaluate is
// too restrictive. Comment out
//
//if (rawLocalFeatureSet)
gAutoNumberFP.beginElement(*element);
FeatureSet *localFeatureSet = new FeatureSet;
gCurrentElement = element ;
gCurrentLocalSet = localFeatureSet ;
gParentCompleteSet = &parent->completeFeatureSet() ;
//ON_DEBUG(cerr << "Path: " << f_path << endl);
if (rawLocalFeatureSet)
{
// ON_DEBUG(cerr << "rawLocalFeatureSet: " << *rawLocalFeatureSet << endl);
localFeatureSet = rawLocalFeatureSet->evaluate(localFeatureSet);
// ON_DEBUG(cerr << "localFeatureSet: " << *localFeatureSet << endl);
}
// qifc:
// when rawLocalFeatureSet != 0 to call f_Renderer.postEvaluate is
// too restrictive. Comment out
//
//if (rawLocalFeatureSet)
// need to create a complete feature set for current element
// set is Sl U (Spc - Sl)
FeatureSet *completeFeatureSet = new
FeatureSet(parent->completeFeatureSet(),
*localFeatureSet);
// add current element to top of stack
f_resolverStack.push(
new ResolverStackElement(element,
localFeatureSet,
completeFeatureSet)
);
// tell renderer about new element
unsigned int ignore = f_Renderer.BeginElement(*element, *localFeatureSet,
*completeFeatureSet,
parent->completeFeatureSet());
if (ignore)
{
gAutoNumberFP.endElement(element->gi());
// clean up stack and path
delete f_resolverStack.pop();
delete f_path.removeLast();
}
return ignore;
}
void Resolver::data(const char* data, unsigned int data_length)
{
// pass through
f_Renderer.data(data, data_length);
}
void Resolver::endElement(const Symbol& s)
{
// NOTE: may want to pass top of stack to renderer for post element
// processing?
gAutoNumberFP.endElement(s);
f_Renderer.EndElement(s); // pass through
delete f_resolverStack.pop(); // pop stack
delete f_path.removeLast(); // remove item from path
}

View File

@@ -1,83 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: Resolver.h /main/4 1996/06/11 17:08:28 cde-hal $ */
#ifndef _Resolver_h
#define _Resolver_h
class Element;
class Symbol;
class FeatureSet;
class PathTable;
class Renderer;
class ResolverStack;
#include "SSPath.h"
#include "ResolverStack.h"
#include "dti_excs/Exceptions.hh"
/* **************************************************************
the Resolver is responsible for taking input from the NodeParser,
getting a feature set from the Style Sheet and passing it on to a
Renderer
- get Element input from NodeParser
- consult Style Sheet PathTable to get raw FeatureSet
- evaluate feature set to resolve variables and expressions
- merge with parent complete feature set to get complete feature
set
- pass data to Renderer (Element, localFeatures, completeFeatures)
* ************************************************************** */
class Resolver : public Destructable
{
public:
Resolver(PathTable& pTable, Renderer& r);
virtual ~Resolver();
// beginElement returns a non-zero value if element is to be ignored
unsigned int beginElement(Element*);
void data(const char* data, unsigned int data_length);
void endElement(const Symbol&);
// called before any data
virtual void Begin();
// called after all data
virtual void End();
private:
SSPath f_path ;
PathTable &f_pathTable;
// NOTE: this one could be a pointer so we can change them on the fly
Renderer &f_Renderer;
ResolverStack f_resolverStack;
};
#endif /* _Resolver_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,87 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: ResolverStack.cc /main/3 1996/06/11 17:08:33 cde-hal $
#include "ResolverStack.h"
#include "Element.h"
#include "Feature.h"
// we have the responsibility of deleting these guys
ResolverStackElement::ResolverStackElement(Element *element,
FeatureSet *local,
FeatureSet *complete)
: f_element(element),
f_localFeatureSet(local),
f_completeFeatureSet(complete)
{
}
ResolverStackElement::~ResolverStackElement()
{
delete f_element;
delete f_localFeatureSet;
delete f_completeFeatureSet ;
}
// required by CC_TPtrDlist
int
ResolverStackElement::operator==(const ResolverStackElement &stack_element)
{
return
stack_element.f_element == f_element &&
stack_element.f_localFeatureSet == f_localFeatureSet &&
stack_element.f_completeFeatureSet == f_completeFeatureSet ;
}
ResolverStack::ResolverStack()
: CC_TPtrDlist<ResolverStackElement>()
{
}
ResolverStack::~ResolverStack()
{
// delete all remaining items in stack
clearAndDestroy();
}
void
ResolverStack::push(ResolverStackElement *item)
{
prepend(item);
}
ResolverStackElement *
ResolverStack::top()
{
return first();
}
ResolverStackElement *
ResolverStack::pop()
{
return removeFirst();
}

View File

@@ -1,75 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: ResolverStack.h /main/4 1996/08/21 15:50:41 drk $ */
#ifndef _ResolverStack_h
#define _ResolverStack_h
#ifndef CDE_NEXT
#else
//#include <StyleSheet/cde_next.h>
#include "dti_cc/CC_Dlist.h"
#endif
class Element ;
class FeatureSet ;
class ResolverStackElement
{
public:
// note, this object will delete these items in its destructor
ResolverStackElement(Element*,
FeatureSet *local,
FeatureSet *complete);
~ResolverStackElement();
int
operator==(const ResolverStackElement &);
// only pass out references because we own these guys
FeatureSet &completeFeatureSet() { return *f_completeFeatureSet ; }
FeatureSet &localFeatureSet() { return *f_localFeatureSet ; }
Element &element() { return *f_element ; }
private:
Element *f_element;
FeatureSet *f_localFeatureSet;
FeatureSet *f_completeFeatureSet;
};
class ResolverStack : private CC_TPtrDlist<ResolverStackElement>
{
public:
ResolverStack();
~ResolverStack();
void push(ResolverStackElement*);
ResolverStackElement* pop();
ResolverStackElement* top();
};
#endif /* _ResolverStack_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,156 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $TOG: SSPath.C /main/5 1998/04/17 11:49:33 mgreess $
#ifndef CDE_NEXT
#else
#include "dti_cc/CC_Tokenizer.h"
#endif
#include "SSPath.h"
#include "Debug.h"
#include "SymTab.h"
#include "StyleSheetExceptions.h"
unsigned int GI_CASE_SENSITIVE = false;
PathTerm::PathTerm(const Element& element) :
f_element(element), f_PQExpr(0)
{
}
PathTerm::PathTerm(const Symbol& symbol, PQExpr* expr) :
f_element(symbol), f_PQExpr(expr)
{
}
PathTerm::PathTerm(const char* symbol, PQExpr* expr) :
f_element(gElemSymTab -> intern(symbol, true)), f_PQExpr(expr)
{
}
PathTerm::~PathTerm()
{
delete f_PQExpr;
}
unsigned int PathTerm::operator ==(const PathTerm&)
{
MESSAGE(cerr, "PathTerm::operator ==() should not be called");
throw(CASTBEEXCEPT badEvaluationException());
return 0;
}
ostream& operator <<(ostream& out, PathTerm& pt)
{
out << pt.symbol() << " (" << size_t(pt.f_PQExpr) << ") ";
return out;
}
////////////////////////////////////////////
//
////////////////////////////////////////////
void SSPath::appendPathTerm(PathTerm* pt)
{
if ( pt -> pqexpr() )
f_containPathQualifier = true;
append(pt);
}
void SSPath::prependPath(SSPath& p)
{
if ( p.entries() == 0 )
return;
CC_TPtrDlistIterator<PathTerm> l_Iter(p);
l_Iter += p.entries();
PathTerm* l_pathTerm = 0;
do {
//prepend(new PathTerm(*l_Iter.key()));
l_pathTerm = l_Iter.key();
prepend(l_pathTerm);
if ( l_pathTerm -> pqexpr() )
f_containPathQualifier = true;
} while ( --l_Iter );
}
SSPath::SSPath()
: f_containPathQualifier(false), f_fastGetIndex(0)
{
}
SSPath::~SSPath()
{
// clean up memory
clearAndDestroy();
delete f_fastGetIndex;
}
SSPath::SSPath(char* str, unsigned int AssignId) :
f_containPathQualifier(false), f_fastGetIndex(0)
{
CC_String a(str);
CC_Tokenizer next(a);
CC_String token;
#ifndef CDE_NEXT
while ( !(token=next()).isNull() ) {
append(new PathTerm(token.data(), 0));
}
#else
while ( next() ) {
append(new PathTerm(token.data(), 0));
}
#endif
}
ostream& operator<<(ostream& out, SSPath& p)
{
CC_TPtrDlistIterator<PathTerm> l_Iter(p);
while ( ++l_Iter ) {
out << *l_Iter.key() << ' ';
}
return out;
}
void SSPath::fastGetIndex()
{
f_fastGetIndex = new value_vector<PathTermPtr>(entries());
CC_TPtrDlistIterator<PathTerm> l_Iter(*this);
int i=0;
while ( ++l_Iter ) {
(*f_fastGetIndex)[i++] = l_Iter.key();
}
}

View File

@@ -1,102 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: SSPath.h /main/4 1996/08/21 15:50:49 drk $ */
#ifndef _Path_h
#define _Path_h
#include "SymTab.h"
#include "Element.h"
#include "PathQualifier.h"
#ifndef CDE_NEXT
#else
#include "dti_cc/CC_Dlist.h"
#include "dti_cc/cc_vvect.h"
#endif
// path term object class
// each term is made up of a SGMLGI and an optional
// expression.
class PathTerm
{
public:
PathTerm(const Element&);
PathTerm(const Symbol&, PQExpr* = 0);
PathTerm(const char* symbol, PQExpr* = 0);
~PathTerm();
unsigned int operator ==(const PathTerm&);
const Element& element() { return f_element; };
const Symbol& symbol() { return f_element.gi(); };
PQExpr* pqexpr() { return f_PQExpr; };
friend ostream& operator <<(ostream&, PathTerm&);
private:
const Element f_element;
PQExpr* f_PQExpr;
};
typedef PathTerm* PathTermPtr;
////////////////////////////////////////////
// path of path terms
////////////////////////////////////////////
class SSPath : public CC_TPtrDlist<PathTerm>
{
private:
unsigned int f_containPathQualifier;
value_vector<PathTermPtr>* f_fastGetIndex;
public:
SSPath(char*, unsigned int assignId); // for test purpose
SSPath();
virtual ~SSPath();
// this call update f_containPathQualifier field
void appendPathTerm(PathTerm*);
unsigned int containSelector() { return f_containPathQualifier; };
// prepend p to this. Elements in p are added to this.
void prependPath(SSPath& p);
// Set up an index so that the random access to elements in the list can
// be O(1). No range checking is performed.
// Set up the index by calling fastGetIndex() before any fastGetAt() call.
void fastGetIndex();
PathTerm* fastGetAt(unsigned int i) { return (*f_fastGetIndex)[i]; };
friend ostream& operator<< (ostream&, SSPath&);
};
typedef CC_TPtrDlist<char> charPtrDlist;
extern unsigned int gGI_CASE_SENSITIVE;
#endif /* _Path_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,150 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: SSTemplates.C /main/8 1996/10/09 15:29:50 rcs $
/*
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
#ifndef CDE_NEXT
//#include "StyleSheet/cde_next.h"
#endif
#include "Attribute.h"
#include "FeatureValue.h"
#include "AttributeList.h"
#include "SSPath.h"
#include "SymTab.h"
#include "BitVector.h"
#include "PathTable.h"
#include "Element.h"
#include "Expression.h"
#include "Resolver.h"
#include "Feature.h"
#include "ResolverStack.h"
#include "FeatureDefDictionary.h"
#ifdef CDE_NEXT
#include "dti_cc/cc_hdict.h"
#include "dti_cc/CC_Slist.h"
#include "dti_cc/CC_Dlist.h"
#include "dti_cc/cc_povec.h"
#include "dti_cc/cc_vvect.h"
#include "dti_cc/cc_pvect.h"
#endif
#ifdef BUILD_FEATURES
/* for features test program - jbm */
typedef Stack<FeatureSet*,dlist_array<FeatureSet> > _stack_fs_orvec_fs_;
#endif
//
// Update this field whenever an ID is assigned. - qifan
// the largest ID used in f's: 59
//
#if defined(sun) || defined(hpux)
typedef CC_TPtrSlist<Attribute> _f4_;
typedef CC_TPtrSlist<Feature> _f5_;
typedef CC_TPtrSlist<PathFeature> _f2_;
typedef CC_TPtrSlist<FeatureValue> _f55_;
typedef CC_TPtrSlist<FeatureDef> _f56_;
typedef CC_TPtrSlist<TypeValues> _f57_;
typedef CC_TPtrSlist<char> _f44_;
typedef CC_TPtrDlist<PathFeature> _f1_;
typedef CC_TPtrDlist<Symbol> _f6_;
typedef CC_TPtrDlist<ResolverStackElement> _f7_;
typedef CC_TPtrDlist<char> _f50_;
typedef hashTable<SymbolName, unsigned int> _f3_;
typedef hashTable<Symbol, Expression> _f8_;
typedef hashTable<unsigned int,BitVector> _f9_;
typedef hashTableIterator<SymbolName,unsigned int> _f13_;
typedef hashTableIterator<unsigned int,BitVector> _f21_;
typedef hashTableIterator<Symbol, Expression> _hash_dict_iter_sym_exp_;
typedef hashTableIterator<FeatureDef, FeatureDef> _f59_;
#ifndef CDE_NEXT
typedef CC_TPtrSlistDictionary<SymbolName,unsigned int> _f31_;
typedef CC_TPtrSlistDictionary<unsigned int,BitVector> _f32_;
typedef CC_TPtrSlistDictionary<Symbol,Expression> _f33_;
typedef CC_TPtrSlistDictionary<SymbolName,unsigned int> _f34_;
#endif
typedef dlist_array<CC_String> _ordvec_cstring_ ;
typedef CC_TValSlist<posRecord> _f54_;
typedef value_vector<PathTermPtr> _PathTermPtrvalue_vector_;
typedef pointer_vector<FeatureValue> _pointer_vector_FeatureValue_;
#endif
#if defined(_IBMR2)
#pragma define( CC_TPtrSlist<Attribute> )
#pragma define( CC_TPtrSlist<Feature> )
#pragma define( CC_TPtrSlist<PathFeature> )
#pragma define( CC_TPtrSlist<FeatureValue> )
#pragma define( CC_TPtrSlist<FeatureDef> )
#pragma define( CC_TPtrSlist<TypeValues> )
#pragma define( CC_TPtrSlist<char> )
#pragma define( CC_TPtrDlist<PathFeature> )
#pragma define( CC_TPtrDlist<Symbol> )
#pragma define( CC_TPtrDlist<ResolverStackElement> )
#pragma define( CC_TPtrDlist<char> )
#pragma define( hashTable<Symbol, Expression> )
#pragma define( hashTable<SymbolName, unsigned int> )
#pragma define( hashTable<unsigned int,BitVector> )
#pragma define( hashTableIterator<SymbolName,unsigned int> )
#pragma define( hashTableIterator<unsigned int,BitVector> )
#pragma define( hashTableIterator<Symbol, Expression> )
#pragma define( hashTableIterator<FeatureDef, FeatureDef> )
#ifndef CDE_NEXT
#pragma define( CC_TPtrSlistDictionary<SymbolName,unsigned int> )
#pragma define( CC_TPtrSlistDictionary<unsigned int,BitVector> )
#pragma define( CC_TPtrSlistDictionary<Symbol,Expression> )
#pragma define( CC_TPtrSlistDictionary<SymbolName,unsigned int> )
#endif
typedef dlist_array<CC_String> _ordvec_cstring_ ;
typedef CC_TValSlist<posRecord> _f54_;
typedef value_vector<PathTermPtr> _PathTermPtrvalue_vector_;
typedef pointer_vector<FeatureValue> _pointer_vector_FeatureValue_;
#pragma define( dlist_array<CC_String> )
#pragma define( CC_TValSlist<posRecord> )
#pragma define( value_vector<PathTermPtr> )
#pragma define( pointer_vector<FeatureValue> )
#endif

View File

@@ -1,64 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: StyleSheet.cc /main/3 1996/06/11 17:09:10 cde-hal $
#include "StyleSheet.h"
#include "Types.h"
#include "Feature.h"
PathTable* gPathTab;
VariableTable* gVariableTable;
SymbolTable* gSymTab;
SymbolTable* gElemSymTab;
unsigned int gGI_CASE_SENSITIVE;
const Element *gCurrentElement ;
const FeatureSet *gCurrentLocalSet;
const FeatureSet *gParentCompleteSet;
StyleSheet::StyleSheet(const char* nm)
: f_GI_CASE_SENSITIVE(false),
f_TopOfStack(0,new FeatureSet(),new FeatureSet())
{
if (nm==0) {
f_name = new char[1];
f_name[0] = 0;
} else
f_name = strdup(nm);
use();
}
StyleSheet::~StyleSheet()
{
delete f_name;
}
void
StyleSheet::use()
{
gSymTab = &f_SymTab;
gVariableTable = &f_VarTab;
gPathTab = &f_PathTab;
gElemSymTab = &f_ElemSymTab;
gGI_CASE_SENSITIVE = f_GI_CASE_SENSITIVE;
}

View File

@@ -1,56 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: StyleSheet.h /main/3 1996/06/11 17:09:16 cde-hal $ */
#ifndef _StyleSheet_h
#define _StyleSheet_h
#include "SymTab.h"
#include "VariableTable.h"
#include "PathTable.h"
#include "ResolverStack.h"
class StyleSheet
{
private:
SymbolTable f_SymTab;
VariableTable f_VarTab;
PathTable f_PathTab;
SymbolTable f_ElemSymTab;
unsigned int f_GI_CASE_SENSITIVE;
ResolverStackElement f_TopOfStack;
char* f_name;
public:
StyleSheet(const char* name = 0);
~StyleSheet();
const char* name() { return f_name; };
void use();
};
#endif /* _StyleSheet_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,31 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: StyleSheetExceptions.cc /main/3 1996/06/11 17:09:22 cde-hal $
#include "StyleSheetExceptions.h"
StyleSheetException::~StyleSheetException()
{
}
badEvaluationException::~badEvaluationException()
{
}

View File

@@ -1,142 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $TOG: StyleSheetExceptions.h /main/4 1998/04/17 11:49:51 mgreess $ */
#ifndef _StyleSheetExceptions_h
#define _StyleSheetExceptions_h
#include "dti_excs/Exceptions.hh"
#include "SymTab.h"
#define CASTEXCEPT
#define CASTBCEXCEPT
#define CASTBEEXCEPT
#define CASTDPEXCEPT
#define CASTDPUCEXCEPT
#define CASTDPUTEXCEPT
#define CASTDPUDEXCEPT
#define CASTDPUEEXCEPT
#define CASTSSEXCEPT
#define CASTSSSEEXCEPT
#define CASTUAEXCEPT
#define CASTUTEXCEPT
#define CASTUVEXCEPT
class StyleSheetException : public Exception
{
public:
DECLARE_EXCEPTION(StyleSheetException, Exception)
virtual ~StyleSheetException();
};
class StyleSheetSyntaxError : public StyleSheetException
{
public:
DECLARE_EXCEPTION(StyleSheetSyntaxError, StyleSheetException)
};
class badEvaluationException : public StyleSheetException
{
public:
DECLARE_EXCEPTION(badEvaluationException, StyleSheetException)
virtual ~badEvaluationException();
};
class badCastException : public StyleSheetException
{
public:
DECLARE_EXCEPTION(badCastException, StyleSheetException)
};
class undefinedVariableException : public badEvaluationException
{
public:
DECLARE_EXCEPTION(undefinedVariableException, badEvaluationException)
undefinedVariableException(const Symbol &v)
: badEvaluationException(),
f_variable_name(v)
{}
private:
Symbol f_variable_name;
};
class undefinedAttributeException : public badEvaluationException
{
public:
DECLARE_EXCEPTION(undefinedAttributeException, badEvaluationException)
undefinedAttributeException(const Symbol &a)
: badEvaluationException(),
f_attribute_name(a)
{}
private:
Symbol f_attribute_name;
};
class docParserException : public Exception
{
public:
DECLARE_EXCEPTION(docParserException, Exception)
};
class unknownTagException : public docParserException
{
public:
DECLARE_EXCEPTION(unknownTagException, docParserException)
};
class docParserUnexpectedCharacter : public docParserException
{
public:
DECLARE_EXCEPTION(docParserUnexpectedCharacter, docParserException)
};
class docParserUnexpectedTag : public docParserException
{
public:
DECLARE_EXCEPTION(docParserUnexpectedTag, docParserException)
};
class docParserUnexpectedData : public docParserException
{
public:
DECLARE_EXCEPTION(docParserUnexpectedData, docParserException)
};
class docParserUnexpectedEof : public docParserException
{
public:
DECLARE_EXCEPTION(docParserUnexpectedEof, docParserException)
};
#endif /* _StyleSheetExceptions_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,176 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: SymTab.cc /main/4 1996/06/11 17:09:34 cde-hal $
#include "SymTab.h"
SymbolName::SymbolName(const char *name)
: CC_String(name)
{
}
unsigned int SymbolName::operator==(const SymbolName &string)
{
return !compareTo(string, exact);
}
unsigned
SymbolTable::hashsym(const SymbolName &string)
{
return string.hash();
}
SymbolTable::SymbolTable()
: hashTable<SymbolName, unsigned int>(hashsym),
f_IDsAssigned(0)
{
f_wildCardId = intern("?", true).id();
f_unlimitedWildCardId = intern("*", true).id();
}
SymbolTable::~SymbolTable()
{
gSymTab = 0;
// cleanup after ourselves
clearAndDestroy();
}
const Symbol
SymbolTable::intern(const char *name, unsigned int assignId)
{
//cerr << "intern(): name =<" << name << "> " << "this=" << (void*)this << "\n";
SymbolName sym_name(name);
unsigned int *id;
const SymbolName *strptr = findKeyAndValue(&sym_name, id);
//cerr << "strptr =" << (void*)strptr << "\n";
if (!strptr)
{
SymbolName *newname = new SymbolName(name);
id = new unsigned int((assignId) ? ++f_IDsAssigned : 0);
insertKeyAndValue(newname, id);
strptr = newname;
}
/*
#ifdef DEBUG
{
hashTableIterator<SymbolName,unsigned int> next(*this);
cout << "intern(" << name << ")" << endl;
while (++next)
cout << "\tKey: " << *next.key() << "\tValue: " << *next.value() << endl;
}
#endif
*/
//cerr << "Final strptr used =" << (void*)strptr << "\n";
return Symbol(strptr, *id);
}
// /////////////////////////////////////////////////////////////////////////
// class Symbol
// /////////////////////////////////////////////////////////////////////////
Symbol::Symbol(const SymbolName *name, unsigned int x)
: f_name(name), f_id(x)
{
}
Symbol::Symbol(const Symbol &sym)
: f_name(sym.f_name), f_id(sym.f_id)
{
}
Symbol
Symbol::operator=(const Symbol &other)
{
f_name = other.f_name; return *this ;
}
const char *
Symbol::name() const
{
return *f_name ;
}
unsigned int
Symbol::operator==(const Symbol &sym) const
{
return sym.f_name == f_name ;
}
// /////////////////////////////////////////////////////////////////////////
// Printing
// /////////////////////////////////////////////////////////////////////////
ostream &operator<<(ostream &o, const Symbol &s)
{
return s.print(o);
}
ostream &operator<<(ostream &o, const SymbolTable &st)
{
return st.print(o);
}
ostream &
SymbolTable::print(ostream &o) const
{
hashTableIterator<SymbolName, unsigned int>
next(*(hashTable<SymbolName, unsigned int>*)this);
o << '<' << endl;
while(++next)
o << next.key() << endl;
o << '>' << endl;
return o ;
}
ostream &
Symbol::print(ostream &o) const
{
#ifdef DEBUG
f_name->print(o);
return o << '(' << id() << ')';
#else
return f_name -> print(o);
#endif
}
ostream &
SymbolName::print(ostream &o) const
{
return o << data();
}

View File

@@ -1,154 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: SymTab.h /main/5 1996/08/21 15:50:57 drk $ */
#ifndef _SymTab_h
#define _SymTab_h
#ifndef CDE_NEXT
#else
#include "dti_cc/CC_String.h"
#include "dti_cc/cc_hdict.h"
//#include "StyleSheet/cde_next.h"
#include <iostream>
using namespace std;
#endif
#include "Types.h"
/* **************************************************************
Creating a Symbol Table Class
Symbol Table has one user function, intern, which returns a
reference to a Symbol
A Symbol can be compared to other symbols using the == operator.
Symbols will only be == if they are the same symbol in the same
SymbolTable
* ************************************************************** */
// forward declarations
class Symbol;
/* -------- class SymbolName -------- */
// derived from CC_String to give a version of ==
// should be privately inherited with a few promotions
class SymbolName : public CC_String
{
public:
SymbolName(const char *);
unsigned int operator==(const SymbolName &);
ostream &print(ostream &) const ;
};
/* **************************************************************
SymbolTable derives privately from RWTPtrHashSet so only the
SymbolTable has access to internal operations
* ************************************************************** */
class SymbolTable : private hashTable<SymbolName, unsigned int>
{
public:
SymbolTable();
~SymbolTable();
// intern creates symbol if necessary
const Symbol intern(const char *name, unsigned int createId = false) ;
ostream &print(ostream &) const ;
unsigned int IdsAssigned() {
return f_IDsAssigned;
};
unsigned int wildCardId() { return f_wildCardId; };
unsigned int unlimitedWildCardId() { return f_unlimitedWildCardId; };
private:
static unsigned hashsym(const SymbolName &);
unsigned int f_wildCardId;
unsigned int f_unlimitedWildCardId;
unsigned int f_IDsAssigned;
};
/* **************************************************************
* class Symbol
* ************************************************************** */
class Symbol
{
public:
// constructor
Symbol(const Symbol &);
// assignment
Symbol operator=(const Symbol &other) ;
const char *name() const;
unsigned int operator==(const Symbol &) const; /* identity operator */
// some methods need to be public
ostream &print(ostream &) const ;
// for path table
unsigned int hash() const { return f_name->hash(); }
unsigned int id() const { return f_id; }
protected:
// alternate constructor
// only SymbolTable::intern can create these
Symbol(const SymbolName *name, unsigned int);
friend const Symbol SymbolTable::intern(const char *, unsigned int assignId);
private:
const SymbolName *f_name ; /* never delete this */
unsigned int f_id;
};
/* **************************************************************
* external declarations
* ************************************************************** */
ostream &operator<<(ostream &, const Symbol&);
ostream &operator<<(ostream &, const SymbolTable&);
#endif /* _SymTab_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,41 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: Types.h /main/3 1996/06/11 17:09:46 cde-hal $ */
#ifndef _Types_h
#define _Types_h
#define true 1
#define false 0
class VariableTable;
class SymbolTable;
class ResolverStackElement;
class Renderer;
extern VariableTable *gVariableTable;
extern SymbolTable *gSymTab;
extern SymbolTable *gElemSymTab;
extern Renderer *gRenderer;
#endif /* _Types_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,83 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: VariableTable.cc /main/3 1996/06/11 17:09:55 cde-hal $
//
#include "Types.h"
#include "VariableTable.h"
static unsigned shash(const Symbol& key)
{
return key.hash();
}
VariableTable::VariableTable()
: hashTable<Symbol,Expression>(shash)
{
}
VariableTable::~VariableTable()
{
clearAndDestroy();
}
unsigned int
VariableTable::exists(const Symbol &name) const
{
return contains(&name);
}
void
VariableTable::enter(const Symbol &name, Expression *value)
{
Expression *exp = findValue(&name);
if (exp)
{
Symbol *sym = remove(&name);
delete sym ;
delete exp ;
}
insertKeyAndValue(new Symbol(name), value);
}
const Expression &
VariableTable::lookup(const Symbol &name) const
{
return *findValue(&name);
}
ostream &
VariableTable::print(ostream &o) const
{
hashTableIterator<Symbol,Expression>
next(*(hashTable<Symbol,Expression>*)this); // cast to
// non-const
while (++next)
o << *next.key() << "\t" << *next.value() << endl;
return o << endl;
}
ostream &operator <<(ostream &o, const VariableTable &v)
{
return v.print(o);
}

View File

@@ -1,53 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: VariableTable.h /main/4 1996/08/21 15:51:00 drk $ */
#ifndef _VariableTable_h
#define _VariableTable_h
#include "SymTab.h"
#include "Expression.h"
#ifndef CDE_NEXT
#else
#include "dti_cc/cc_hdict.h"
#endif
class VariableTable : private hashTable<Symbol, Expression>
{
public:
VariableTable();
~VariableTable();
unsigned int exists(const Symbol &name) const;
void enter (const Symbol &name, Expression *value);
const Expression &lookup(const Symbol &name) const;
ostream &print(ostream &) const;
};
ostream &operator <<(ostream &o, const VariableTable &v);
#endif /* _VariableTable_h */
/* DO NOT ADD ANY LINES AFTER THIS #endif */

View File

@@ -1,227 +0,0 @@
/* $XConsortium: defParser.y /main/2 1996/11/11 11:51:02 drk $ */
%{
#include <stdio.h>
#include <ctype.h>
#include <sstream>
#include <iostream>
#include "Debug.h"
#include "FeatureDefDictionary.h"
#define alloca(x) (malloc(x))
def_list_t* g_def_list = 0;
extern void yyerror(char*);
extern int yylex();
#undef yywrap
%}
%union
{
unsigned char charData;
unsigned char* charPtrData;
int intData;
float realData;
FeatureValue* valueData;
defv_t* valueListPtrData;
TypeValues* typeValuesPtrData;
type_values_list_t* typeValuesListPtrData;
def_list_t* defListPtrData;
FeatureDef* defPtrData;
}
%token<charData>
STAR
COMMA
COLON
SEMI_COLON
FSOPEN
FSCLOSE
OPER_parenopen
OPER_parenclose
%token<intData>
INTEGER
%token<realData>
REAL
%token<charPtrData>
NORMAL_STRING
QUOTED_STRING
REF_NAME
TYPE
%type<charPtrData>
Name
%type<valueData>
Value
%type<valueListPtrData>
ValueList
ValueListOpt
%type<typeValuesPtrData>
TypeValues
%type<typeValuesListPtrData>
TypeValuesList
%type<defPtrData>
Def
DefReference
CompositeDef
WildCardDef
PrimitiveDef
%type<defListPtrData>
DefList
%start featureDef
%%
featureDef : DefList
{
g_def_list = $1;
}
;
DefList : DefList Def
{
$$=$1;
if ( $2 -> type() == FeatureDef::WILDCARD )
$$ -> prepend($2);
else
$$ -> append($2);
}
|
Def
{
$$=new def_list_t();
$$ -> append($1);
}
;
Def: CompositeDef
{
$$=$1;
}
| PrimitiveDef
{
$$=$1;
}
| DefReference
{
$$=$1;
}
| WildCardDef
{
$$=$1;
}
;
CompositeDef : Name FSOPEN DefList FSCLOSE
{
$$= new FeatureDefComposite((char*)$1, $3);
delete $1;
}
;
PrimitiveDef : Name COLON TypeValuesList SEMI_COLON
{
$$= new FeatureDefPrimitive((char*)$1, $3);
delete $1;
}
;
DefReference : Name SEMI_COLON
{
$$= new FeatureDefReference((char*)$1);
delete $1;
}
;
WildCardDef : STAR SEMI_COLON
{
$$= new FeatureDefWildCard("*");
}
;
Name : NORMAL_STRING
{
$$=$1;
}
;
TypeValuesList : TypeValuesList COMMA TypeValues
{
$$=$1;
$$ -> append($3);
}
| TypeValues
{
$$=new type_values_list_t();
$$ -> append($1);
}
;
TypeValues : TYPE OPER_parenopen ValueList OPER_parenclose
{
$$=new TypeValues((char*)$1, $3);
delete $1;
}
| TYPE
{
$$=new TypeValues((char*)$1, 0);
delete $1;
}
;
ValueList : ValueList COMMA Value
{
$1 -> append($3);
$$=$1;
}
| Value
{
$$ = new defv_t();
$$ -> append($1);
}
;
Value : INTEGER
{
$$=new FeatureValueInt($1);
}
| QUOTED_STRING
{
$$=new FeatureValueString((char*)$1);
delete $1;
}
| REAL
{
$$=new FeatureValueReal($1);
}
;
%%
/*
void yyerror(char *errorstr)
{
cerr << errorstr ;
}
*/

View File

@@ -1,218 +0,0 @@
%option noyywrap
%a 30000
%e 10000
%k 10000
%n 10000
%o 40000
%p 20000
%{
/* $XConsortium: defToken.l /main/5 1996/11/19 16:54:10 drk $ */
#include <string.h>
#include "FeatureDefDictionary.h"
#include "defParser.tab.h"
#include "Debug.h"
#include <iostream>
using namespace std;
extern istream *g_defParserin;
#define YY_INPUT(buf,result,max_size)\
{\
if (g_defParserin -> eof()) {\
result=0;\
} else {\
g_defParserin -> read((char *)buf, max_size-1); \
result = g_defParserin -> gcount(); \
buf[result] = 0; \
}\
}
unsigned char* defToken_string_buf = new unsigned char[1024];
int defToken_string_buf_size = 1024;
int defToken_string_buf_content_size = 0;
unsigned char* new_copy(const unsigned char* str, int size)
{
unsigned char* x = new unsigned char[ ( size <= 0 ) ? 1 : size + 1];
memcpy(x, str, size);
x[size] = 0;
return x;
}
void addToDefTokenStringBuf(const char* str, int size)
{
if ( size <= 0 ) return;
if ( defToken_string_buf_size - defToken_string_buf_content_size < size ) {
defToken_string_buf_size = 2*(size+defToken_string_buf_content_size);
unsigned char* x = new unsigned char[defToken_string_buf_size];
memcpy(x, defToken_string_buf, defToken_string_buf_content_size);
delete [] defToken_string_buf;
defToken_string_buf = x;
}
memcpy(defToken_string_buf + defToken_string_buf_content_size, str, size);
defToken_string_buf_content_size += size;
defToken_string_buf[defToken_string_buf_content_size] = 0;
}
%}
stringprefix ([Ss][Tt][Rr][Ii][Nn][Gg][_][Pp][Rr][Ee][Ff][Ii][Xx])
string ([Ss][Tt][Rr][Ii][Nn][Gg])
integer ([Ii][Nn][Tt][Ee][Gg][Ee][Rr])
array([Aa][Rr][Rr][Aa][Yy])
real ([Rr][Ee][Aa][Ll])
unit ([Dd][Ii][Mm][Ee][Nn][Ss][Ii][Oo][Nn])
unitpixel ([Dd][Ii][Mm][Ee][Nn][Ss][Ii][Oo][Nn][_][Pp][Ii][Xx][Ee][Ll])
boolean ([Bb][Oo][Oo][Ll][Ee][Aa][Nn])
%x quoted_string
%%
^"#".* {
}
"," {
return(COMMA);
}
"*" {
return(STAR);
}
";" {
return(SEMI_COLON);
}
":" {
return(COLON);
}
"{" {
return(FSOPEN);
}
"}" {
return(FSCLOSE);
}
"(" {
return(OPER_parenopen);
}
")" {
return(OPER_parenclose);
}
{stringprefix} {
defParserlval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
return(TYPE);
}
{string} {
defParserlval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
return(TYPE);
}
{integer} {
defParserlval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
return(TYPE);
}
{real} {
defParserlval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
return(TYPE);
}
{unit} {
defParserlval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
return(TYPE);
}
{unitpixel} {
defParserlval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
return(TYPE);
}
{array} {
defParserlval.charPtrData = new_copy((unsigned char*)yytext, yyleng);
return(TYPE);
}
{boolean} {
defParserlval.charPtrData =
new_copy((unsigned char*)"INTEGER", strlen("INTEGER"));
return(TYPE);
}
[0-9]+ {
defParserlval.intData = atoi((char*)yytext);
return(INTEGER);
}
[0-9]+"."[0-9]+ {
defParserlval.realData = atof((char*)yytext);
return(REAL);
}
\" {
BEGIN quoted_string;
}
<quoted_string>\" {
defParserlval.charPtrData =
new unsigned char[defToken_string_buf_content_size+1];
memcpy( defParserlval.charPtrData,
defToken_string_buf,
defToken_string_buf_content_size+1
);
defToken_string_buf_content_size = 0;
BEGIN 0;
return(QUOTED_STRING);
}
<quoted_string>. {
addToDefTokenStringBuf(yytext, yyleng);
}
"&"[^ \t\n\";.=@+*\/\.\*:?\^,{}\[\]()]+ {
defParserlval.charPtrData =
(unsigned char*)strdup((const char*)(yytext+1));
return(REF_NAME);
}
[^ \t\n\";.=@+*\/\.\*:?\^,{}\[\]()]+ {
defParserlval.charPtrData =
(unsigned char*)strdup((const char*)yytext);
return(NORMAL_STRING);
}
[\t] {
}
[\n] {
yylineno++;
}
. {
}
%%
void defParsererror(char* msg)
{
cerr << "line " << yylineno << ": " << msg;
}

View File

@@ -1,134 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: docparser.C /main/4 1996/08/21 15:51:05 drk $
#include "Debug.h"
#include "DocParser.h"
#include "Element.h"
#include "PathTable.h"
#include "Renderer.h"
#include "Resolver.h"
#include "StyleSheet.h"
#include "StyleSheetExceptions.h"
#include "VariableTable.h"
#include <iostream>
using namespace std;
Renderer *gRenderer = 0;
class TestRenderer : public Renderer
{
public:
// inherited virtuals
void Begin() {} ;
void End() {} ;
FeatureSet *initialize();
unsigned int BeginElement(const Element &element,
const FeatureSet &featureset,
const FeatureSet &complete,
const FeatureSet &parentComplete);
void data(const char *data, unsigned int size);
void EndElement(const Symbol &element_name);
};
FeatureSet *
TestRenderer::initialize()
{
return new FeatureSet;
}
unsigned int
TestRenderer::BeginElement(const Element &element,
const FeatureSet &localset,
const FeatureSet &complete,
const FeatureSet &/* parentComplete */)
{
ON_DEBUG(cerr << "TestRenderer::BeginElement()" << endl);
ON_DEBUG(cerr << localset<< endl);
ON_DEBUG(cerr << complete << endl);
if (localset.lookup(gSymTab->intern("ignore")))
return 1 ; // ignore
cout << element << endl;
return 0 ; // do not ignore
}
void
TestRenderer::data(const char * data, unsigned int /* size */)
{
ON_DEBUG(cerr << "TestRenderer::data()" << endl);
cout << data ;
}
void
TestRenderer::EndElement(const Symbol &name)
{
ON_DEBUG(cerr << "TestRenderer::EndElement(" << name << ')' << endl);
cout << "</" << name << '>';
}
void
styleerror(char *errorstr)
{
cerr << errorstr ;
}
// extern FILE *stylein;
extern int styleparse();
extern PathTable *gPathTab;
extern VariableTable *gVariableTable ;
extern istream *g_stylein;
main(int argc, char **argv)
{
INIT_EXCEPTIONS();
StyleSheet ss ;
ifstream stylestream(argv[1]);
g_stylein = &stylestream;
g_stylein->unsetf(ios::skipws);
styleparse();
try
{
TestRenderer renderer ;
Resolver resolver(*gPathTab, renderer);
DocParser docparser(resolver);
docparser.parse(cin);
}
catch_any()
{
cerr << "docparser.C: exception thrown" << endl;
rethrow;
}
end_try;
cout << endl;
exit (0);
}

View File

@@ -1,421 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: evaluate.cc /main/3 1996/06/11 17:10:18 cde-hal $
#include "Types.h"
#include "Expression.h"
#include "Feature.h"
#include "FeatureValue.h"
#include "ResolverStack.h"
#include "StyleSheet.h"
#include "StyleSheetExceptions.h"
#include "SymTab.h"
#include "VariableTable.h"
extern const Element *gCurrentElement ;
extern const FeatureSet *gCurrentLocalSet;
extern const FeatureSet *gParentCompleteSet;
// unused except by HardCopy
Renderer *gRenderer = 0 ;
void
styleerror(char *errorstr)
{
cerr << "Parse Error: " << errorstr << endl;
}
main(int argc, char **argv)
{
INIT_EXCEPTIONS();
StyleSheet ss;
FeatureSet fs;
FeatureValue *exp ;
/* -------- String -------- */
fs.add(new Feature(gSymTab->intern("string"),
new FeatureValueString("this is a string")));
/* -------- Symbol -------- */
fs.add(new Feature(gSymTab->intern("symbol"),
new FeatureValueSymbol(gSymTab->intern("Symbol"))));
/* -------- Integer -------- */
fs.add(new Feature(gSymTab->intern("int"),
new FeatureValueInt(17)));
/* -------- Real -------- */
fs.add(new Feature(gSymTab->intern("real"),
new FeatureValueReal(42.2)));
/* -------- Integer addition -------- */
exp = new FeatureValueExpression
(new Expression(new BinaryOperatorNode(BinaryOperatorNode::PLUS,
new ConstantNode(new FeatureValueInt(10)),
new ConstantNode(new FeatureValueInt(10)))));
// check cloning
FeatureValueExpression ep(*(FeatureValueExpression*)exp);
fs.add(new Feature(gSymTab->intern("int + int"), exp));
/* -------- Integer subtraction -------- */
exp = new FeatureValueExpression
(new Expression(new BinaryOperatorNode(BinaryOperatorNode::MINUS,
new ConstantNode(new FeatureValueInt(3)),
new ConstantNode(new FeatureValueInt(127)))));
fs.add(new Feature(gSymTab->intern("int - int"), exp));
/* -------- Integer division -------- */
exp = new FeatureValueExpression
(new Expression(new BinaryOperatorNode(BinaryOperatorNode::DIVIDE,
new ConstantNode(new FeatureValueInt(10)),
new ConstantNode(new FeatureValueInt(2)))));
fs.add(new Feature(gSymTab->intern("int / int"), exp));
/* -------- Real division -------- */
exp = new FeatureValueExpression
(new Expression(new BinaryOperatorNode(BinaryOperatorNode::DIVIDE,
new ConstantNode(new FeatureValueReal(5)),
new ConstantNode(new FeatureValueReal(2)))));
fs.add(new Feature(gSymTab->intern("real / real"), exp));
/* -------- Real multiplication -------- */
exp = new FeatureValueExpression
(new Expression(new BinaryOperatorNode(BinaryOperatorNode::TIMES,
new ConstantNode(new FeatureValueReal(5.1)),
new ConstantNode(new FeatureValueReal(8.7)))));
fs.add(new Feature(gSymTab->intern("real * real"), exp));
/* -------- int + real -------- */
exp = new FeatureValueExpression
(new Expression(new BinaryOperatorNode(BinaryOperatorNode::PLUS,
new ConstantNode(new FeatureValueInt(5)),
new ConstantNode(new FeatureValueReal(8.7)))));
fs.add(new Feature(gSymTab->intern("int + real"), exp));
/* -------- real + int -------- */
exp = new FeatureValueExpression
(new Expression(new BinaryOperatorNode(BinaryOperatorNode::PLUS,
new ConstantNode(new FeatureValueReal(8.7)),
new ConstantNode(new FeatureValueInt(5)))));
fs.add(new Feature(gSymTab->intern("real + int"), exp));
/* -------- now do some variable stuff -------- */
// empty top of stack item
// gTopOfStack = new ResolverStackElement(0,new FeatureSet(),new FeatureSet());
FeatureSet *localSet = new FeatureSet ;
gCurrentElement = 0 ;
gCurrentLocalSet = localSet ;
gParentCompleteSet = new FeatureSet ;
// add an element for variable lookup
localSet->add(new Feature(gSymTab->intern("size"),
new FeatureValueInt(10)));
// make some variable entries
// insert a duplicate to check memory leaks
gVariableTable->enter(gSymTab->intern("DEFAULT_FONT_FAMILY"),
new Expression(new ConstantNode(new FeatureValueString("courier"))));
gVariableTable->enter(gSymTab->intern("DEFAULT_FONT_FAMILY"),
new Expression(new ConstantNode(new FeatureValueString("helvetica"))));
fs.add(new Feature(gSymTab->intern("exp"),
new FeatureValueExpression
(new Expression (new VariableNode(gSymTab->intern("DEFAULT_FONT_FAMILY"))))));
CompositeVariableNode *cvn = new CompositeVariableNode;
cvn->appendItem(gSymTab->intern("size"));
fs.add(new Feature(gSymTab->intern("Xsize"),
new FeatureValueExpression(new Expression (cvn))));
/* -------- dimensions -------- */
fs.add(new Feature(gSymTab->intern("dim"),
new FeatureValueDimension(new FeatureValueInt(10),
FeatureValueDimension::INCH)));
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::PLUS,
new ConstantNode(new FeatureValueInt(5)),
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(25),
FeatureValueDimension::INCH)))));
fs.add(new Feature(gSymTab->intern("int + dim"), exp));
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::PLUS,
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(25),
FeatureValueDimension::INCH)),
new ConstantNode(new FeatureValueInt(5)))));
fs.add(new Feature(gSymTab->intern("dim + int"), exp));
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::PLUS,
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(25),
FeatureValueDimension::POINT)),
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(5),
FeatureValueDimension::INCH)))));
fs.add(new Feature(gSymTab->intern("dim + dim"), exp));
/* -------- real * dim -------- */
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::TIMES,
new ConstantNode
(new FeatureValueReal(2.2)),
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(11),
FeatureValueDimension::POINT)))));
fs.add(new Feature(gSymTab->intern("real * dim"), exp));
/* -------- dim * real -------- */
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::TIMES,
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(11),
FeatureValueDimension::POINT)),
new ConstantNode
(new FeatureValueReal(2.1)))));
fs.add(new Feature(gSymTab->intern("dim * real"), exp));
/* -------- dim / real -------- */
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::DIVIDE,
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(11),
FeatureValueDimension::POINT)),
new ConstantNode
(new FeatureValueReal(2.0)))));
fs.add(new Feature(gSymTab->intern("dim / real"), exp));
/* -------- real / dim -------- */
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::DIVIDE,
new ConstantNode
(new FeatureValueReal(11)),
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(2),
FeatureValueDimension::POINT)))));
fs.add(new Feature(gSymTab->intern("real / dim"), exp));
/* -------- dim * int -------- */
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::TIMES,
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(11),
FeatureValueDimension::POINT)),
new ConstantNode
(new FeatureValueInt(2)))));
fs.add(new Feature(gSymTab->intern("dim * int"), exp));
/* -------- int * dim -------- */
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::TIMES,
new ConstantNode
(new FeatureValueInt(2)),
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(11),
FeatureValueDimension::POINT)))));
fs.add(new Feature(gSymTab->intern("int * dim"), exp));
/* -------- dim / int -------- */
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::DIVIDE,
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(11),
FeatureValueDimension::POINT)),
new ConstantNode
(new FeatureValueInt(2)))));
fs.add(new Feature(gSymTab->intern("dim / int"), exp));
/* -------- int / dim -------- */
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::DIVIDE,
new ConstantNode
(new FeatureValueInt(22)),
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(11),
FeatureValueDimension::POINT)))));
fs.add(new Feature(gSymTab->intern("int / dim"), exp));
/* -------- int - dim -------- */
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::MINUS,
new ConstantNode
(new FeatureValueInt(2)),
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(11),
FeatureValueDimension::POINT)))));
fs.add(new Feature(gSymTab->intern("int - dim"), exp));
/* -------- dim - int -------- */
exp = new FeatureValueExpression
(new Expression
(new BinaryOperatorNode(BinaryOperatorNode::MINUS,
new ConstantNode
(new FeatureValueDimension
(new FeatureValueInt(11),
FeatureValueDimension::POINT)),
new ConstantNode
(new FeatureValueInt(2)))));
fs.add(new Feature(gSymTab->intern("dim - int"), exp));
/* -------- String + String -------- */
exp = new FeatureValueExpression
(new Expression(new BinaryOperatorNode(BinaryOperatorNode::PLUS,
new ConstantNode(new FeatureValueString("foo")),
new ConstantNode(new FeatureValueString("bar")))));
fs.add(new Feature(gSymTab->intern("String + String"), exp));
/* -------- String + String + String-------- */
FeatureValueExpression *exp1 =
new FeatureValueExpression
(new Expression(new BinaryOperatorNode(BinaryOperatorNode::PLUS,
new ConstantNode(new FeatureValueString("foo")),
new ConstantNode(new FeatureValueString("bar")))));
exp = new FeatureValueExpression
(new Expression(new BinaryOperatorNode(BinaryOperatorNode::PLUS,
new ConstantNode(exp1),
new ConstantNode(new FeatureValueString("baz")))));
fs.add(new Feature(gSymTab->intern("String + String + String"), exp));
/* -------- print out our set -------- */
cout << fs << endl;
FeatureSet *evaluated = fs.evaluate();
cout << *evaluated << endl;
delete evaluated ;
cout << *gVariableTable << endl;
// write this guy out that we created at the top
cout << ep << endl;
delete gCurrentLocalSet ;
delete gParentCompleteSet ;
FeatureValueDimension *dtest =
new FeatureValueDimension
(new FeatureValueDimension(new FeatureValueInt(72),
FeatureValue::POINT),
FeatureValue::INCH);
cout << *dtest << endl;
cout << (float)*dtest << endl;
delete dtest ;
}

View File

@@ -1,66 +0,0 @@
{
string: "this is a string"
symbol: Symbol
int: 17
real: 42.2
int + int: (10 + 10)
int - int: (3 - 127)
int / int: (10 / 2)
real / real: (5 / 2)
real * real: (5.1 * 8.7)
int + real: (5 + 8.7)
real + int: (8.7 + 5)
exp: DEFAULT_FONT_FAMILY
Xsize: size
dim: <10 inch>
int + dim: (5 + <25 inch>)
dim + int: (<25 inch> + 5)
dim + dim: (<25 point> + <5 inch>)
real * dim: (2.2 * <11 point>)
dim * real: (<11 point> * 2.1)
dim / real: (<11 point> / 2)
real / dim: (11 / <2 point>)
dim * int: (<11 point> * 2)
int * dim: (2 * <11 point>)
dim / int: (<11 point> / 2)
int / dim: (22 / <11 point>)
int - dim: (2 - <11 point>)
dim - int: (<11 point> - 2)
}
{
string: "this is a string"
symbol: Symbol
int: 17
real: 42.2
int + int: 20
int - int: -124
int / int: 5
real / real: 2.5
real * real: 44.37
int + real: 13.7
real + int: 13.7
exp: "helvetica"
Xsize: 10
dim: <10 inch>
int + dim: <30 inch>
dim + int: <30 inch>
dim + dim: <5.34722 inch>
real * dim: <24.2 point>
dim * real: <23.1 point>
dim / real: <5.5 point>
real / dim: <5.5 point>
dim * int: <22 point>
int * dim: <22 point>
dim / int: <5.5 point>
int / dim: <2 point>
int - dim: <-9 point>
dim - int: <9 point>
}
DEFAULT_FONT_FAMILY "helvetica"
(10 + 10)
<<72 point> inch>
1

View File

@@ -1,156 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: feature.cc /main/3 1996/06/11 17:10:23 cde-hal $
#include "StyleSheetExceptions.h"
#include "SymTab.h"
#include "Feature.h"
#include "FeatureValue.h"
#include "StyleSheet.h"
#include <stdlib.h>
void
styleerror(char *errorstr)
{
cerr << "Parse Error: " << errorstr << endl;
}
main(int argc, char **argv)
{
INIT_EXCEPTIONS();
Stack<FeatureSet*,dlist_array<FeatureSet> > *stack;
Stack<FeatureSet*,dlist_array<FeatureSet> > stack1 ;
Stack<FeatureSet*,dlist_array<FeatureSet> > stack2 ;
stack1.push(new FeatureSet());
stack2.push(new FeatureSet());
stack = &stack1 ;
StyleSheet ss ;
// make sure args are balanced
/*
if (!(argc & 1))
cout << "feature [<name> <value>]+" << endl;
*/
for (int i = 1 ; i < argc ; )
{
switch (argv[i][0])
{
case '-':
// start a new feature set
stack = &stack2 ;
i++ ;
break;
case '{':
{
i++ ;
FeatureSet *newset = new FeatureSet();
stack->top()->add(new Feature(gSymTab->intern(argv[i++]),
new FeatureValueFeatureSet(newset)));
stack->push(newset);
}
break;
case '}':
stack->pop();
i++;
break;
default:
{
char c = argv[i+1][0] ;
FeatureValue *value = 0;
if (c >= '0' && c <= '9')
value = new FeatureValueInt(atoi(argv[i+1]));
else if ( c == '\'')
value = new FeatureValueSymbol(gSymTab->intern(argv[i+1]));
else
value = new FeatureValueString(argv[i+1]);
stack->top()->add(new Feature(gSymTab->intern(argv[i++]),
value));
i++;
}
break;
}
}
cout << "************** orig ****************" << endl;
cout << *stack1.top() << endl;
cout << "************** copy ****************" << endl;
FeatureSet *copy = new FeatureSet(*stack1.top());
cout << *copy << endl;
delete copy;
// now test merge
FeatureSet *merged = new FeatureSet(*stack1.top(), *stack2.top());
// delete these and check for memory leaks
delete stack1.pop();
delete stack2.pop();
cout << "************** merged ****************" << endl;
cout << *merged << endl;
try {
const Feature *f = merged->deep_lookup("font", "size", 0);
cout << "deep_lookup(\"font\", \"size\"): " ;
if (f)
cout << *f << endl;
else
cout << "(nil)" << endl;
// now try it with Symbols
Symbol font (gSymTab->intern("font"));
Symbol size (gSymTab->intern("size"));
f = merged->deep_lookup(&font,
&size, 0);
cout << "deep_lookup(\"font\", \"size\"): " ;
if (f)
cout << *f << endl;
else
cout << "(nil)" << endl;
}
catch_any()
{
cout << "exception thrown" << endl;
}
end_try;
delete merged ;
}

View File

@@ -1,893 +0,0 @@
/* $XConsortium: style.y /main/4 1996/11/11 11:51:33 drk $ */
%{
#include <stdio.h>
#include <ctype.h>
#include <sstream>
#include <iostream>
#include <assert.h>
#include "StyleSheetExceptions.h"
#include "VariableTable.h"
#include "FeatureValue.h"
#include "Expression.h"
#include "SSPath.h"
#include "PathTable.h"
#include "Renderer.h"
#include "PathQualifier.h"
#include "Debug.h"
#include "ParserConst.h"
#include "FeatureDefDictionary.h"
#include <utility/funcs.h>
#include "HardCopy/autoNumberFP.h"
extern autoNumberFP gAutoNumberFP;
#define alloca(x) (malloc(x))
extern void yyerror(char*);
extern int yylex();
extern void enter_sgmlgi_context();
extern featureDefDictionary* g_FeatureDefDictionary;
extern unsigned g_validation_mode;
extern unsigned g_hasSemanticError;
static char localCharToCharPtrBuf[2];
#undef yywrap
const char* toUpperCase(unsigned char* string)
{
static char buffer[512];
int j=0;
for ( int i=0; i<strlen((const char*)string); i++ )
{
if (islower(string[i]))
buffer[j] = toupper(string[i]) ;
else
buffer[j] = (char)string[i] ;
j++;
}
buffer[j] = 0;
return buffer;
}
%}
%union
{
unsigned char charData;
unsigned char* charPtrData;
unsigned int boolData;
int intData;
float realData;
Expression* expPtrData;
TermNode* termNodePtrData;
FeatureValue* FeatureValuePtrData;
FeatureSet* FeatureSetPtrData;
Feature* FeaturePtrData;
SSPath* PathPtrData;
PathTerm* PathTermPtrData;
charPtrDlist* charPtrDlistData;
PathFeatureList* PathFeatureListPtrData;
CompositeVariableNode* CompositeVariableNodePtrData;
CC_TPtrSlist<FeatureValue>* FeatureValueSlistPtrData;
PQExpr* PQExprPtrData;
}
%token<intData>
INTEGER
OPER_equality
OPER_relational
%token<boolData>
BOOLVAL
%token<realData>
REAL
%token<charData>
OPER_assign
ARRAYOPEN
ARRAYCLOSE
SEPARATOR
FSOPEN
FSCLOSE
OPER_modify
OPER_parent
OPER_attr
OPER_oneof
OPER_star
OPER_or
OPER_and
OPER_div
OPER_parenopen
OPER_parenclose
OPER_logicalnegate
PMEMOPEN
PMEMCLOSE
OPER_period
OPER_plus
OPER_minus
%token<charPtrData>
DIMENSION
NORMAL_STRING
UNIT_STRING
QUOTED_STRING
GI_CASE_SENSITIVE
SGMLGI_STRING
%type<intData>
POSITION_VALUE
%type<charPtrData>
SGMLGI
STRING
array_name
SGMLGI_CONTENT
%type<charData>
OPER_mult
OPER_binop
OPER_add
OPER_feature
%type<expPtrData>
multi_expr
simple_expr
%type<termNodePtrData>
term
symbol
parent
attr
dimension
%type<FeatureSetPtrData>
featureset
feature_list
%type<FeatureValuePtrData>
rhs.gp
array
array_member
%type<CompositeVariableNodePtrData>
string_list
%type<FeatureValueSlistPtrData>
array_member_list
%type<FeaturePtrData>
feature
%type<PathPtrData>
path_term_list
%type<PathTermPtrData>
path_term
%type<PathFeatureListPtrData>
path_expr_list
path_expr
%type<charPtrDlistData>
feature_name_list
%type<PQExprPtrData>
boolean_expr
logical_and_expr
equality_expr
path_selectorOPTL
path_selector
%start stylesheet
%nonassoc OPER_period
%nonassoc SGMLGI_STRING
%%
stylesheet : sensitivityOPTL statement.gpOPTL
{
}
;
sensitivity : GI_CASE_SENSITIVE OPER_assign BOOLVAL
{
gGI_CASE_SENSITIVE = $3;
}
;
statement.gp : var_assignment
{
}
| path_expr
{
/* copy items form the feature list into the path table */
PathFeatureListIterator l_Iter(*($1));
PathFeature *x = 0;
while ( ++l_Iter ) {
x = l_Iter.key();
if ( g_validation_mode == true )
if ( g_FeatureDefDictionary -> checkSemantics(x -> featureSet()) == false )
g_hasSemanticError = true;
gPathTab -> addPathFeatureSet( x );
}
/* clear out the first list so the elements are not deleted
with the list because they are still referenced by the
path table */
$1 -> clear();
delete $1;
}
;
var_assignment : STRING OPER_assign rhs.gp
{
Expression *x = new Expression(new ConstantNode($3));
if ( gAutoNumberFP.accept((const char*)$1, x) ) {
delete $1;
delete x;
break;
}
gVariableTable -> enter( gSymTab -> intern((const char*)$1), x);
delete $1;
}
;
symbol : attr
{
$$=$1;
}
|
parent string_list
{
$$=$1;
}
| string_list
{
const Symbol* x = $1 -> convertableToVariable();
if ( x ) {
$$=new VariableNode(*x);
delete $1;
} else
$$=$1;
}
;
string_list : string_list OPER_feature STRING
{
$1->appendItem(gSymTab->intern(toUpperCase($3)));
$$=$1;
delete $3 ;
}
| STRING
{
$$=new CompositeVariableNode;
$$ -> appendItem(gSymTab->intern(toUpperCase($1)));
delete $1;
}
;
parent : OPER_parent SGMLGI
{
/*
$$=new
ParentNode(gSymTab->intern((const char*)$1));
*/
MESSAGE(cerr, "^ operator not supported.");
throw(StyleSheetException());
}
;
attr : OPER_attr SGMLGI
{
$$=new
SgmlAttributeNode(gSymTab->intern((const char*)$2));
delete $2;
}
;
rhs.gp : simple_expr
{
$$=new FeatureValueExpression($1);
}
| array
{
$$=$1;
}
| featureset
{
$$=new FeatureValueFeatureSet($1);
}
;
simple_expr : simple_expr OPER_add multi_expr
{
BinaryOperatorNode::operatorType opType;
switch ($2) {
case '+': opType=BinaryOperatorNode::PLUS; break;
case '-': opType=BinaryOperatorNode::MINUS; break;
default:
throw(badEvaluationException());
}
FeatureValueExpression* FVexprL = new FeatureValueExpression($1);
FeatureValueExpression* FVexprR = new FeatureValueExpression($3);
$$ = new Expression(
new BinaryOperatorNode(opType,
new ConstantNode(FVexprL),
new ConstantNode(FVexprR)
)
);
}
| multi_expr
{
$$=$1;
}
;
multi_expr : multi_expr OPER_mult term
{
BinaryOperatorNode::operatorType opType;
switch ($2) {
case '*': opType=BinaryOperatorNode::TIMES; break;
case '/': opType=BinaryOperatorNode::DIVIDE; break;
default:
throw(badEvaluationException());
}
FeatureValueExpression* FVexpr = new FeatureValueExpression($1);
$$ = new Expression(
new BinaryOperatorNode(opType, new ConstantNode(FVexpr), $3)
);
}
| term
{
$$ = new Expression($1);
}
;
OPER_binop : OPER_mult
{
$$=$1;
}
| OPER_add
{
$$=$1;
}
;
OPER_mult : OPER_star
{
$$=$1;
}
| OPER_div
{
$$=$1;
}
;
term : BOOLVAL
{
$$=new ConstantNode(new FeatureValueInt(int($1)));
}
| symbol UNIT_STRING
{
FeatureValueExpression* fve =
new FeatureValueExpression(new Expression($1));
FeatureValueDimension* x =
new FeatureValueDimension(fve, (const char*)$2);
delete $2 ;
$$=new ConstantNode(x);
}
| symbol
{
$$=$1;
}
| dimension
{
$$=$1;
}
| QUOTED_STRING
{
$$=new ConstantNode(new FeatureValueString((const char*)$1));
delete $1 ;
}
| INTEGER UNIT_STRING
{
$$=new ConstantNode(new FeatureValueDimension(new FeatureValueInt($1), (const char*)$2));
delete $2 ;
}
| REAL UNIT_STRING
{
$$=new ConstantNode(new FeatureValueDimension(new FeatureValueReal($1), (const char*)$2));
delete $2 ;
}
| INTEGER
{
$$=new ConstantNode(new FeatureValueInt($1));
}
| REAL
{
$$=new ConstantNode(new FeatureValueReal($1));
}
| OPER_parenopen simple_expr OPER_parenclose
{
$$=new ConstantNode(new FeatureValueExpression($2));
}
;
array : array_name ARRAYOPEN array_member_list ARRAYCLOSE
{
FeatureValueArray* x =
new FeatureValueArray((const char*)$1, $3 -> entries());
CC_TPtrSlistIterator<FeatureValue> iter(*$3);
int i = 0;
while ( ++iter ) {
(*x)[i++] = iter.key();
}
delete $1;
delete $3;
$$ = x;
}
| array_name ARRAYOPEN ARRAYCLOSE
{
$$ = new FeatureValueArray((const char*)$1, 0);
delete $1;
}
;
array_name : STRING
{
$$ = $1;
}
|
{
$$ = new unsigned char[1];
$$[0] = 0;
}
;
array_member_list : array_member SEPARATOR array_member_list
{
$3 -> prepend($1);
$$ = $3;
}
| array_member
{
$$=new CC_TPtrSlist<FeatureValue>;
$$ -> append($1);
}
;
array_member : simple_expr
{
$$ = new FeatureValueExpression($1);
}
| array
{
$$=$1;
}
;
featureset : FSOPEN feature_list SEPARATOR_OPTL FSCLOSE
{
$$=$2;
}
| FSOPEN FSCLOSE
{
$$ = new FeatureSet ();
}
;
feature_list : feature_list SEPARATOR feature
{
if ($3 -> name() == Symbol(gSymTab->intern("FAMILY"))) {
// the evaluate() call clones $3
FeatureValueFeatureSet *fvfs =
(FeatureValueFeatureSet*) $3->evaluate();
const FeatureSet* fs = fvfs->value();
const Feature* charsetF =
fs->lookup(gSymTab->intern("CHARSET"));
// charsetF is a mandatory entry in fontfamily
assert( charsetF );
const FeatureValueString* fv_string =
(FeatureValueString*)charsetF->value();
const char* charset = *fv_string;
assert( charset );
int entries = $1 -> entries();
for (int i=0; i<entries; i++) {
const Feature* entry = $1->at(i);
if (! (entry->name() == Symbol(gSymTab->intern("FAMILY"))))
continue;
const FeatureSet* entry_fs =
((FeatureValueFeatureSet*)(entry->evaluate()))->value();
const Feature* entry_charsetF =
entry_fs->lookup(gSymTab->intern("CHARSET"));
assert( entry_charsetF );
const char* entry_charset =
*((FeatureValueString*)(entry_charsetF->value()));
assert( entry_charset );
if (! strcmp(charset, entry_charset)) {
delete $1 -> removeAt(i);
break; // escape from for-loop
}
}
delete fvfs ;
$$ = $1;
$$ -> add($3);
}
else {
if ( $1 -> find((Feature*)$3) ) {
FeatureSet* fs = new FeatureSet();
fs -> add($3);
$$ =new FeatureSet(*$1, *fs);
delete $1;
delete fs;
}
else {
$$=$1;
$$ -> add($3);
}
}
}
| feature
{
$$=new FeatureSet();
$$ -> add($1);
}
;
SEPARATOR_OPTL : SEPARATOR
{
}
|
{
}
;
feature : feature_name_list OPER_modify rhs.gp
{
CC_TPtrDlistIterator<char> l_Iter(*($1));
FeatureSet *fs = 0;
Feature *f = 0;
FeatureValue *fv = $3;
const char* cptr = 0;
char buffer[256];
while (++l_Iter) {
cptr = l_Iter.key();
int index = 0 ;
const char *c = cptr ;
while (*c)
{
if (islower(*c))
buffer[index] = toupper(*c) ;
else
buffer[index] = *c ;
c++ ;
index++;
}
buffer[index] = 0;
/* fprintf(stderr, "converted: %s to %s\n", cptr, buffer); */
f = new Feature(gSymTab -> intern(buffer), fv);
if ( $1 -> last() != cptr ) {
fs = new FeatureSet();
fs -> add(f);
fv = new FeatureValueFeatureSet(fs);
}
}
$1->clearAndDestroy();
delete $1 ;
$$=f;
}
;
feature_name_list : feature_name_list OPER_feature STRING
{
$1 -> prepend((char *)$3);
$$=$1;
}
|
STRING
{
$$=new CC_TPtrDlist<char>;
$$ -> append((char *)$1);
}
;
path_expr : path_term_list featureset
{
$$=new PathFeatureList;
$$ -> append(new PathFeature($1, $2));
}
| path_term_list OPER_parenopen path_expr_list OPER_parenclose
{
PathFeatureListIterator l_Iter(*($3));
while ( ++l_Iter ) {
(l_Iter.key()) -> path() -> prependPath(*$1);
}
delete $1;
$$=$3;
}
;
path_expr_list : path_expr_list SEPARATOR path_expr
{
$$=$1;
$$ -> appendList(*$3);
delete $3 ;
}
| path_expr
{
$$=$1;
}
path_term_list : path_term_list path_term
{
$1 -> appendPathTerm($2);
$$=$1;
}
| path_term
{
$$ = new SSPath;
$$ -> appendPathTerm($1);
}
;
path_term : SGMLGI path_selectorOPTL
{
$$=new PathTerm((const char*)$1, $2);
delete $1;
}
| OPER_oneof
{
localCharToCharPtrBuf[0]=$1; localCharToCharPtrBuf[1]=0;
$$=new PathTerm(localCharToCharPtrBuf, 0);
}
| OPER_star
{
localCharToCharPtrBuf[0]=$1; localCharToCharPtrBuf[1]=0;
$$=new PathTerm(localCharToCharPtrBuf, 0);
}
;
OPER_feature : OPER_period
{
}
OPER_add : OPER_plus
{
}
| OPER_minus
{
}
;
SGMLGI : SGMLGI_CONTENT
{
// char % can start an OLIAS internal element which
// is used only by the browser.
// Example %BOGUS within HEAD1 in OLIAS book
if ( $1[0] != '%' && isalnum($1[0]) == 0 ) {
MESSAGE(cerr, form("%s is not a SGMLGI", $1));
throw(badEvaluationException());
}
/* note, should probably be using RCStrings, would make wide */
/* char handling better too? */
if ( gGI_CASE_SENSITIVE == false )
{
for (int i=0; i<strlen((const char*)$1); i++)
if ( islower($1[i]) )
$1[i] = toupper($1[i]);
}
$$=$1;
}
;
SGMLGI_CONTENT : STRING OPER_period {enter_sgmlgi_context();} SGMLGI_STRING
{
int l = strlen((char*)$1) + strlen((char*)$4) + 2;
$$=new unsigned char[l];
strcpy((char*)$$, (char*)$1);
strcat((char*)$$, ".");
strcat((char*)$$, (char*)$4);
delete $1;
delete $4;
}
| STRING OPER_period
{
int l = strlen((char*)$1) + 2;
$$=new unsigned char[l];
strcpy((char*)$$, (char*)$1);
strcat((char*)$$, ".");
delete $1;
}
| STRING
{
$$=$1;
}
;
dimension : DIMENSION
{
int i;
for (i=0; i<strlen((const char*)$1); i++) {
if ( isalpha($1[i]) )
break;
}
char c;
float x;
if ( i > 0 ) {
c = $1[i]; $1[i]=0;
x = atof((const char*)$1);
$1[i]=c;
} else
x = 1;
$$=new ConstantNode(new FeatureValueDimension(new FeatureValueReal(x), (const char*)&$1[i]));
delete $1;
}
STRING : NORMAL_STRING
{
$$=$1;
}
| UNIT_STRING
{
$$=$1;
}
;
path_selector : ARRAYOPEN boolean_expr ARRAYCLOSE
{
$$=$2;
}
;
boolean_expr : logical_and_expr
{
//////////////////////////////////////////////////////
// This portion of the code (up to equality_expr) is
// hacked for V1.1 only. Due to the way
// PathQualifier.h is written, this code is not
// general at all. qfc 8/16/94
//////////////////////////////////////////////////////
$$=$1;
}
| boolean_expr OPER_or logical_and_expr
{
$$ = new PQLogExpr($1, PQor, $3);
}
;
logical_and_expr : equality_expr
{
$$=$1;
}
| logical_and_expr OPER_and equality_expr
{
$$ = new PQLogExpr($1, PQand, $3);
}
;
equality_expr : OPER_attr SGMLGI OPER_equality QUOTED_STRING
{
$$ = new PQAttributeSelector(
gSymTab->intern((const char*)$2),
( $3 == EQUAL ) ? PQEqual : PQNotEqual,
(const char*)$4
);
delete $2;
delete $4;
}
| NORMAL_STRING OPER_equality POSITION_VALUE
{
if ( strcasecmp((char*)$1, "position") == 0 ) {
$$=new PQPosition(
( $2 == EQUAL ) ? PQEqual : PQNotEqual,
$3
);
} else
if ( strcasecmp((char*)$1, "sibling") == 0 ) {
$$=new PQSibling(
( $2 == EQUAL ) ? PQEqual : PQNotEqual,
$3
);
} else
throw(StyleSheetException());
delete $1;
}
;
POSITION_VALUE : INTEGER
{
$$ = (int)$1;
}
| QUOTED_STRING
{
if ( strcasecmp((char*)$1, "#LAST") != 0 )
throw(StyleSheetException());
$$ = -1;
}
;
sensitivityOPTL : sensitivity
{
}
| /* empty */
{
}
;
statement.gpOPTL : statement.gpPLUS
{
}
| /* empty */
{
}
;
statement.gpPLUS : statement.gpPLUS statement.gp
{
}
| statement.gp
{
}
;
path_selectorOPTL : path_selector
{
$$=$1;
}
| /* empty */
{
$$=0;
}
;

View File

@@ -1,161 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: testparser.C /main/4 1996/08/21 15:51:08 drk $
#include "PathTable.h"
#include "Debug.h"
#include "Const.h"
#include "StyleSheetExceptions.h"
#include "VariableTable.h"
#include "StyleSheet.h"
#include "Resolver.h"
Renderer* gRenderer = 0;
extern int styleparse();
extern int stylerestart(FILE*);
extern FILE *stylein;
test1()
{
BitVector v1(33, 0);
v1.setBitTo(0, 1);
v1.setBitTo(1, 1);
v1.setBitTo(5, 1);
v1.setBitTo(32, 1);
debug(cerr, v1);
v1.shiftRightOneBit();
BitVector v2(33, 0);
v2.setBitTo(3, 1);
debug(cerr, v2);
MESSAGE(cerr, "v2 | v1");
v2 |= v1;
debug(cerr, v2);
BitVector v3(33, 0);
v3.setBitTo(8, 1);
debug(cerr, v3);
v3 &= v1;
MESSAGE(cerr, "v3 & v1");
debug(cerr, v3);
BitVector v4(33, 0);
v4.setBitTo(1, 1);
v4.setBitTo(8, 1);
debug(cerr, v4);
v4 ^= v1;
MESSAGE(cerr, "v4 ^ v1");
debug(cerr, v4);
}
test2( char* argv[] )
{
SSPath t(argv[1], false);
SSPath p(argv[2], true);
EncodedPath et(&t);
EncodedPath ep(&p, true);
debug(cerr, ep.match(et, 0, 0));
}
test3( int argc, char* argv[] )
{
/*
PathTable pt;
SSPath *px;
for ( int i=1; i<argc-1; i++ ) {
px = new SSPath(argv[i], (FeatureSet*)i);
pt.addPathFeatureSet(px);
}
SSPath pq(argv[argc-2], false);
debug(cerr, int(pt.getFeatureSet(pq)));
*/
}
test4( int argc, char* argv[] )
{
if ( argc >= 2 ) {
stylein = fopen(argv[1], "r");
if ( stylein == 0 ) {
MESSAGE(cerr, "open file failed");
return 1;
}
styleparse();
debug(cerr, *gVariableTable);
debug(cerr, *gPathTab);
fclose(stylein);
} else
MESSAGE(cerr, "no file argument");
}
struct XmappingTable_t {
char* FeatureName;
char* SubFeatureNameList;
char Value; // d: directly from the value()
// i: indrectly from the value()
char* Source; // l: local FeatureSet
// p: parent FeatureSet
// c: Combined FeatureSet
// can be a list of l, p, c
char* LoutBeginTag;
};
main( int argc, char* argv[] )
{
INIT_EXCEPTIONS();
StyleSheet ss;
if ( strcmp(argv[1], "test1") == 0 )
test1;
else
if ( strcmp(argv[1], "test2") == 0 )
test2(&argv[1]);
else
if ( strcmp(argv[1], "test3") == 0 )
test3(argc-1, &argv[1]);
else
if ( strcmp(argv[1], "test4") == 0 )
test4(argc-1, &argv[1]);
}
void styleerror( char* errorstr )
{
MESSAGE(cerr, errorstr);
return;
}

View File

@@ -1,48 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
// $XConsortium: testsym.cc /main/3 1996/06/11 17:10:33 cde-hal $
#include "SymTab.h"
SymbolTable *gSymTab = new SymbolTable;
SymbolTable *gElemSymTab = 0;
main()
{
Symbol a = gSymTab->intern("a");
Symbol b = gSymTab->intern("b");
Symbol a2 = gSymTab->intern("a");
cout << (a == a) << endl;
cout << (a == b) << endl;
cout << (a == a2) << endl;
cout << "ids = " << endl;
cout << a.name() << "\t" << a.id() << endl;
cout << b.name() << "\t" << b.id() << endl;
cout << a2.name() << "\t" << a2.id() << endl;
}

View File

@@ -1,355 +0,0 @@
/*
* $TOG: tokenStyle.l /main/6 1998/04/17 11:50:07 mgreess $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
%option noyywrap
%a 30000
%e 10000
%k 10000
%n 10000
%o 40000
%p 20000
%{
#include <string.h>
#include "ParserConst.h"
#include "Expression.h"
#include "FeatureValue.h"
#include "PathTable.h"
#include "SSPath.h"
#include "PathQualifier.h"
#include "StyleSheetExceptions.h"
#include "style.tab.h"
#include "Debug.h"
#include <iostream>
istream *g_stylein = 0;
#define YY_INPUT(buf,result,max_size)\
{\
if (g_stylein -> eof()) {\
result=0;\
} else {\
g_stylein -> read((char*)buf, max_size-1); \
result = g_stylein -> gcount(); \
buf[result] = 0; \
}\
}
unsigned char* qstring_buf = new unsigned char[1024];
int qstring_buf_size = 1024;
int qstring_buf_content_size = 0;
char* commentBuffer = new char [1024];
int commentBufferSize = 1024;
int commentBufferContentSize = 0;
void addToQstringBuf(const unsigned char* str, int size)
{
if ( size <= 0 ) return;
if ( qstring_buf_size - qstring_buf_content_size < size ) {
qstring_buf_size = 2*(size+qstring_buf_content_size);
unsigned char* x = new unsigned char[qstring_buf_size];
memcpy(x, qstring_buf, qstring_buf_content_size);
delete [] qstring_buf;
qstring_buf = x;
}
memcpy(qstring_buf + qstring_buf_content_size, str, size);
qstring_buf_content_size += size;
qstring_buf[qstring_buf_content_size] = 0;
}
%}
unit ([Ii][Nn]|[Ii][Nn][Cc][Hh]|[Pp][Cc]|[Pp][Ii][Cc][Aa]|[Pp][Tt]|[Pp][Oo][Ii][Nn][Tt]|[Pp][Ii][Xx][Ee][Ll]|[Cc][Mm])
%x block sgmlgimode quoted_string
%%
"#|" BEGIN(block);
^"#".* {
if ( commentBufferSize < yyleng ) {
delete [] commentBuffer;
commentBufferSize = 2 * yyleng ;
commentBuffer = new char [commentBufferSize];
}
commentBufferContentSize = yyleng-1;
memcpy(commentBuffer, yytext+1, commentBufferContentSize); // copy everything except the #
commentBuffer[commentBufferContentSize] = 0;
}
"=" {
return(OPER_assign);
}
"@" {
return(OPER_attr);
}
[+] {
stylelval.charData = yytext[0];
return(OPER_plus);
}
[-] {
stylelval.charData = yytext[0];
return(OPER_minus);
}
"/" {
stylelval.charData = yytext[0];
return(OPER_div);
}
"." {
return(OPER_period);
}
"*" {
stylelval.charData = yytext[0];
return(OPER_star);
}
":" {
return(OPER_modify);
}
"?" {
return(OPER_oneof);
}
"^" {
return(OPER_parent);
}
"," {
return(SEPARATOR);
}
"{" {
return(FSOPEN);
}
"}" {
return(FSCLOSE);
}
"[" {
return(ARRAYOPEN);
}
"]" {
return(ARRAYCLOSE);
}
"(" {
return(OPER_parenopen);
}
")" {
return(OPER_parenclose);
}
"||" {
return(OPER_or);
}
"&&" {
return(OPER_and);
}
"=="|"!=" {
if ( strcmp((const char*)yytext, "==") == 0 )
stylelval.intData = EQUAL;
else
stylelval.intData = NOT_EQUAL;
return(OPER_equality);
}
"!" {
return(OPER_logicalnegate);
}
"<="|"<"|">="|">" {
if ( strcmp((const char*)yytext, "<=") == 0 )
stylelval.intData = LESS_OR_EQUAL;
else
if ( strcmp((const char*)yytext, "<") == 0 )
stylelval.intData = LESS;
else
if ( strcmp((const char*)yytext, ">=") == 0 )
stylelval.intData = GREATER_OR_EQUAL;
else
stylelval.intData = GREATER;
return(OPER_relational);
}
"GICaseSensitive" {
return(GI_CASE_SENSITIVE);
}
[Tt][Rr][Uu][Ee] {
stylelval.boolData = true;
return(BOOLVAL);
}
[Ff][Aa][Ll][Ss][Ee] {
stylelval.boolData = false;
return(BOOLVAL);
}
[On][Nn] {
stylelval.boolData = true;
return(BOOLVAL);
}
[Oo][Ff][Ff] {
stylelval.boolData = false;
return(BOOLVAL);
}
[0-9]+("."[0-9]+)?{unit} {
stylelval.charPtrData =
(unsigned char*)strdup((const char*)yytext);
return(DIMENSION);
}
[0-9]+ {
stylelval.intData = atoi((char*)yytext);
return(INTEGER);
}
[0-9]+"."[0-9]+ {
stylelval.realData = atof((char*)yytext);
return(REAL);
}
\" {
BEGIN quoted_string;
}
<quoted_string>\" {
stylelval.charPtrData =
new unsigned char[qstring_buf_content_size+1];
memcpy( stylelval.charPtrData,
qstring_buf,
qstring_buf_content_size+1
);
qstring_buf_content_size = 0;
BEGIN 0;
return(QUOTED_STRING);
}
<quoted_string>\\ {
int c = yyinput();
switch (c) {
case '"':
addToQstringBuf((unsigned char*)"\"", 1);
break;
case '\\':
addToQstringBuf((unsigned char*)"\\", 1);
break;
default:
throw(CASTSSEXCEPT StyleSheetException());
}
}
<quoted_string>[^\\\"]* {
addToQstringBuf((unsigned char*)yytext, yyleng);
}
<quoted_string>. {
addToQstringBuf((unsigned char*)yytext, yyleng);
}
{unit} {
stylelval.charPtrData =
(unsigned char*)strdup((const char*)yytext);
return(UNIT_STRING);
}
[^ \t\n\".=@+*\/\.\*:?\^,{}\[\]()!]+ {
stylelval.charPtrData =
(unsigned char*)strdup((const char*)yytext);
return(NORMAL_STRING);
}
<sgmlgimode>[0-9a-zA-Z\.\-]+ {
stylelval.charPtrData =
(unsigned char*)strdup((const char*)yytext);
BEGIN 0;
return(SGMLGI_STRING);
}
[\t] {
}
[\n] {
yylineno++;
}
. {
}
<block>"|#" { BEGIN(0); }
<block>. ;
<block>\n ;
%%
void enter_sgmlgi_context()
{
BEGIN sgmlgimode;
}
void report_error_location()
{
if ( commentBufferContentSize > 0 ) {
cerr << commentBuffer << "\n";
}
}
void styleerror(char* msg)
{
#ifdef DEBUG
cerr << "line " << yylineno << ": " << msg << "\n";
#endif
throw(CASTSSSEEXCEPT StyleSheetSyntaxError());
}

View File

@@ -1,39 +0,0 @@
XCOMM $XConsortium: Imakefile /main/14 1996/08/21 15:51:16 drk $
XCOMM ** WARNING **
XCOMM
XCOMM The files named here may appear in many different Imakefiles.
XCOMM If you add or remove a file, be sure to update all locations.
XCOMM It's unfortunate, but all this redundancy serves a purpose.
XCOMM
XCOMM Other possible locations are:
XCOMM .../lib/DtMmdb/Imakefile
XCOMM .../lib/DtMmdb/<subdir>/Imakefile
XCOMM .../programs/dtinfo/mmdb/Imakefile
XCOMM .../programs/dtinfo/mmdb/<subdir>/Imakefile
#define DoNormalLib NormalLibDtMmdb
#define DoSharedLib SharedLibDtMmdb
#define DoDebugLib DebugLibDtMmdb
#define DoProfileLib ProfileLibDtMmdb
#define LibName DtMmdb
#define SoRev SODTMMDBREV
#define LibHeaders NO
#define LibCreate NO
#define LargePICTable YES
#define CplusplusSource YES
DEPEND_DEFINES = $(DEPENDDEFINES)
XCOMM In DtMmdb we compile as C_API sources.
DEFINES = -DC_API
INCLUDES = $(CXXDEPENDINCLUDES) -I.. $(EXCEPTIONS_INCLUDES) -I../misc
SRCS = base.C info_base.C info_lib.C smart_ptr.C transaction.C utility.C
OBJS = $(SRCS:.C=.o)
#include <Library.tmpl>
SubdirLibraryRule($(OBJS))
DependTarget()

View File

@@ -1,8 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
noinst_LTLIBRARIES = libapi.la
libapi_la_CXXFLAGS = -I..
libapi_la_SOURCES = base.C info_base.C info_lib.C smart_ptr.C transaction.C \
utility.C

View File

@@ -1,115 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: base.cc /main/4 1996/06/11 17:10:55 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "api/base.h"
base::base(object_dict* obj_dict) :
info_base_set_names(0), info_base_list_names(0),
num_cset_ptrs(0), num_list_ptrs(0),
f_obj_dict(obj_dict)
{
base_path[0] = 0;
base_name[0] = 0;
base_desc[0] = 0;
base_uid[0] = 0;
}
base::base(object_dict* obj_dict,
char** set_nms, char** list_nms,
const char* base_dir, const char* base_nm, const char* base_ds,
const char* base_uid_str
) :
info_base_set_names(set_nms), info_base_list_names(list_nms),
num_cset_ptrs(0), num_list_ptrs(0),
f_obj_dict(obj_dict)
{
if ( base_dir ) {
int len = MIN(strlen(base_dir), PATHSIZ - 1);
*((char *) memcpy (base_path, base_dir, len) + len) = '\0';
} else {
base_path[0] = 0;
}
if ( base_nm ) {
int len = MIN(strlen(base_nm), PATHSIZ - 1);
*((char *) memcpy (base_name, base_nm, len) + len) = '\0';
} else {
base_name[0] = 0;
}
if ( base_ds ) {
int len = MIN(strlen(base_ds), PATHSIZ - 1);
*((char *) memcpy (base_desc, base_ds, len) + len) = '\0';
} else {
base_desc[0] = 0;
}
if ( base_uid_str ) {
int len = MIN(strlen(base_uid_str), UIDSIZ - 1);
*((char *) memcpy (base_uid, base_uid_str, len) + len) = '\0';
} else {
base_uid[0] = 0;
}
if ( set_nms )
while ( info_base_set_names[num_cset_ptrs] )
num_cset_ptrs++;
if ( list_nms ) {
while ( info_base_list_names[num_list_ptrs] )
num_list_ptrs++;
}
}
base::~base()
{
;
}

View File

@@ -1,106 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: base.h /main/4 1996/06/11 17:11:01 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _base_h
#define _base_h 1
#include "object/cset.h"
#include "schema/object_dict.h"
#define MAP_FILE "names.mmdb"
#define MAP_FILE_8_3 "bookcase.map"
#define DATA_FILE_SUFFIX "dbd"
#define INDEX_FILE_SUFFIX "dbi"
#define UIDSIZ 20
/*************************************/
// The base class
/*************************************/
class base : public primitive
{
public:
base(object_dict* dict);
base(object_dict* dict,
char** set_nms, char** list_nms,
const char* base_dir, const char* base_name,
const char* base_desc, const char* base_uid
);
virtual ~base();
object_dict& get_obj_dict() { return *f_obj_dict; };
const char* get_base_name() const { return base_name; };
const char* get_base_desc() const { return base_desc; };
const char* get_base_path() const { return base_path; };
const char* get_base_uid() const { return base_uid; };
protected:
char base_path[PATHSIZ];
char base_name[PATHSIZ];
char base_desc[PATHSIZ];
char base_uid[UIDSIZ];
char** info_base_set_names;
char** info_base_list_names;
int num_cset_ptrs;
int num_list_ptrs;
object_dict* f_obj_dict;
};
typedef base* basePtr;
#endif

View File

@@ -1,46 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: db_oid.h /main/3 1996/06/11 17:11:06 cde-hal $ */
#ifndef _db_oid_h
#define _db_oid_h 1
#include "object/oid_t.h"
/*************************************/
// The db_oid class
/*************************************/
class db_oid : public oid_t
{
public:
db_oid() {};
db_oid(oid_t& x) : oid_t(x) {};
virtual ~db_oid() {};
int index_num;
};
#endif

View File

@@ -1,354 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: info_base.C /main/5 1996/09/04 01:37:05 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef C_API
#include <sstream>
using namespace std;
#endif
#include "api/info_base.h"
#include "compression/abs_agent.h"
info_base::info_base(object_dict& obj_dict,
char** set_name_list, char** list_name_list,
const char* base_dir, const char* base_nm,
const char* base_ds, const char* base_uid,
const char* base_locale,
const mm_version& v
)
: base(&obj_dict,
set_name_list, list_name_list,
base_dir, base_nm, base_ds, base_uid
), f_v(v)
{
/*
debug(cerr, base_dir);
debug(cerr, base_nm);
debug(cerr, base_ds);
*/
if (base_locale) {
int len = MIN(strlen(base_locale), PATHSIZ - 1);
*((char *) memcpy (info_base_locale, base_locale, len) + len) = '\0';
} else {
*info_base_locale = 0;
}
char* nm ;
int i;
//////////////////////
// sets
//////////////////////
info_base_set_ptrs = new cset_handlerPtr[num_cset_ptrs];
for ( i=0; i<num_cset_ptrs; i++ ) {
nm = form("%s.%s", base_nm, info_base_set_names[i]);
mtry {
info_base_set_ptrs[i] = (cset_handler*)
(f_obj_dict -> get_handler(nm));
}
mcatch_any()
{
info_base_set_ptrs[i] = 0;
}
end_try;
}
//////////////////////
// lists
//////////////////////
info_base_list_ptrs = new dl_list_handlerPtr[num_list_ptrs];
for ( i=0; i<num_list_ptrs; i++ ) {
nm = form("%s.%s", base_nm, info_base_list_names[i]);
mtry {
info_base_list_ptrs[i] = (dl_list_handler*)
obj_dict.get_handler(nm);
}
mcatch_any()
{
info_base_list_ptrs[i] = 0;
}
end_try;
}
#ifdef C_API
f_index_id = 0;
#endif
MESSAGE(cerr, form("info base %s in %s available.", base_name, base_dir));
}
info_base::~info_base()
{
delete info_base_list_ptrs;
delete info_base_set_ptrs;
}
int info_base::get_set_pos(const char* set_nm)
{
for ( int i=0; i<num_cset_ptrs; i++ ) {
if ( strcmp(set_nm, info_base_set_names[i]) == 0 )
return i;
}
return -1;
}
cset_handlerPtr info_base::get_set(const char* set_nm)
{
//MESSAGE(cerr, "in info_base::get_set()");
return get_set(get_set_pos(set_nm));
}
cset_handlerPtr info_base::get_set(int i)
{
if ( !INRANGE(i, 0, num_cset_ptrs-1) )
throw (boundaryException(0, num_cset_ptrs-1, i));
return info_base_set_ptrs[i];
}
///////////////////
// funcs about list
///////////////////
int info_base::get_list_pos(const char* list_nm)
{
for ( int i=0; i<num_list_ptrs; i++ ) {
if ( strcmp(list_nm, info_base_list_names[i]) == 0 )
return i;
}
return -1;
}
dl_list_handlerPtr info_base::get_list(const char* list_nm)
{
return ( get_list(get_list_pos(list_nm)) );
}
dl_list_handlerPtr info_base::get_list(int i)
{
if ( !INRANGE(i, 0, num_list_ptrs-1) ) {
throw(boundaryException(0, num_list_ptrs-1, i));
}
return info_base_list_ptrs[i];
}
int info_base::num_of_docs()
{
// the implementation is temp. It should take
// a hint as where to obtain the information.
// like from a set named so and so.
cset_handler* x = get_set("doc");
if (x) {
return (*x) -> count();
} else {
return 0;
}
}
////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////
Iterator::Iterator( handler* x, c_code_t y) :
collection_hd(x), instance_c_code(y), ind(0)
{
}
Iterator::~Iterator()
{
}
Iterator::operator void*()
{
return ( ind == 0 ) ? 0 : (void*)1;
}
Iterator* info_base::first(char* col_nm, c_code_t code)
{
handler* x = get_set(col_nm);
if ( x == 0 ) {
x = get_list(col_nm);
}
if ( x == 0 ) {
throw(stringException("unknown collection name"));
}
page_storage *s = (page_storage*)(x -> its_store());
if ( s == 0 ) {
throw(stringException("collection has no store"));
}
if ( s -> my_oid().ccode() != PAGE_STORAGE_CODE ) {
throw(stringException("non page store no supported"));
}
Iterator* it = new Iterator(x, code);
it -> ind = s -> first_loc();
if ( managers::template_mgr -> peek_slot(s, it->ind) != code ) {
this -> next(*it);
}
return it;
}
oid_t info_base::get_oid(const Iterator& it)
{
page_storage *s = (page_storage*)( it.collection_hd -> its_store() );
root *r = 0;
managers::template_mgr -> init_obj(s, it.ind, r);
if (r == 0)
throw(stringException("null root pointer"));
return r -> my_oid();
}
void info_base::next(Iterator& it)
{
page_storage *s = (page_storage*)( it.collection_hd -> its_store());
while ( s -> seek_loc( it.ind, positive, spointer_t::IS_OBJECT ) == true ) {
if ( managers::template_mgr -> peek_slot(s, it.ind) == it.instance_c_code ) {
return;
}
}
it.ind = 0;
}
int stdin_sgml_data_getchar(unsigned char* buf, int max_sz)
{
static int remain_chars = 0;
static int chars_to_read;
static char loc_buf[LBUFSIZ];
if ( remain_chars == 0 ) {
if ( fgets(loc_buf, LBUFSIZ, stdin) == NULL )
return 0;
if ( fgets(loc_buf, LBUFSIZ, stdin) == NULL )
throw(stringException("no locator line"));
if ( fscanf(stdin, "%d", &remain_chars) != 1 )
throw(stringException("sgml_data_getchar(): fscanf() failed"));
if ( getc(stdin) != '\t' ) {
debug(cerr, remain_chars);
throw(stringException("'\\t' expected"));
}
}
chars_to_read = MIN(max_sz, remain_chars);
if ( (int)fread((char*)buf, 1, chars_to_read, stdin) != chars_to_read ) {
throw(stringException("sgml_data_getchar(): fread() failed"));
}
remain_chars -= chars_to_read;
if ( remain_chars == 0 ) {
if ( getc(stdin) != '\n' )
throw(stringException("'\\n' expected"));
}
/*
for ( int i=0; i<chars_to_read; i++ ) {
cerr << buf[i];
}
MESSAGE(cerr, "\n");
debug(cerr, max_sz);
debug(cerr, chars_to_read);
*/
return chars_to_read;
}
int stdin_ps_data_getchar(unsigned char* buf, int max_sz)
{
return fread((char*)buf, 1, max_sz, stdin);
}
extern int sgmllex();
extern int pslex();
void info_base::build_dict(char* agent_name)
{
compress_agent_handler* x = (compress_agent_handler*)
(f_obj_dict -> get_handler(agent_name));
if ( x == 0 )
throw(stringException("info_base::build_dict(): unknown compress agent"));
if ( strstr(agent_name, ".sgml.") != NULL ) {
(*x) -> build_dict(sgmllex, stdin_sgml_data_getchar);
} else
if ( strstr(agent_name, ".ps.") != NULL ) {
(*x) -> build_dict(pslex, stdin_ps_data_getchar);
} else
throw(stringException("info_base::build_dict(): unknown compress target"));
}

View File

@@ -1,145 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: info_base.h /main/6 1996/09/04 01:37:17 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _info_base_h
#define _info_base_h 1
#include "utility/macro.h"
#include "storage/version.h"
#include "api/base.h"
#include "mgrs/managers.h"
#include "schema/object_dict.h"
#include "object/cset.h"
#include "object/dl_list.h"
class Iterator
{
public:
Iterator( handler*, c_code_t );
~Iterator();
operator void*();
protected:
handler* collection_hd;
c_code_t instance_c_code;
mmdb_pos_t ind;
friend class info_base;
};
/*************************************/
// The info_base class
/*************************************/
class info_base : public base
{
public:
info_base( object_dict& dict,
char** set_nms, char** list_nms,
const char* base_dir, const char* base_name,
const char* base_desc, const char* base_uid,
const char* base_locale,
const mm_version& v
);
virtual ~info_base();
// export funcs
cset_handlerPtr get_set( const char* set_name );
cset_handlerPtr get_set( int set_position );
dl_list_handlerPtr get_list( const char* list_name );
dl_list_handlerPtr get_list( int list_position );
void add_composite(char* new_db_path, char* def_spec_path);
// query functions
int num_of_docs();
mm_version& data_version() { return f_v; };
// iterate over all instances with 'c_code' in a set or a list
Iterator* first(char* col_nm, c_code_t c_code);
oid_t get_oid(const Iterator& ind);
void next(Iterator&);
#ifdef C_API
// an integer id within the infolib
int index_id() { return f_index_id; };
void set_index_id(int x) { f_index_id = x; };
#endif
// build compression dicts. data is from stdin
void build_dict(char* compress_agent_name);
const char* get_info_base_locale() const { return info_base_locale; }
protected:
cset_handlerPtr* info_base_set_ptrs;
dl_list_handlerPtr* info_base_list_ptrs;
#ifdef C_API
int f_index_id;
#endif
mm_version f_v;
int get_set_pos( const char* set_name );
int get_list_pos( const char* list_name );
friend class info_lib;
char info_base_locale[PATHSIZ];
};
typedef info_base* info_basePtr;
#endif

View File

@@ -1,664 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: info_lib.C /main/9 1996/12/02 12:47:19 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "misc/unique_id.h"
#include "api/info_lib.h"
#include "utility/db_version.h"
#include "oliasdb/locator_hd.h"
#include "oliasdb/graphic_hd.h"
/*
extern void report_total();
extern void reset_total();
*/
int g_mode_8_3 = 0;
typedef char* charPtr;
info_lib::info_lib(char** set_name_array, char** list_name_array,
char* info_lib_dir, char* selected_base_name,
char* infoLibName, int des) :
set_nm_list(set_name_array), list_nm_list(list_name_array),
f_bad_base_array_size(0), f_bad_info_bases(0),
f_bad_info_base_names(0), f_bad_info_base_paths(0), f_descriptor(des)
{
//debug(cerr, info_lib_dir);
//debug(cerr, infoLibName);
int len;
f_obj_dict = new object_dict;
if ( info_lib_dir == 0 ) {
throw(stringException("NULL info lib path"));
}
if ( check_and_create_dir(info_lib_dir) == false )
throw(stringException(
form("infolib %s does not exist or can't be created", info_lib_dir)
)
);
len = MIN(strlen(info_lib_dir), PATHSIZ -1);
*((char *) memcpy (info_lib_path, info_lib_dir, len) + len) = '\0';
len = MIN(strlen(infoLibName), PATHSIZ -1);
*((char *) memcpy (info_lib_name, infoLibName, len) + len) = '\0';
fstream *map_in = 0;
if ( exist_file(MAP_FILE_8_3, info_lib_dir) == true ) {
map_in = new fstream(form("%s/%s", info_lib_dir, MAP_FILE_8_3), ios::in);
g_mode_8_3 = 1;
if ( !map_in -> getline(info_lib_name, PATHSIZ, '\t') ||
!map_in -> getline(info_lib_uid, UIDSIZ, '\n')
)
{
throw(stringException(
form("infolib %s does not have correct name-id entry", info_lib_dir)
)
);
}
} else
if ( exist_file(MAP_FILE, info_lib_dir) == true )
map_in = new fstream(form("%s/%s", info_lib_dir, MAP_FILE), ios::in);
else {
return;
}
char base_name[PATHSIZ];
char base_desc[PATHSIZ];
char base_uid[UIDSIZ];
char base_locale[PATHSIZ];
char db_path_name[PATHSIZ];
int major_mm_version = 0;
int minor_mm_version = 0;
while ( map_in -> getline(base_name, PATHSIZ, '\t') ) {
map_in -> getline(base_desc, PATHSIZ, '\t');
if ( g_mode_8_3 == 1 ) {
map_in -> getline(base_uid, PATHSIZ, '\t');
map_in -> getline(base_locale, PATHSIZ, '\t');
}
else
base_uid[0] = 0;
(*map_in) >> major_mm_version >> minor_mm_version;
map_in -> get();
if ( base_name[0] != CommentChar ) {
//debug(cerr, base_name);
//debug(cerr, base_desc);
//fprintf(stderr, "base_name = %s\n", base_name);
if ((selected_base_name == 0 ||
strcmp(selected_base_name, base_name) == 0))
{
len = MIN(strlen(info_lib_dir) + strlen(base_name) +1, PATHSIZ -1);
*((char *) memcpy (db_path_name,
form("%s/%s", info_lib_dir, base_name),
len) + len) = '\0';
mm_version mmv_code(MAJOR, MINOR);
mm_version mmv_base_data(2, 1);
mm_version mmv_data(major_mm_version, minor_mm_version);
///////////////////////////////////////////////
// Hardcoded knowledge of discontinuation of
// backward compatibility
///////////////////////////////////////////////
if ( mmv_data < mmv_base_data ||
mmv_data == mmv_base_data ||
mmv_code < mmv_data
)
{
if ( f_bad_base_array_size == 0 ||
f_bad_base_array_size <= f_bad_info_bases
)
{
if ( f_bad_base_array_size == 0 ) {
f_bad_base_array_size = 10;
f_bad_info_base_names = new charPtr[f_bad_base_array_size];
f_bad_info_base_paths = new charPtr[f_bad_base_array_size];
for (int i=0; i<f_bad_base_array_size; i++) {
f_bad_info_base_paths[i] = 0;
f_bad_info_base_names[i] = 0;
}
} else {
char** x = new charPtr[2*f_bad_base_array_size];
char** y = new charPtr[2*f_bad_base_array_size];
for (int i=0; i<2*f_bad_base_array_size; i++) {
x[i] = 0;
y[i] = 0;
}
memcpy(x, f_bad_info_base_names, sizeof(charPtr)*f_bad_base_array_size);
memcpy(y, f_bad_info_base_paths, sizeof(charPtr)*f_bad_base_array_size);
f_bad_base_array_size *= 2;
delete [] f_bad_info_base_names;
delete [] f_bad_info_base_paths;
f_bad_info_base_names = x;
f_bad_info_base_paths = y;
}
}
f_bad_info_base_paths[f_bad_info_bases] = strdup(info_lib_dir);
f_bad_info_base_names[f_bad_info_bases] = strdup(base_name);
f_bad_info_bases++;
MESSAGE(cerr, "Data and code version mismatch");
MESSAGE(cerr, form("Data version: v%d.%d",
major_mm_version, minor_mm_version
));
MESSAGE(cerr, form("Code version: v%d.%d",
MAJOR, MINOR
));
MESSAGE(cerr, form("infobase %s is not available.", base_name));
continue;
}
//reset_total();
_init_info_base(db_path_name, base_name, base_desc, base_uid, base_locale,
mm_version(major_mm_version, minor_mm_version));
//report_total();
}
}
}
map_in -> close();
delete map_in ;
}
info_lib::~info_lib()
{
long ind = first();
while ( ind ) {
info_base* x = (*this)(ind);
delete x;
next(ind) ;
}
if ( f_bad_info_base_paths ) {
for (int i=0; i<f_bad_base_array_size; i++) {
delete f_bad_info_base_paths[i];
}
delete f_bad_info_base_paths;
}
if ( f_bad_info_base_names ) {
for (int i=0; i<f_bad_base_array_size; i++) {
delete f_bad_info_base_names[i];
}
delete f_bad_info_base_names;
}
delete f_obj_dict;
}
/* *********************************************************/
// init all bases. play the trick by changing the db_path
// value to load all info bases (each has different db_path).
/* *********************************************************/
info_base *
info_lib::_init_info_base( const char* base_path,
const char* base_name,
const char* base_desc,
const char* base_uid,
const char* base_locale,
const mm_version& v
)
{
/*
debug(cerr, base_path);
debug(cerr, base_name);
*/
//fprintf(stderr, "init_base\n");
//fprintf(stderr, "base_path=%s\n", base_path);
//fprintf(stderr, "base_name=%s\n", base_name);
info_base *x = 0;
if ( ( x = get_info_base(base_name)) == 0 ) {
if ( exist_dir(base_path) == false )
return 0;
//fprintf(stderr, "try to init %s\n", base_name);
mtry {
f_obj_dict -> init_a_base((char*)base_path, (char*)base_name);
x = new info_base(*f_obj_dict, set_nm_list, list_nm_list,
base_path, base_name, base_desc, base_uid, base_locale,
v
);
info_base_list.insert_as_tail(new dlist_void_ptr_cell(x));
}
mcatch (mmdbException &,e)
{
//fprintf(stderr, "in catch block\n");
return 0;
} end_try;
}
return x;
}
/******************************************/
//
// def_strings array:
//
// def_strings[0] : infobase name
// def_strings[1] : infobase textual description
// def_strings[2] : define spec file name (full path)
//
/******************************************/
Boolean
info_lib::define_info_base( char* base_name, char* base_desc,
char* spec_file_path
)
{
//MESSAGE(cerr, "define_info_base()");
//debug(cerr, base_name);
//debug(cerr, base_desc);
//debug(cerr, spec_file_path);
char new_db_path[PATHSIZ];
char f_name[PATHSIZ];
char base_uid[UIDSIZ];
int len;
const char* uid;
len = MIN(strlen(info_lib_path) + strlen(base_name) + 1, PATHSIZ -1);
*((char *) memcpy (new_db_path,
form("%s/%s", info_lib_path, base_name),
len) + len) = '\0';
uid = unique_id();
len = MIN(strlen(uid), UIDSIZ -1);
*((char *) memcpy(base_uid, uid, len) + len) = '\0';
g_mode_8_3 = 1;
info_base* base = get_info_base(base_name) ;
/* no checking here. DDK assures unique base name case
if ( base == 0 ) {
*/
//////////////////////////
// check info base path
//////////////////////////
if ( check_and_create_dir(new_db_path) == false ) {
throw(stringException(form("bad base bath %s", new_db_path)));
}
//////////////////////////
// remove any old files
//////////////////////////
len = MIN(strlen(base_name) + strlen(DATA_FILE_SUFFIX) +1, PATHSIZ -1);
*((char *) memcpy(f_name,
form("%s.%s", base_name, DATA_FILE_SUFFIX),
len) + len) = '\0';
if ( exist_file(f_name, new_db_path) == true )
del_file(f_name, new_db_path);
len = MIN(strlen(base_name) + strlen(INDEX_FILE_SUFFIX) + 1, PATHSIZ -1);
*((char *) memcpy(f_name,
form("%s.%s", base_name, INDEX_FILE_SUFFIX),
len) + len) = '\0';
if ( exist_file(f_name, new_db_path) == true )
del_file(f_name, new_db_path);
len = MIN(strlen(base_name) + strlen(SCHEMA_FILE_SUFFIX) +1, PATHSIZ -1);
*((char *) memcpy(f_name,
form("%s.%s", base_name, SCHEMA_FILE_SUFFIX),
len) + len) = '\0';
if ( exist_file(f_name, new_db_path) == true )
del_file(f_name, new_db_path);
f_obj_dict -> init_a_base(spec_file_path, new_db_path, base_name);
const char* lang;
if ((lang = getenv("LC_ALL")) == NULL)
if ((lang = getenv("LC_CTYPE")) == NULL)
if ((lang = getenv("LANG")) == NULL)
lang = "C.UTF-8";
base = new info_base(*f_obj_dict, set_nm_list, list_nm_list,
new_db_path, base_name, base_desc, base_uid,
lang, mm_version(MAJOR, MINOR)
);
info_base_list.insert_as_tail(new dlist_void_ptr_cell(base));
/*************************************/
// add the base name and description
// to the names file
/*************************************/
char* lib_nm = form("%s/%s", info_lib_path, MAP_FILE_8_3);
fstream nm_out(lib_nm, ios::out | ios::app);
// fstream nm_out(lib_nm, ios::app, open_file_prot());
if ( !nm_out ) {
MESSAGE(cerr, form("can't open %s/%s for append",
info_lib_path, MAP_FILE_8_3)
);
throw(streamException(nm_out.rdstate()));
}
if ( bytes(lib_nm) == 0 ) {
char* lib_entry = form("%s\t%s\n", info_lib_name, unique_id());
if ( !(nm_out << lib_entry) ) {
MESSAGE(cerr,
form("write %s.%s failed", info_lib_path, MAP_FILE_8_3));
throw(streamException(nm_out.rdstate()));
}
}
char* base_entry = form("%s\t%s\t%s\t%s\t%d\t%d\n",
base_name, base_desc, base_uid,
lang, MAJOR, MINOR
);
if ( !(nm_out << base_entry) ) {
MESSAGE(cerr, form("write %s.%s failed", info_lib_path, MAP_FILE_8_3));
throw(streamException(nm_out.rdstate()));
}
nm_out.close();
if ( nm_out.fail() ) {
MESSAGE(cerr, form("close %s.%s failed", info_lib_path, MAP_FILE_8_3));
throw(streamException(nm_out.rdstate()));
}
//}
//MESSAGE(cerr, "define() done");
return true;
}
info_base* info_lib::get_info_base(const char* info_base_nm)
{
long ind = first();
//debug(cerr, ind);
while ( ind ) {
info_base* x = (*this)(ind);
/*
debug(cerr, int(x));
debug(cerr, x -> base_name);
debug(cerr, info_base_nm);
*/
if ( strcmp ( x -> base_name, info_base_nm) == 0 )
return x;
next(ind) ;
}
return 0;
}
/* inline */
/*
int info_lib::num_of_bases()
{
return info_base_list.count();
}
*/
/*************************/
// iteration funcstions
/*************************/
/* inline */
/*
int info_lib::first()
{
return info_base_list.first();
}
info_base* info_lib::operator()(int ind)
{
return (info_base*)(((dlist_void_ptr_cell*)ind)->void_ptr());
}
void info_lib::next(int& ind)
{
info_base_list.next(ind) ;
}
*/
int info_lib::bad_infobases()
{
return f_bad_info_bases;
}
const char* info_lib::get_bad_infobase_path(int x)
{
if ( x <= 0 || x > f_bad_info_bases )
return 0;
return f_bad_info_base_paths[x-1];
}
const char* info_lib::get_bad_infobase_name(int x)
{
if ( x <= 0 || x > f_bad_info_bases )
return 0;
return f_bad_info_base_names[x-1];
}
info_base*
info_lib::getInfobaseByComponent(const char *locator_string, enum TestSelector sel)
{
if ( locator_string == 0 )
return 0;
info_base* ib = 0;
long ind = first();
while ( ind ) {
ib = (*this)(ind);
if (ib==0)
throw(stringException("null info_base ptr"));
mtry { // since an infobase may not have any graphics, we catch
// any exceptions there and try next infobase.
switch (sel) {
case LOC:
{
locator_smart_ptr loc(ib, locator_string);
//fprintf(stderr, "inside-loc-string=%s\n", loc.inside_node_locator_str());
//fprintf(stderr, "loc-string=%s\n", locator_string);
if ( strcmp( loc.inside_node_locator_str(), locator_string) == 0 ) {
return ib;
}
}
case GRA:
{
graphic_smart_ptr graphic(ib, locator_string);
if ( strcmp( graphic.locator(), locator_string) == 0 ) {
return ib;
}
}
}
}
mcatch (mmdbException &,e)
{
} end_try;
next(ind);
}
return 0;
}
info_base**
info_lib::getInfobasesByComponent(char **locator_strings, int count, enum TestSelector sel)
{
info_base** ibs = new info_basePtr[count];
int i;
for ( i=0; i<count; ibs[i++] = 0 );
info_base* ib = 0;
long ind = first();
while ( ind ) {
ib = (*this)(ind);
if (ib == 0)
throw(stringException("null info_base ptr"));
for ( i=0; i<count; i++ ) {
mtry {
if ( locator_strings[i] && ibs[i] == 0 ) {
switch (sel) {
case LOC:
{
locator_smart_ptr loc(ib, locator_strings[i]);
if ( strcmp( loc.inside_node_locator_str(),
locator_strings[i]) == 0
)
ibs[i] = ib;
}
break;
case GRA:
{
graphic_smart_ptr graphic(ib, locator_strings[i]);
if ( strcmp( graphic.locator(),
locator_strings[i]) == 0
)
ibs[i] = ib;
}
break;
}
}
}
mcatch (mmdbException &,e)
{
} end_try;
}
next(ind);
}
return ibs;
}

View File

@@ -1,151 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: info_lib.h /main/5 1996/09/04 01:37:43 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _info_lib_h
#define _info_lib_h 1
#include "dstr/dlist.h"
#include "dstr/dlist_void_ptr_cell.h"
#include "api/info_base.h"
#include "utility/funcs.h"
#include "schema/object_dict.h"
/*************************************/
// The info_lib class
/*************************************/
class info_lib : public primitive
{
public:
info_lib(char** set_name_array, char** list_name_array,
char* info_lib_dir = 0, char* selected_base_name = 0,
char* info_lib_name = (char*)"", int descriptor = -1);
virtual ~info_lib();
// define a base
Boolean define_info_base( char* base_name,
char* base_desc,
char* spec_file_path
);
// get a base (the manager of a collection of documents)
info_base* get_info_base(const char* info_base_name);
// get number of info bases in the lib
int num_of_bases() { return info_base_list.count(); };
// info_lib path/name
const char* get_info_lib_path() { return info_lib_path; };
const char* get_info_lib_name() { return info_lib_name; };
const char* get_info_lib_uid() { return info_lib_uid; };
// iterator. 0 is the termination value
// can be used to get all base names
long first() { return info_base_list.first(); };
info_base* operator()(long ind) {
return (info_base*)(((dlist_void_ptr_cell*)ind)->void_ptr());
};
void next(long& ind) { info_base_list.next(ind); };
enum TestSelector { LOC, GRA };
info_base* getInfobaseByComponent( const char *locator_string,
enum TestSelector sel);
info_base** getInfobasesByComponent( char **locator_strings,
int count, enum TestSelector sel);
int bad_infobases();
const char* get_bad_infobase_path(int);
const char* get_bad_infobase_name(int);
int descriptor() { return f_descriptor; };
protected:
char info_lib_path[PATHSIZ];
char info_lib_name[PATHSIZ];
char info_lib_uid[UIDSIZ];
dlist info_base_list;
char** set_nm_list;
char** list_nm_list;
object_dict *f_obj_dict;
info_base* _init_info_base( const char* new_db_path,
const char* base_name,
const char* base_desc,
const char* base_uid,
const char* base_locale,
const mm_version& v
);
int f_bad_base_array_size;
int f_bad_info_bases;
char** f_bad_info_base_names;
char** f_bad_info_base_paths;
int f_descriptor;
/*
void define_composites(composite_mgr_t* mgr_ptr,
char* new_db_path,
char** def_strings,
Boolean& base_exist);
*/
};
typedef info_lib* info_libPtr;
#endif

View File

@@ -1,96 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: server.cc /main/3 1996/06/11 17:11:23 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "api/server.h"
#include "utility/db_version.h"
server::server(char* x_infolib_path) :
infolibptr(0), info_base_set_names(0), info_base_list_names(0)
{
if ( x_infolib_path == 0 ) {
throw(stringException("NULL info lib path"));
}
if ( check_and_create_dir(x_infolib_path) == false )
throw(stringException(
form("server: infolib %s does not exist or can't be created", x_infolib_path)
)
);
int len = MIN(strlen(x_infolib_path), PATHSIZ - 1);
*((char *) memcpy(info_lib_dir, x_infolib_path, len) + len) = '\0';
}
server::~server()
{
delete infolibptr;
delete info_base_set_names;
delete info_base_list_names;
}
int server::major_code_version()
{
return MAJOR;
}
int server::minor_code_version()
{
return MINOR;
}
mm_version server::code_version()
{
return mm_version(MAJOR, MINOR);
}

View File

@@ -1,82 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: server.h /main/3 1996/06/11 17:11:28 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _server_h
#define _server_h 1
#include "api/info_lib.h"
#include "api/info_base.h"
#include "mgrs/managers.h"
class server
{
public:
server(char* x_info_lib_path);
~server();
info_lib* infolib_ptr() { return infolibptr; };
int major_code_version() ;
int minor_code_version() ;
mm_version code_version();
protected:
char info_lib_dir[PATHSIZ];
info_lib* infolibptr;
char** info_base_set_names;
char** info_base_list_names;
managers internal_managers;
};
#endif

View File

@@ -1,343 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: smart_ptr.cc /main/4 1996/06/11 17:11:33 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "api/smart_ptr.h"
#include "object/compressed_pstring.h"
smart_ptr::smart_ptr(info_lib* lib_ptr,
const char* ibase_name,
int composite_pos,
const handler& query_hd,
int index_selector,
composite_tag tag
)
{
info_base* ibase = lib_ptr -> get_info_base(ibase_name);
if ( ibase == 0 ) {
throw(stringException(
form("unknown base %s in %s\n", ibase_name,
lib_ptr -> get_info_lib_path()
)));
}
//debug(cerr, ibase -> num_of_docs());
switch (tag) {
case SET:
{
cset_handlerPtr set_ptr = ibase -> get_set(composite_pos);
if ( set_ptr == 0 )
throw(stringException("NULL set ptr"));
_init((*set_ptr)->get_first_oid(query_hd, index_selector),
set_ptr -> its_store()
);
}
break;
case LIST:
{
dl_list_handlerPtr list_ptr = ibase -> get_list(composite_pos);
if ( list_ptr == 0 )
throw(stringException("NULL set ptr"));
_init((*list_ptr)->get_first_oid(query_hd, index_selector),
list_ptr -> its_store()
);
}
break;
default:
throw(stringException("unknown tag"));
}
}
smart_ptr::smart_ptr(info_base* ibase,
int composite_pos,
const handler& query_hd,
int index_selector,
composite_tag tag
)
{
switch (tag) {
case SET:
{
cset_handlerPtr set_ptr = ibase -> get_set(composite_pos);
if ( set_ptr == 0 )
throw(stringException("NULL set ptr"));
_init((*set_ptr)->get_first_oid(query_hd, index_selector),
set_ptr -> its_store()
);
}
break;
case LIST:
{
dl_list_handlerPtr list_ptr = ibase -> get_list(composite_pos);
if ( list_ptr == 0 )
throw(stringException("NULL set ptr"));
_init((*list_ptr)->get_first_oid(query_hd, index_selector),
list_ptr -> its_store()
);
}
break;
default:
throw(stringException("unknown tag"));
}
}
/* inlined */
/*
smart_ptr::smart_ptr()
{
}
smart_ptr::~smart_ptr()
{
}
*/
void smart_ptr::_init(const oid_t& id, const abs_storage* x)
{
//MESSAGE(cerr, "smart_ptr::_init()");
obj_id.become(id);
//obj_id.asciiOut(cerr); cerr << "\n";
store = (abs_storage*)x;
obj_ptr = 0;
handler::operator->();
//obj_id.asciiOut(cerr); cerr << "\n";
//debug(cerr, int(obj_ptr));
//MESSAGE(cerr, "smart_ptr::_init() done");
}
handler* smart_ptr::get_handler(int i, c_code_t code)
{
handler* x = _get_component(i);
x -> operator->();
if ( x -> its_oid().ccode() != code )
throw(stringException("invalid node data class code"));
return x;
}
int smart_ptr::get_int(int i)
{
handler* x = get_handler(i, INTEGER_CODE);
int y= (*(integer_handler*)x) -> get();
delete x;
return y;
}
const char* smart_ptr::get_string(int i, buffer& buf)
{
handler* x = _get_component(i);
x -> operator->(); // this will bring the its_oid field up-to-date
char* str;
switch ( x -> its_oid().ccode() ) {
case STRING_CODE:
{
str = (*(pstring_handler*)x) -> get(buf);
break;
}
case COMPRESSED_STRING_CODE:
{
str = (*(compressed_pstring_handler*)x) -> get(buf);
break;
}
default:
throw(stringException("invalid node data class code"));
}
delete x;
return str;
}
const char* smart_ptr::get_string(int i)
{
handler* x = _get_component(i);
x -> operator->(); // this will bring the its_oid field up-to-date
char* str;
switch ( x -> its_oid().ccode() ) {
case STRING_CODE:
{
str = (*(pstring_handler*)x) -> get();
break;
}
case COMPRESSED_STRING_CODE:
{
str = (*(compressed_pstring_handler*)x) -> get();
break;
}
default:
throw(stringException("invalid node data class code"));
}
delete x;
return str;
}
int smart_ptr::get_string_size(int i)
{
handler* x = _get_component(i);
x -> operator->(); // this will bring the its_oid field up-to-date
int y ;
switch ( x -> its_oid().ccode() ) {
case STRING_CODE:
y = (*(pstring_handler*)x) -> size();
break;
case COMPRESSED_STRING_CODE:
y = (*(compressed_pstring_handler*)x) -> size();
break;
default:
throw(stringException("invalid node data class code"));
}
delete x;
return y;
}
oid_t smart_ptr::get_oid(int i)
{
handler* x = get_handler(i, OID_CODE);
oid_t y = (*(oid_handler*)x) -> my_coid();
delete x;
return y;
}
void smart_ptr::update_oid(int i, const oid_t& x)
{
static char buf[64];
handler* z = get_handler(i, OID_CODE);
oid_handler* y = (oid_handler*)z;
snprintf(buf, sizeof(buf), "%d.%d\n", x.ccode(), (int)x.icode());
istringstream in(buf);
(*y) -> asciiIn(in);
delete y;
}
void smart_ptr::update_string(int i, istream& in)
{
handler* x = _get_component(i);
x -> operator->(); // this will bring the its_oid field up-to-date
io_status ok;
switch ( x -> its_oid().ccode() ) {
case STRING_CODE:
ok =(*(pstring_handler*)x) -> asciiIn(in);
break;
case COMPRESSED_STRING_CODE:
ok =(*(compressed_pstring_handler*)x) -> _asciiIn(in);
break;
default:
throw(stringException("invalid node data class code"));
}
if(ok) { ; }
delete x;
}
void smart_ptr::update_string(int i, const char* buf, int size)
{
handler* x = _get_component(i);
x -> operator->(); // this will bring the its_oid field up-to-date
switch ( x -> its_oid().ccode() ) {
case STRING_CODE:
(*(pstring_handler*)x) -> update(buf, size);
break;
case COMPRESSED_STRING_CODE:
(*(compressed_pstring_handler*)x) -> _asciiIn(buf, size);
break;
default:
throw(stringException("invalid node data class code"));
}
delete x;
}

View File

@@ -1,104 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: smart_ptr.h /main/5 1996/06/11 17:11:38 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _smart_ptr_h
#define _smart_ptr_h 1
#include "object/cset.h"
#include "object/dl_list.h"
#include "object/integer.h"
#include "api/info_lib.h"
#include "mgrs/query_mgr.h"
class smart_ptr : public composite_handler
{
public:
enum composite_tag { SET, LIST };
smart_ptr(info_lib* lib_ptr,
const char* infobase_name, int composite_position,
const handler& query_hd, int index_selector, composite_tag);
smart_ptr(info_base* base_ptr, int composite_position,
const handler& query_hd, int index_selector, composite_tag);
smart_ptr(abs_storage* st, const oid_t& x)
/*: composite_handler(c)*/
{
_init(*(oid_t*)&x, st);
};
smart_ptr() {};
virtual ~smart_ptr() {};
int get_int(int component_index);
const char* get_string(int component_index);
const char* get_string(int component_index, buffer&);
int get_string_size(int component_index);
oid_t get_oid(int component_index);
void update_oid(int component_index, const oid_t& x);
void update_string(int component_index, istream& in);
void update_string(int component_index, const char* buf, int size);
protected:
void _init(const oid_t& id, const abs_storage*);
handler* get_handler(int component_index, c_code_t code);
};
typedef smart_ptr* smart_ptrPtr;
#endif

View File

@@ -1,177 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: transaction.C /main/5 1996/08/21 15:51:19 drk $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "api/transaction.h"
#include "dstr/bset.h"
#include "mgrs/misc.h"
transaction* g_transac = 0;
//////////////////////////////////////
// application functions
//////////////////////////////////////
inline void begin_trans(const void* x)
{
((page_storage*)x) -> begin_trans();
}
inline void end_trans(const void* x)
{
((page_storage*)x) -> commit_trans();
}
inline void roll_back(const void* x)
{
((page_storage*)x) -> roll_back();
}
inline void psync(const void* x)
{
((page_storage*)x) -> sync();
}
inline void commit_object(const void* x)
{
name_oid_t *y = (name_oid_t*)x;
if (y==0)
throw(stringException("null pointer"));
handler z(y->v_oid, y->v_store);
z.commit();
}
inline void set_updated_false_f(const void* x)
{
name_oid_t *y = (name_oid_t*)x;
if (y==0)
throw(stringException("null pointer"));
handler z(y->v_oid, y->v_store);
z -> set_mode(UPDATE, false);
}
//////////////////////////////////
//
//
//////////////////////////////////
transaction::transaction() :
v_store_array(), v_updated_objects(oid_storage_eq, oid_storage_ls)
{
}
transaction::~transaction()
{
}
void transaction::book(abs_storage* x)
{
if ( v_store_array.member(x) == 0 ) {
((page_storage*)x) -> begin_trans();
v_store_array.insert(x);
}
}
void transaction::book(oid_t& id, abs_storage* x)
{
char _dummy[1]; _dummy[0] = 0;
name_oid_t* y = new name_oid_t(_dummy, id, x);
if ( v_updated_objects.insert(y) == false )
delete y;
if ( v_store_array.member(x) == 0 ) {
debug(cerr, id);
debug(cerr, x -> my_path());
debug(cerr, x -> my_name());
throw(stringException("store is not in transaction mode"));
}
}
void transaction::begin()
{
v_store_array.apply(begin_trans);
g_transac = this;
//MESSAGE(cerr, "g_tr in transaction.C");
//debug(cerr, int(g_transac));
}
void transaction::end()
{
//MESSAGE(cerr, "transaction::end()");
v_updated_objects.apply(commit_object);
v_store_array.apply(end_trans);
v_updated_objects.del_elements(delete_name_oid_rec_f);
g_transac = 0;
//MESSAGE(cerr, "transaction::end() done");
}
void transaction::abort()
{
v_updated_objects.del_elements(delete_name_oid_rec_f);
g_transac = 0;
}
void transaction::rollback()
{
v_updated_objects.apply(set_updated_false_f);
v_store_array.apply(roll_back);
}
void transaction::sync()
{
v_updated_objects.apply(commit_object);
v_store_array.apply(psync);
g_transac = 0;
}

View File

@@ -1,85 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: transaction.h /main/4 1996/06/11 17:11:50 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _transaction_h
#define _transaction_h 1
#include <stdarg.h>
#include "dstr/bset.h"
#include "object/oid_t.h"
#include "storage/page_storage.h"
#include "mgrs/misc.h"
class transaction
{
public:
transaction();
~transaction();
void book(oid_t&, abs_storage*);
void book(abs_storage*);
void begin();
void end();
void sync(); // checkpoint in odmg93
void rollback();
void abort();
protected:
bset v_store_array;
bset v_updated_objects;
};
extern transaction* g_transac;
#endif

View File

@@ -1,92 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: utility.cc /main/4 1996/06/11 17:11:55 cde-hal $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "api/utility.h"
#include "misc/unique_id.h"
typedef char* charPtr;
int load( info_base* base, char* container_nm )
{
return _load( base, container_nm, cin );
}
int load( info_base* base, char* container_nm, char* data_path )
{
fstream in(data_path, ios::in);
return _load( base, container_nm, in );
}
int load( info_base* base, char** argv, int argc )
{
int ok = 0;
char* container_nm, *data_path;
for ( int i=0; i<argc; i += 2 ) {
container_nm = argv[i];
data_path = argv[i+1];
ok |= load( base, container_nm, data_path );
}
return ok;
}
int _load( info_base* base, char* container_nm, istream& in )
{
handler* x = (base -> get_obj_dict()).get_handler(container_nm);
if ( x ) {
(*(cset_handler*)x) -> asciiIn(in);
return 0;
} else
return -1;
}

View File

@@ -1,69 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: utility.h /main/5 1996/08/21 15:51:23 drk $
*
* Copyright (c) 1992 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _utility_h
#define _utility_h 1
#ifdef C_API
#include "utility/c_stringstream.h"
#else
#include <sstream>
#endif
#include <string.h>
#include "utility/debug.h"
#include "api/info_lib.h"
int _load( info_base*, char* container_nm, istream& in );
int load( info_base*, char* container_nm, char* data_path );
int load( info_base*, char* container_nm ); // from cin
int load( info_base*, char** argv, int argc );
#endif

View File

@@ -1,39 +0,0 @@
XCOMM $XConsortium: Imakefile /main/9 1996/08/21 15:51:27 drk $
XCOMM ** WARNING **
XCOMM
XCOMM The files named here may appear in many different Imakefiles.
XCOMM If you add or remove a file, be sure to update all locations.
XCOMM It's unfortunate, but all this redundancy serves a purpose.
XCOMM
XCOMM Other possible locations are:
XCOMM .../lib/DtMmdb/Imakefile
XCOMM .../lib/DtMmdb/<subdir>/Imakefile
XCOMM .../programs/dtinfo/mmdb/Imakefile
XCOMM .../programs/dtinfo/mmdb/<subdir>/Imakefile
#define DoNormalLib NormalLibDtMmdb
#define DoSharedLib SharedLibDtMmdb
#define DoDebugLib DebugLibDtMmdb
#define DoProfileLib ProfileLibDtMmdb
#define LibName DtMmdb
#define SoRev SODTMMDBREV
#define LibHeaders NO
#define LibCreate NO
#define LargePICTable YES
#define CplusplusSource YES
DEPEND_DEFINES = $(DEPENDDEFINES)
XCOMM In DtMmdb we compile as C_API sources.
DEFINES = -DC_API
INCLUDES = $(CXXDEPENDINCLUDES) -I.. $(EXCEPTIONS_INCLUDES)
SRCS = mmdb_btree.C
OBJS = $(SRCS:.C=.o)
#include <Library.tmpl>
SubdirLibraryRule($(OBJS))
DependTarget()

View File

@@ -1,7 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
noinst_LTLIBRARIES = libbtree.la
libbtree_la_CXXFLAGS = -I..
libbtree_la_SOURCES = mmdb_btree.C

View File

@@ -1,195 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: mmdb_btree.cc /main/3 1996/06/11 17:14:32 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "btree/mmdb_btree.h"
btree::btree(const char* store_name)
{
// let the package figure out all these parameters
btree_info.flags = 0;
btree_info.cachesize = 0;
btree_info.maxkeypage = 0;
btree_info.minkeypage = 0;
btree_info.psize = 0;
btree_info.compare = NULL;
btree_info.prefix = NULL;
btree_info.lorder = 0;
key_DBT.data = 0;
key_DBT.size = 0;
int mode = O_CREAT|O_RDWR;
//btree_DB = dbopen(store_name, mode, 0640, DB_BTREE, &btree_info);
btree_DB = dbopen(store_name, mode, 0640, DB_BTREE, NULL);
if ( btree_DB == 0 )
throw(stringException("btree dbopen failed"));
}
btree::~btree()
{
if ( btree_DB->sync(btree_DB, 0) == RET_ERROR ) {
cerr << "btree sync failed";
std::exit(1);
}
if ( btree_DB->close(btree_DB) == RET_ERROR ) {
cerr << "btree close failed";
std::exit(1);
}
}
void btree::clean()
{
throw(stringException("void btree::clean(): not implemented yet"));
}
void btree::data_t_2_DBT(data_t& w)
{
switch (w.flag) {
case data_t::INT:
key_DBT.data = &w.key.int_key;
key_DBT.size = sizeof(w.key.int_key);
break;
case data_t::STRING:
key_DBT.data = w.key.str_key;
key_DBT.size = strlen(w.key.str_key);
break;
case data_t::VOID:
throw(stringException("btree data_t_2_DBT: unknown key type"));
}
}
Boolean btree::insert(data_t& w)
{
data_t_2_DBT(w);
DBT data_DBT;
data_DBT.data = &w.dt;
data_DBT.size = sizeof(w.dt);
//int status = btree_DB->put(btree_DB, &key_DBT, &data_DBT, R_NOOVERWRITE);
int status = btree_DB->put(btree_DB, &key_DBT, &data_DBT, 0);
switch (status) {
case RET_ERROR:
throw(stringException("btree put failed"));
break;
case RET_SPECIAL:
throw(stringException("btree put: dup key"));
break;
case RET_SUCCESS:
return true;
}
return false;
}
Boolean btree::remove(data_t& w)
{
data_t_2_DBT(w);
int status = btree_DB->del(btree_DB, &key_DBT, 0);
switch (status) {
case RET_ERROR:
throw(stringException("btree delete failed"));
break;
case RET_SPECIAL:
case RET_SUCCESS:
return true;
}
return false;
}
Boolean btree::member(data_t& w)
{
data_t_2_DBT(w);
DBT data_DBT;
int status = btree_DB->get(btree_DB, &key_DBT, &data_DBT, 0);
switch (status) {
case RET_ERROR:
throw(stringException("btree get failed"));
break;
case RET_SPECIAL:
return false;
case RET_SUCCESS:
if ( data_DBT.size != sizeof(w.dt) )
throw(stringException("btree get: tree corrupted"));
memcpy((char*)&w.dt, data_DBT.data, data_DBT.size);
return true;
}
return false;
}
ostream& btree::asciiOut(ostream& out)
{
return out;
}
istream& btree::asciiIn(istream& in)
{
return in;
}

View File

@@ -1,102 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/*
* $XConsortium: mmdb_btree.h /main/3 1996/06/11 17:14:37 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _btree_h
#define _btree_h 1
#include "storage/unixf_storage.h"
#include "dynhash/data_t.h"
#if defined(SVR4) || defined(__linux__)
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#else
#include <sys/file.h>
#include <sys/types.h>
#include <limits.h>
#endif
#include <cstdlib>
#include "dstr/index_agent.h"
#include "btree_berkeley/db.h"
class btree : public index_agent
{
public:
btree(const char* btree_file_name );
~btree();
void clean();
Boolean insert(data_t& w);
Boolean remove(data_t& w);
Boolean member(data_t& w);
ostream& asciiOut(ostream& out);
istream& asciiIn(istream& in);
protected:
DBT key_DBT;
DB* btree_DB;
BTREEINFO btree_info;
protected:
void data_t_2_DBT(data_t& w);
};
#endif

View File

@@ -1,63 +0,0 @@
XCOMM $XConsortium: Imakefile /main/8 1996/08/21 15:51:32 drk $
XCOMM ** WARNING **
XCOMM
XCOMM The files named here may appear in many different Imakefiles.
XCOMM If you add or remove a file, be sure to update all locations.
XCOMM It's unfortunate, but all this redundancy serves a purpose.
XCOMM
XCOMM Other possible locations are:
XCOMM .../lib/DtMmdb/Imakefile
XCOMM .../lib/DtMmdb/<subdir>/Imakefile
XCOMM .../programs/dtinfo/mmdb/Imakefile
XCOMM .../programs/dtinfo/mmdb/<subdir>/Imakefile
#define DoNormalLib NormalLibDtMmdb
#define DoSharedLib SharedLibDtMmdb
#define DoDebugLib DebugLibDtMmdb
#define DoProfileLib ProfileLibDtMmdb
#define LibName DtMmdb
#define SoRev SODTMMDBREV
#define LibHeaders NO
#define LibCreate NO
#define LargePICTable YES
DEPEND_DEFINES = $(DEPENDDEFINES)
DEFINES = -DMEMMOVE
INCLUDES = -I../ -I.
XCOMM Integretion Berkeley ndbm packege (sun.4.1.3 version) to mmdb:
XCOMM 9/15/93. qfc
XCOMM
XCOMM cp -r berkeley.db/PORT/sun.4.1.3/{clib,include,sys}/?* .
XCOMM
XCOMM change a few "include" lines in db.h, snprintf.h and mmmove.h.
XCOMM
XCOMM Merge Notes: 9/15/93. qfc
XCOMM SRCS1: btree code. from berkeley.db/btree
XCOMM SRCS2: clib code. from berkeley.db/PORT/sun.4.1.3/clib
XCOMM SRCS3: mpool code. from berkeley.db/mpool
XCOMM SRCS4: db code. from berkeley.db/db
SRCS1 = bt_close.c bt_conv.c bt_debug.c bt_delete.c bt_get.c \
bt_open.c bt_overflow.c bt_page.c bt_put.c bt_search.c \
bt_seq.c bt_split.c bt_stack.c bt_utils.c
#ifdef AIXArchitecture
SRCS2 = mktemp.c realloc.c snprintf.c
#else
SRCS2 = memmove.c mktemp.c realloc.c snprintf.c
#endif
SRCS3 = mpool.c
SRCS4 = db.c
SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS4)
OBJS = $(SRCS1:.c=.o) $(SRCS2:.c=.o) $(SRCS3:.c=.o) $(SRCS4:.c=.o)
#include <Library.tmpl>
SubdirLibraryRule($(OBJS))
DependTarget()

View File

@@ -1,16 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
noinst_LTLIBRARIES = libbtree_berkeley.la
libbtree_berkeley_la_CFLAGS = -DMEMMOVE -I..
libbtree_berkeley_la_SOURCES = bt_close.c bt_conv.c bt_debug.c bt_delete.c \
bt_get.c bt_open.c bt_overflow.c bt_page.c \
bt_put.c bt_search.c bt_seq.c bt_split.c \
bt_stack.c bt_utils.c mktemp.c \
realloc.c snprintf.c mpool.c db.c
if AIX
else
libbtree_berkeley_la_SOURCES += memmove.c
endif

View File

@@ -1,227 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: bt_close.c /main/4 1996/06/11 17:12:14 cde-hal $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Mike Olson.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)bt_close.c 8.2 (Berkeley) 9/7/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <db.h>
#include "btree.h"
static int bt_meta __P((BTREE *));
/*
* BT_CLOSE -- Close a btree.
*
* Parameters:
* dbp: pointer to access method
*
* Returns:
* RET_ERROR, RET_SUCCESS
*/
int
__bt_close(DB *dbp)
{
BTREE *t;
int fd;
t = dbp->internal;
/* Toss any page pinned across calls. */
if (t->bt_pinned != NULL) {
mpool_put(t->bt_mp, t->bt_pinned, 0);
t->bt_pinned = NULL;
}
/*
* Delete any already deleted record that we've been saving
* because the cursor pointed to it.
*/
if (ISSET(t, B_DELCRSR) && __bt_crsrdel(t, &t->bt_bcursor))
return (RET_ERROR);
if (__bt_sync(dbp, 0) == RET_ERROR)
return (RET_ERROR);
if (mpool_close(t->bt_mp) == RET_ERROR)
return (RET_ERROR);
if (t->bt_stack)
free(t->bt_stack);
if (t->bt_kbuf)
free(t->bt_kbuf);
if (t->bt_dbuf)
free(t->bt_dbuf);
fd = t->bt_fd;
free(t);
free(dbp);
return (close(fd) ? RET_ERROR : RET_SUCCESS);
}
/*
* BT_SYNC -- sync the btree to disk.
*
* Parameters:
* dbp: pointer to access method
*
* Returns:
* RET_SUCCESS, RET_ERROR.
*/
int
__bt_sync(const DB *dbp, u_int flags)
{
BTREE *t;
int status;
PAGE *h;
void *p = NULL;
t = dbp->internal;
/* Toss any page pinned across calls. */
if (t->bt_pinned != NULL) {
mpool_put(t->bt_mp, t->bt_pinned, 0);
t->bt_pinned = NULL;
}
/* Sync doesn't currently take any flags. */
if (flags != 0) {
errno = EINVAL;
return (RET_ERROR);
}
if (ISSET(t, B_INMEM | B_RDONLY) || !ISSET(t, B_MODIFIED))
return (RET_SUCCESS);
if (ISSET(t, B_METADIRTY) && bt_meta(t) == RET_ERROR)
return (RET_ERROR);
/*
* Nastiness. If the cursor has been marked for deletion, but not
* actually deleted, we have to make a copy of the page, delete the
* key/data item, sync the file, and then restore the original page
* contents.
*/
if (ISSET(t, B_DELCRSR)) {
if ((p = (void*)malloc(t->bt_psize)) == NULL)
return (RET_ERROR);
if ((h = mpool_get(t->bt_mp, t->bt_bcursor.pgno, 0)) == NULL) {
free(p);
return (RET_ERROR);
}
memmove(p, h, t->bt_psize);
if ((status =
__bt_dleaf(t, h, t->bt_bcursor.index)) == RET_ERROR)
goto ecrsr;
mpool_put(t->bt_mp, h, MPOOL_DIRTY);
}
if ((status = mpool_sync(t->bt_mp)) == RET_SUCCESS)
CLR(t, B_MODIFIED);
ecrsr: if (ISSET(t, B_DELCRSR)) {
if ((h = mpool_get(t->bt_mp, t->bt_bcursor.pgno, 0)) == NULL) {
free(p);
return (RET_ERROR);
}
memmove(h, p, t->bt_psize);
free(p);
mpool_put(t->bt_mp, h, MPOOL_DIRTY);
}
return (status);
}
/*
* BT_META -- write the tree meta data to disk.
*
* Parameters:
* t: tree
*
* Returns:
* RET_ERROR, RET_SUCCESS
*/
static int
bt_meta(BTREE *t)
{
BTMETA m;
void *p;
if ((p = mpool_get(t->bt_mp, P_META, 0)) == NULL)
return (RET_ERROR);
/* Fill in metadata. */
m.m_magic = BTREEMAGIC;
m.m_version = BTREEVERSION;
m.m_psize = t->bt_psize;
m.m_free = t->bt_free;
m.m_nrecs = t->bt_nrecs;
m.m_flags = t->bt_flags & SAVEMETA;
memmove(p, &m, sizeof(BTMETA));
mpool_put(t->bt_mp, p, MPOOL_DIRTY);
return (RET_SUCCESS);
}

View File

@@ -1,237 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: bt_conv.c /main/3 1996/06/11 17:12:19 cde-hal $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Mike Olson.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)bt_conv.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <stdio.h>
#include <db.h>
#include "btree.h"
static void mswap __P((PAGE *));
/*
* __BT_BPGIN, __BT_BPGOUT --
* Convert host-specific number layout to/from the host-independent
* format stored on disk.
*
* Parameters:
* t: tree
* pg: page number
* h: page to convert
*/
void
__bt_pgin(void *t, pgno_t pg, void *pp)
{
PAGE *h;
int i, top;
u_char flags;
char *p;
if (!ISSET(((BTREE *)t), B_NEEDSWAP))
return;
if (pg == P_META) {
mswap(pp);
return;
}
h = pp;
BLSWAP(h->pgno);
BLSWAP(h->prevpg);
BLSWAP(h->nextpg);
BLSWAP(h->flags);
BSSWAP(h->lower);
BSSWAP(h->upper);
top = NEXTINDEX(h);
if ((h->flags & P_TYPE) == P_BINTERNAL)
for (i = 0; i < top; i++) {
BSSWAP(h->linp[i]);
p = (char *)GETBINTERNAL(h, i);
BLPSWAP(p);
p += sizeof(size_t);
BLPSWAP(p);
p += sizeof(pgno_t);
if (*(u_char *)p & P_BIGKEY) {
p += sizeof(u_char);
BLPSWAP(p);
p += sizeof(pgno_t);
BLPSWAP(p);
}
}
else if ((h->flags & P_TYPE) == P_BLEAF)
for (i = 0; i < top; i++) {
BSSWAP(h->linp[i]);
p = (char *)GETBLEAF(h, i);
BLPSWAP(p);
p += sizeof(size_t);
BLPSWAP(p);
p += sizeof(size_t);
flags = *(u_char *)p;
if (flags & (P_BIGKEY | P_BIGDATA)) {
p += sizeof(u_char);
if (flags & P_BIGKEY) {
BLPSWAP(p);
p += sizeof(pgno_t);
BLPSWAP(p);
}
if (flags & P_BIGDATA) {
p += sizeof(size_t);
BLPSWAP(p);
p += sizeof(pgno_t);
BLPSWAP(p);
}
}
}
}
void
__bt_pgout(void *t, pgno_t pg, void *pp)
{
PAGE *h;
int i, top;
u_char flags;
char *p;
if (!ISSET(((BTREE *)t), B_NEEDSWAP))
return;
if (pg == P_META) {
mswap(pp);
return;
}
h = pp;
top = NEXTINDEX(h);
if ((h->flags & P_TYPE) == P_BINTERNAL)
for (i = 0; i < top; i++) {
p = (char *)GETBINTERNAL(h, i);
BLPSWAP(p);
p += sizeof(size_t);
BLPSWAP(p);
p += sizeof(pgno_t);
if (*(u_char *)p & P_BIGKEY) {
p += sizeof(u_char);
BLPSWAP(p);
p += sizeof(pgno_t);
BLPSWAP(p);
}
BSSWAP(h->linp[i]);
}
else if ((h->flags & P_TYPE) == P_BLEAF)
for (i = 0; i < top; i++) {
p = (char *)GETBLEAF(h, i);
BLPSWAP(p);
p += sizeof(size_t);
BLPSWAP(p);
p += sizeof(size_t);
flags = *(u_char *)p;
if (flags & (P_BIGKEY | P_BIGDATA)) {
p += sizeof(u_char);
if (flags & P_BIGKEY) {
BLPSWAP(p);
p += sizeof(pgno_t);
BLPSWAP(p);
}
if (flags & P_BIGDATA) {
p += sizeof(size_t);
BLPSWAP(p);
p += sizeof(pgno_t);
BLPSWAP(p);
}
}
BSSWAP(h->linp[i]);
}
BLSWAP(h->pgno);
BLSWAP(h->prevpg);
BLSWAP(h->nextpg);
BLSWAP(h->flags);
BSSWAP(h->lower);
BSSWAP(h->upper);
}
/*
* MSWAP -- Actually swap the bytes on the meta page.
*
* Parameters:
* p: page to convert
*/
static void
mswap(PAGE *pg)
{
char *p;
p = (char *)pg;
BLPSWAP(p); /* m_magic */
p += sizeof(u_long);
BLPSWAP(p); /* m_version */
p += sizeof(u_long);
BLPSWAP(p); /* m_psize */
p += sizeof(u_long);
BLPSWAP(p); /* m_free */
p += sizeof(u_long);
BLPSWAP(p); /* m_nrecs */
p += sizeof(u_long);
BLPSWAP(p); /* m_flags */
p += sizeof(u_long);
}

View File

@@ -1,355 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: bt_debug.c /main/4 1996/10/04 09:54:32 drk $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Mike Olson.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)bt_debug.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <db.h>
#include "btree.h"
#ifdef DEBUG
/*
* BT_DUMP -- Dump the tree
*
* Parameters:
* dbp: pointer to the DB
*/
void
__bt_dump(dbp)
DB *dbp;
{
BTREE *t;
PAGE *h;
pgno_t i;
char *sep;
t = dbp->internal;
(void)fprintf(stderr, "%s: pgsz %ld",
ISSET(t, B_INMEM) ? "memory" : "disk", t->bt_psize);
if (ISSET(t, R_RECNO))
(void)fprintf(stderr, " keys %lu", t->bt_nrecs);
#undef X
#define X(flag, name) \
if (ISSET(t, flag)) { \
(void)fprintf(stderr, "%s%s", sep, name); \
sep = ", "; \
}
if (t->bt_flags) {
sep = " flags (";
X(B_DELCRSR, "DELCRSR");
X(R_FIXLEN, "FIXLEN");
X(B_INMEM, "INMEM");
X(B_NODUPS, "NODUPS");
X(B_RDONLY, "RDONLY");
X(R_RECNO, "RECNO");
X(B_SEQINIT, "SEQINIT");
X(B_METADIRTY,"METADIRTY");
(void)fprintf(stderr, ")\n");
}
#undef X
for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) {
__bt_dpage(h);
(void)mpool_put(t->bt_mp, h, 0);
}
}
/*
* BT_DMPAGE -- Dump the meta page
*
* Parameters:
* h: pointer to the PAGE
*/
void
__bt_dmpage(h)
PAGE *h;
{
BTMETA *m;
char *sep;
m = (BTMETA *)h;
(void)fprintf(stderr, "magic %lx\n", m->m_magic);
(void)fprintf(stderr, "version %lu\n", m->m_version);
(void)fprintf(stderr, "psize %lu\n", m->m_psize);
(void)fprintf(stderr, "free %lu\n", m->m_free);
(void)fprintf(stderr, "nrecs %lu\n", m->m_nrecs);
(void)fprintf(stderr, "flags %lu", m->m_flags);
#undef X
#define X(flag, name) \
if (m->m_flags & flag) { \
(void)fprintf(stderr, "%s%s", sep, name); \
sep = ", "; \
}
if (m->m_flags) {
sep = " (";
X(B_NODUPS, "NODUPS");
X(R_RECNO, "RECNO");
(void)fprintf(stderr, ")");
}
}
/*
* BT_DNPAGE -- Dump the page
*
* Parameters:
* n: page number to dump.
*/
void
__bt_dnpage(dbp, pgno)
DB *dbp;
pgno_t pgno;
{
BTREE *t;
PAGE *h;
t = dbp->internal;
if ((h = mpool_get(t->bt_mp, pgno, 0)) != NULL) {
__bt_dpage(h);
(void)mpool_put(t->bt_mp, h, 0);
}
}
/*
* BT_DPAGE -- Dump the page
*
* Parameters:
* h: pointer to the PAGE
*/
void
__bt_dpage(h)
PAGE *h;
{
BINTERNAL *bi;
BLEAF *bl;
RINTERNAL *ri;
RLEAF *rl;
indx_t cur, top;
char *sep;
(void)fprintf(stderr, " page %ld: (", h->pgno);
#undef X
#define X(flag, name) \
if (h->flags & flag) { \
(void)fprintf(stderr, "%s%s", sep, name); \
sep = ", "; \
}
sep = "";
X(P_BINTERNAL, "BINTERNAL") /* types */
X(P_BLEAF, "BLEAF")
X(P_RINTERNAL, "RINTERNAL") /* types */
X(P_RLEAF, "RLEAF")
X(P_OVERFLOW, "OVERFLOW")
X(P_PRESERVE, "PRESERVE");
(void)fprintf(stderr, ")\n");
#undef X
(void)fprintf(stderr, "\tprev %2ld next %2ld", h->prevpg, h->nextpg);
if (h->flags & P_OVERFLOW)
return;
top = NEXTINDEX(h);
(void)fprintf(stderr, " lower %3d upper %3d nextind %d\n",
h->lower, h->upper, top);
for (cur = 0; cur < top; cur++) {
(void)fprintf(stderr, "\t[%03d] %4d ", cur, h->linp[cur]);
switch(h->flags & P_TYPE) {
case P_BINTERNAL:
bi = GETBINTERNAL(h, cur);
(void)fprintf(stderr,
"size %03ld pgno %03ld", (long)bi->ksize, bi->pgno);
if (bi->flags & P_BIGKEY)
(void)fprintf(stderr, " (indirect)");
else if (bi->ksize)
(void)fprintf(stderr,
" {%.*s}", (int)bi->ksize, bi->bytes);
break;
case P_RINTERNAL:
ri = GETRINTERNAL(h, cur);
(void)fprintf(stderr, "entries %03ld pgno %03ld",
ri->nrecs, ri->pgno);
break;
case P_BLEAF:
bl = GETBLEAF(h, cur);
if (bl->flags & P_BIGKEY)
(void)fprintf(stderr,
"big key page %lu size %lu/",
*(pgno_t *)bl->bytes,
(long)*(size_t *)(bl->bytes + sizeof(pgno_t)));
else if (bl->ksize)
(void)fprintf(stderr, "%s/", bl->bytes);
if (bl->flags & P_BIGDATA)
(void)fprintf(stderr,
"big data page %lu size %lu",
*(pgno_t *)(bl->bytes + bl->ksize),
(long)*(size_t *)(bl->bytes + bl->ksize +
sizeof(pgno_t)));
else if (bl->dsize)
(void)fprintf(stderr, "%.*s",
(int)bl->dsize, bl->bytes + bl->ksize);
break;
case P_RLEAF:
rl = GETRLEAF(h, cur);
if (rl->flags & P_BIGDATA)
(void)fprintf(stderr,
"big data page %lu size %lu",
*(pgno_t *)rl->bytes,
(long)*(size_t *)(rl->bytes + sizeof(pgno_t)));
else if (rl->dsize)
(void)fprintf(stderr,
"%.*s", (int)rl->dsize, rl->bytes);
break;
}
(void)fprintf(stderr, "\n");
}
}
#endif
#ifdef STATISTICS
/*
* BT_STAT -- Gather/print the tree statistics
*
* Parameters:
* dbp: pointer to the DB
*/
void
__bt_stat(dbp)
DB *dbp;
{
extern u_long bt_cache_hit, bt_cache_miss;
extern u_long bt_rootsplit, bt_split, bt_sortsplit;
extern u_long bt_pfxsaved;
BTREE *t;
PAGE *h;
pgno_t i, pcont, pinternal, pleaf;
u_long ifree, lfree, nkeys;
int levels;
t = dbp->internal;
pcont = pinternal = pleaf = 0;
nkeys = ifree = lfree = 0;
for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) {
switch(h->flags & P_TYPE) {
case P_BINTERNAL:
case P_RINTERNAL:
++pinternal;
ifree += h->upper - h->lower;
break;
case P_BLEAF:
case P_RLEAF:
++pleaf;
lfree += h->upper - h->lower;
nkeys += NEXTINDEX(h);
break;
case P_OVERFLOW:
++pcont;
break;
}
(void)mpool_put(t->bt_mp, h, 0);
}
/* Count the levels of the tree. */
for (i = P_ROOT, levels = 0 ;; ++levels) {
h = mpool_get(t->bt_mp, i, 0);
if (h->flags & (P_BLEAF|P_RLEAF)) {
if (levels == 0)
levels = 1;
(void)mpool_put(t->bt_mp, h, 0);
break;
}
i = ISSET(t, R_RECNO) ?
GETRINTERNAL(h, 0)->pgno :
GETBINTERNAL(h, 0)->pgno;
(void)mpool_put(t->bt_mp, h, 0);
}
(void)fprintf(stderr, "%d level%s with %ld keys",
levels, levels == 1 ? "" : "s", nkeys);
if (ISSET(t, R_RECNO))
(void)fprintf(stderr, " (%ld header count)", t->bt_nrecs);
(void)fprintf(stderr,
"\n%lu pages (leaf %ld, internal %ld, overflow %ld)\n",
pinternal + pleaf + pcont, pleaf, pinternal, pcont);
(void)fprintf(stderr, "%ld cache hits, %ld cache misses\n",
bt_cache_hit, bt_cache_miss);
(void)fprintf(stderr, "%ld splits (%ld root splits, %ld sort splits)\n",
bt_split, bt_rootsplit, bt_sortsplit);
pleaf *= t->bt_psize - BTDATAOFF;
if (pleaf)
(void)fprintf(stderr,
"%.0f%% leaf fill (%ld bytes used, %ld bytes free)\n",
((double)(pleaf - lfree) / pleaf) * 100,
pleaf - lfree, lfree);
pinternal *= t->bt_psize - BTDATAOFF;
if (pinternal)
(void)fprintf(stderr,
"%.0f%% internal fill (%ld bytes used, %ld bytes free\n",
((double)(pinternal - ifree) / pinternal) * 100,
pinternal - ifree, ifree);
if (bt_pfxsaved)
(void)fprintf(stderr, "prefix checking removed %lu bytes.\n",
bt_pfxsaved);
}
#endif

View File

@@ -1,340 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: bt_delete.c /main/3 1996/06/11 17:12:29 cde-hal $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Mike Olson.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)bt_delete.c 8.2 (Berkeley) 9/7/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <db.h>
#include "btree.h"
static int bt_bdelete __P((BTREE *, const DBT *));
/*
* __BT_DELETE -- Delete the item(s) referenced by a key.
*
* Parameters:
* dbp: pointer to access method
* key: key to delete
* flags: R_CURSOR if deleting what the cursor references
*
* Returns:
* RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found.
*/
int
__bt_delete(const DB *dbp, const DBT *key, u_int flags)
{
BTREE *t;
int status;
t = dbp->internal;
/* Toss any page pinned across calls. */
if (t->bt_pinned != NULL) {
mpool_put(t->bt_mp, t->bt_pinned, 0);
t->bt_pinned = NULL;
}
if (ISSET(t, B_RDONLY)) {
errno = EPERM;
return (RET_ERROR);
}
switch(flags) {
case 0:
status = bt_bdelete(t, key);
break;
case R_CURSOR:
/*
* If flags is R_CURSOR, delete the cursor; must already have
* started a scan and not have already deleted the record. For
* the delete cursor bit to have been set requires that the
* scan be initialized, so no reason to check.
*/
if (!ISSET(t, B_SEQINIT))
goto einval;
status = ISSET(t, B_DELCRSR) ?
RET_SPECIAL : __bt_crsrdel(t, &t->bt_bcursor);
break;
default:
einval: errno = EINVAL;
return (RET_ERROR);
}
if (status == RET_SUCCESS)
SET(t, B_MODIFIED);
return (status);
}
/*
* BT_BDELETE -- Delete all key/data pairs matching the specified key.
*
* Parameters:
* tree: tree
* key: key to delete
*
* Returns:
* RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found.
*/
static int
bt_bdelete(BTREE *t, const DBT *key)
{
EPG *e, save;
PAGE *h;
pgno_t cpgno, pg;
indx_t cindex;
int deleted, dirty1, dirty2, exact;
/* Find any matching record; __bt_search pins the page. */
if ((e = __bt_search(t, key, &exact)) == NULL)
return (RET_ERROR);
if (!exact) {
mpool_put(t->bt_mp, e->page, 0);
return (RET_SPECIAL);
}
/*
* Delete forward, then delete backward, from the found key. The
* ordering is so that the deletions don't mess up the page refs.
* The first loop deletes the key from the original page, the second
* unpins the original page. In the first loop, dirty1 is set if
* the original page is modified, and dirty2 is set if any subsequent
* pages are modified. In the second loop, dirty1 starts off set if
* the original page has been modified, and is set if any subsequent
* pages are modified.
*
* If find the key referenced by the cursor, don't delete it, just
* flag it for future deletion. The cursor page number is P_INVALID
* unless the sequential scan is initialized, so no reason to check.
* A special case is when the already deleted cursor record was the
* only record found. If so, then the delete opertion fails as no
* records were deleted.
*
* Cycle in place in the current page until the current record doesn't
* match the key or the page is empty. If the latter, walk forward,
* skipping empty pages and repeating until a record doesn't match
* the key or the end of the tree is reached.
*/
cpgno = t->bt_bcursor.pgno;
cindex = t->bt_bcursor.index;
save = *e;
dirty1 = 0;
for (h = e->page, deleted = 0;;) {
dirty2 = 0;
do {
if (h->pgno == cpgno && e->index == cindex) {
if (!ISSET(t, B_DELCRSR)) {
SET(t, B_DELCRSR);
deleted = 1;
}
++e->index;
} else {
if (__bt_dleaf(t, h, e->index)) {
if (h->pgno != save.page->pgno)
mpool_put(t->bt_mp, h, dirty2);
mpool_put(t->bt_mp, save.page, dirty1);
return (RET_ERROR);
}
if (h->pgno == save.page->pgno)
dirty1 = MPOOL_DIRTY;
else
dirty2 = MPOOL_DIRTY;
deleted = 1;
}
} while (e->index < NEXTINDEX(h) && __bt_cmp(t, key, e) == 0);
/*
* Quit if didn't find a match, no next page, or first key on
* the next page doesn't match. Don't unpin the original page
* unless an error occurs.
*/
if (e->index < NEXTINDEX(h))
break;
for (;;) {
if ((pg = h->nextpg) == P_INVALID)
goto done1;
if (h->pgno != save.page->pgno)
mpool_put(t->bt_mp, h, dirty2);
if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) {
mpool_put(t->bt_mp, save.page, dirty1);
return (RET_ERROR);
}
if (NEXTINDEX(h) != 0) {
e->page = h;
e->index = 0;
break;
}
}
if (__bt_cmp(t, key, e) != 0)
break;
}
/*
* Reach here with the original page and the last page referenced
* pinned (they may be the same). Release it if not the original.
*/
done1: if (h->pgno != save.page->pgno)
mpool_put(t->bt_mp, h, dirty2);
/*
* Walk backwards from the record previous to the record returned by
* __bt_search, skipping empty pages, until a record doesn't match
* the key or reach the beginning of the tree.
*/
*e = save;
for (;;) {
if (e->index)
--e->index;
for (h = e->page; e->index; --e->index) {
if (__bt_cmp(t, key, e) != 0)
goto done2;
if (h->pgno == cpgno && e->index == cindex) {
if (!ISSET(t, B_DELCRSR)) {
SET(t, B_DELCRSR);
deleted = 1;
}
} else {
if (__bt_dleaf(t, h, e->index) == RET_ERROR) {
mpool_put(t->bt_mp, h, dirty1);
return (RET_ERROR);
}
if (h->pgno == save.page->pgno)
dirty1 = MPOOL_DIRTY;
deleted = 1;
}
}
if ((pg = h->prevpg) == P_INVALID)
goto done2;
mpool_put(t->bt_mp, h, dirty1);
dirty1 = 0;
if ((e->page = mpool_get(t->bt_mp, pg, 0)) == NULL)
return (RET_ERROR);
e->index = NEXTINDEX(e->page);
}
/*
* Reach here with the last page that was looked at pinned. Release
* it.
*/
done2: mpool_put(t->bt_mp, h, dirty1);
return (deleted ? RET_SUCCESS : RET_SPECIAL);
}
/*
* __BT_DLEAF -- Delete a single record from a leaf page.
*
* Parameters:
* t: tree
* index: index on current page to delete
*
* Returns:
* RET_SUCCESS, RET_ERROR.
*/
int
__bt_dleaf(BTREE *t, PAGE *h, int index)
{
BLEAF *bl;
indx_t *ip, offset;
size_t nbytes;
int cnt;
char *from;
void *to;
/*
* Delete a record from a btree leaf page. Internal records are never
* deleted from internal pages, regardless of the records that caused
* them to be added being deleted. Pages made empty by deletion are
* not reclaimed. They are, however, made available for reuse.
*
* Pack the remaining entries at the end of the page, shift the indices
* down, overwriting the deleted record and its index. If the record
* uses overflow pages, make them available for reuse.
*/
to = bl = GETBLEAF(h, index);
if (bl->flags & P_BIGKEY && __ovfl_delete(t, bl->bytes) == RET_ERROR)
return (RET_ERROR);
if (bl->flags & P_BIGDATA &&
__ovfl_delete(t, bl->bytes + bl->ksize) == RET_ERROR)
return (RET_ERROR);
nbytes = NBLEAF(bl);
/*
* Compress the key/data pairs. Compress and adjust the [BR]LEAF
* offsets. Reset the headers.
*/
from = (char *)h + h->upper;
memmove(from + nbytes, from, (char *)to - from);
h->upper += nbytes;
offset = h->linp[index];
for (cnt = index, ip = &h->linp[0]; cnt--; ++ip)
if (ip[0] < offset)
ip[0] += nbytes;
for (cnt = NEXTINDEX(h) - index; --cnt; ++ip)
ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1];
h->lower -= sizeof(indx_t);
return (RET_SUCCESS);
}

View File

@@ -1,254 +0,0 @@
/*
* CDE - Common Desktop Environment
*
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
*
* These libraries and programs are free software; you can
* redistribute them and/or modify them under the terms of the GNU
* Lesser General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* These libraries and programs are distributed in the hope that
* they will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with these libraries and programs; if not, write
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301 USA
*/
/* $XConsortium: bt_get.c /main/3 1996/06/11 17:12:34 cde-hal $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Mike Olson.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)bt_get.c 8.2 (Berkeley) 9/7/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <db.h>
#include "btree.h"
/*
* __BT_GET -- Get a record from the btree.
*
* Parameters:
* dbp: pointer to access method
* key: key to find
* data: data to return
* flag: currently unused
*
* Returns:
* RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found.
*/
int
__bt_get(const DB *dbp, const DBT *key, DBT *data, u_int flags)
{
BTREE *t;
EPG *e;
int exact, status;
t = dbp->internal;
/* Toss any page pinned across calls. */
if (t->bt_pinned != NULL) {
mpool_put(t->bt_mp, t->bt_pinned, 0);
t->bt_pinned = NULL;
}
/* Get currently doesn't take any flags. */
if (flags) {
errno = EINVAL;
return (RET_ERROR);
}
if ((e = __bt_search(t, key, &exact)) == NULL)
return (RET_ERROR);
if (!exact) {
mpool_put(t->bt_mp, e->page, 0);
return (RET_SPECIAL);
}
/*
* A special case is if we found the record but it's flagged for
* deletion. In this case, we want to find another record with the
* same key, if it exists. Rather than look around the tree we call
* __bt_first and have it redo the search, as __bt_first will not
* return keys marked for deletion. Slow, but should never happen.
*/
if (ISSET(t, B_DELCRSR) && e->page->pgno == t->bt_bcursor.pgno &&
e->index == t->bt_bcursor.index) {
mpool_put(t->bt_mp, e->page, 0);
if ((e = __bt_first(t, key, &exact)) == NULL)
return (RET_ERROR);
if (!exact)
return (RET_SPECIAL);
}
status = __bt_ret(t, e, NULL, data);
/*
* If the user is doing concurrent access, we copied the
* key/data, toss the page.
*/
if (ISSET(t, B_DB_LOCK))
mpool_put(t->bt_mp, e->page, 0);
else
t->bt_pinned = e->page;
return (status);
}
/*
* __BT_FIRST -- Find the first entry.
*
* Parameters:
* t: the tree
* key: the key
*
* Returns:
* The first entry in the tree greater than or equal to key.
*/
EPG *
__bt_first(BTREE *t, const DBT *key, int *exactp)
{
PAGE *h;
EPG *e;
EPG save;
pgno_t cpgno, pg;
indx_t cindex;
int found;
/*
* Find any matching record; __bt_search pins the page. Only exact
* matches are tricky, otherwise just return the location of the key
* if it were to be inserted into the tree.
*/
if ((e = __bt_search(t, key, exactp)) == NULL)
return (NULL);
if (!*exactp)
return (e);
if (ISSET(t, B_DELCRSR)) {
cpgno = t->bt_bcursor.pgno;
cindex = t->bt_bcursor.index;
} else {
cpgno = P_INVALID;
cindex = 0; /* GCC thinks it's uninitialized. */
}
/*
* Walk backwards, skipping empty pages, as long as the entry matches
* and there are keys left in the tree. Save a copy of each match in
* case we go too far. A special case is that we don't return a match
* on records that the cursor references that have already been flagged
* for deletion.
*/
save = *e;
h = e->page;
found = 0;
do {
if (cpgno != h->pgno || cindex != e->index) {
if (save.page->pgno != e->page->pgno) {
mpool_put(t->bt_mp, save.page, 0);
save = *e;
} else
save.index = e->index;
found = 1;
}
/*
* Make a special effort not to unpin the page the last (or
* original) match was on, but also make sure it's unpinned
* if an error occurs.
*/
while (e->index == 0) {
if (h->prevpg == P_INVALID)
goto done1;
if (h->pgno != save.page->pgno)
mpool_put(t->bt_mp, h, 0);
if ((h = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) {
if (h->pgno == save.page->pgno)
mpool_put(t->bt_mp, save.page, 0);
return (NULL);
}
e->page = h;
e->index = NEXTINDEX(h);
}
--e->index;
} while (__bt_cmp(t, key, e) == 0);
/*
* Reach here with the last page that was looked at pinned, which may
* or may not be the same as the last (or original) match page. If
* it's not useful, release it.
*/
done1: if (h->pgno != save.page->pgno)
mpool_put(t->bt_mp, h, 0);
/*
* If still haven't found a record, the only possibility left is the
* next one. Move forward one slot, skipping empty pages and check.
*/
if (!found) {
h = save.page;
if (++save.index == NEXTINDEX(h)) {
do {
pg = h->nextpg;
mpool_put(t->bt_mp, h, 0);
if (pg == P_INVALID) {
*exactp = 0;
return (e);
}
if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
return (NULL);
} while ((save.index = NEXTINDEX(h)) == 0);
save.page = h;
}
if (__bt_cmp(t, key, &save) != 0) {
*exactp = 0;
return (e);
}
}
*e = save;
*exactp = 1;
return (e);
}

Some files were not shown because too many files have changed in this diff Show More