summaryrefslogtreecommitdiff
path: root/Build/source/libs/poppler/poppler-src/goo
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/poppler/poppler-src/goo')
-rw-r--r--Build/source/libs/poppler/poppler-src/goo/GooHash.cc403
-rw-r--r--Build/source/libs/poppler/poppler-src/goo/GooHash.h93
-rw-r--r--Build/source/libs/poppler/poppler-src/goo/GooString.h7
3 files changed, 6 insertions, 497 deletions
diff --git a/Build/source/libs/poppler/poppler-src/goo/GooHash.cc b/Build/source/libs/poppler/poppler-src/goo/GooHash.cc
deleted file mode 100644
index 620803eb603..00000000000
--- a/Build/source/libs/poppler/poppler-src/goo/GooHash.cc
+++ /dev/null
@@ -1,403 +0,0 @@
-//========================================================================
-//
-// GooHash.cc
-//
-// Copyright 2001-2003 Glyph & Cog, LLC
-//
-//========================================================================
-
-//========================================================================
-//
-// Modified under the Poppler project - http://poppler.freedesktop.org
-//
-// All changes made under the Poppler project to this file are licensed
-// under GPL version 2 or later
-//
-// Copyright (C) 2017 Albert Astals Cid <aacid@kde.org>
-// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
-//
-// To see a description of the changes please see the Changelog file that
-// came with your tarball or type make ChangeLog if you are building from git
-//
-//========================================================================
-
-#include <config.h>
-
-#ifdef USE_GCC_PRAGMAS
-#pragma implementation
-#endif
-
-#include "gmem.h"
-#include "GooString.h"
-#include "GooHash.h"
-#include "GooLikely.h"
-
-//------------------------------------------------------------------------
-
-struct GooHashBucket {
- GooString *key;
- union {
- void *p;
- int i;
- } val;
- GooHashBucket *next;
-};
-
-struct GooHashIter {
- int h;
- GooHashBucket *p;
-};
-
-//------------------------------------------------------------------------
-
-GooHash::GooHash(GBool deleteKeysA) {
- int h;
-
- deleteKeys = deleteKeysA;
- size = 7;
- tab = (GooHashBucket **)gmallocn(size, sizeof(GooHashBucket *));
- for (h = 0; h < size; ++h) {
- tab[h] = nullptr;
- }
- len = 0;
-}
-
-GooHash::~GooHash() {
- GooHashBucket *p;
- int h;
-
- for (h = 0; h < size; ++h) {
- while (tab[h]) {
- p = tab[h];
- tab[h] = p->next;
- if (deleteKeys) {
- delete p->key;
- }
- delete p;
- }
- }
- gfree(tab);
-}
-
-void GooHash::add(GooString *key, void *val) {
- GooHashBucket *p;
- int h;
-
- // expand the table if necessary
- if (len >= size) {
- expand();
- }
-
- // add the new symbol
- p = new GooHashBucket;
- p->key = key;
- p->val.p = val;
- h = hash(key);
- p->next = tab[h];
- tab[h] = p;
- ++len;
-}
-
-void GooHash::add(GooString *key, int val) {
- GooHashBucket *p;
- int h;
-
- // expand the table if necessary
- if (len >= size) {
- expand();
- }
-
- // add the new symbol
- p = new GooHashBucket;
- p->key = key;
- p->val.i = val;
- h = hash(key);
- p->next = tab[h];
- tab[h] = p;
- ++len;
-}
-
-void GooHash::replace(GooString *key, void *val) {
- GooHashBucket *p;
- int h;
-
- if ((p = find(key, &h))) {
- p->val.p = val;
- if (deleteKeys) {
- delete key;
- }
- } else {
- add(key, val);
- }
-}
-
-void GooHash::replace(GooString *key, int val) {
- GooHashBucket *p;
- int h;
-
- if ((p = find(key, &h))) {
- p->val.i = val;
- if (deleteKeys) {
- delete key;
- }
- } else {
- add(key, val);
- }
-}
-
-void *GooHash::lookup(GooString *key) {
- GooHashBucket *p;
- int h;
-
- if (!(p = find(key, &h))) {
- return nullptr;
- }
- return p->val.p;
-}
-
-int GooHash::lookupInt(const GooString *key) {
- GooHashBucket *p;
- int h;
-
- if (!(p = find(key, &h))) {
- return 0;
- }
- return p->val.i;
-}
-
-void *GooHash::lookup(const char *key) {
- GooHashBucket *p;
- int h;
-
- if (!(p = find(key, &h))) {
- return nullptr;
- }
- return p->val.p;
-}
-
-int GooHash::lookupInt(const char *key) {
- GooHashBucket *p;
- int h;
-
- if (!(p = find(key, &h))) {
- return 0;
- }
- return p->val.i;
-}
-
-void *GooHash::remove(GooString *key) {
- GooHashBucket *p;
- GooHashBucket **q;
- void *val;
- int h;
-
- if (!(p = find(key, &h))) {
- return nullptr;
- }
- q = &tab[h];
- while (*q != p) {
- q = &((*q)->next);
- }
- *q = p->next;
- if (deleteKeys) {
- delete p->key;
- }
- val = p->val.p;
- delete p;
- --len;
- return val;
-}
-
-int GooHash::removeInt(GooString *key) {
- GooHashBucket *p;
- GooHashBucket **q;
- int val;
- int h;
-
- if (!(p = find(key, &h))) {
- return 0;
- }
- q = &tab[h];
- while (*q != p) {
- q = &((*q)->next);
- }
- *q = p->next;
- if (deleteKeys) {
- delete p->key;
- }
- val = p->val.i;
- delete p;
- --len;
- return val;
-}
-
-void *GooHash::remove(const char *key) {
- GooHashBucket *p;
- GooHashBucket **q;
- void *val;
- int h;
-
- if (!(p = find(key, &h))) {
- return nullptr;
- }
- q = &tab[h];
- while (*q != p) {
- q = &((*q)->next);
- }
- *q = p->next;
- if (deleteKeys) {
- delete p->key;
- }
- val = p->val.p;
- delete p;
- --len;
- return val;
-}
-
-int GooHash::removeInt(const char *key) {
- GooHashBucket *p;
- GooHashBucket **q;
- int val;
- int h;
-
- if (!(p = find(key, &h))) {
- return 0;
- }
- q = &tab[h];
- while (*q != p) {
- q = &((*q)->next);
- }
- *q = p->next;
- if (deleteKeys) {
- delete p->key;
- }
- val = p->val.i;
- delete p;
- --len;
- return val;
-}
-
-void GooHash::startIter(GooHashIter **iter) {
- *iter = new GooHashIter;
- (*iter)->h = -1;
- (*iter)->p = nullptr;
-}
-
-GBool GooHash::getNext(GooHashIter **iter, GooString **key, void **val) {
- if (!*iter) {
- return gFalse;
- }
- if ((*iter)->p) {
- (*iter)->p = (*iter)->p->next;
- }
- while (!(*iter)->p) {
- if (++(*iter)->h == size) {
- delete *iter;
- *iter = nullptr;
- return gFalse;
- }
- (*iter)->p = tab[(*iter)->h];
- }
- *key = (*iter)->p->key;
- *val = (*iter)->p->val.p;
- return gTrue;
-}
-
-GBool GooHash::getNext(GooHashIter **iter, GooString **key, int *val) {
- if (!*iter) {
- return gFalse;
- }
- if ((*iter)->p) {
- (*iter)->p = (*iter)->p->next;
- }
- while (!(*iter)->p) {
- if (++(*iter)->h == size) {
- delete *iter;
- *iter = nullptr;
- return gFalse;
- }
- (*iter)->p = tab[(*iter)->h];
- }
- *key = (*iter)->p->key;
- *val = (*iter)->p->val.i;
- return gTrue;
-}
-
-void GooHash::killIter(GooHashIter **iter) {
- delete *iter;
- *iter = nullptr;
-}
-
-void GooHash::expand() {
- GooHashBucket **oldTab;
- GooHashBucket *p;
- int oldSize, h, i;
-
- oldSize = size;
- oldTab = tab;
- size = 2*size + 1;
- tab = (GooHashBucket **)gmallocn(size, sizeof(GooHashBucket *));
- for (h = 0; h < size; ++h) {
- tab[h] = nullptr;
- }
- for (i = 0; i < oldSize; ++i) {
- while (oldTab[i]) {
- p = oldTab[i];
- oldTab[i] = oldTab[i]->next;
- h = hash(p->key);
- p->next = tab[h];
- tab[h] = p;
- }
- }
- gfree(oldTab);
-}
-
-GooHashBucket *GooHash::find(const GooString *key, int *h) {
- GooHashBucket *p;
-
- if (unlikely(!key))
- return nullptr;
-
- *h = hash(key);
- for (p = tab[*h]; p; p = p->next) {
- if (!p->key->cmp(key)) {
- return p;
- }
- }
- return nullptr;
-}
-
-GooHashBucket *GooHash::find(const char *key, int *h) {
- GooHashBucket *p;
-
- *h = hash(key);
- for (p = tab[*h]; p; p = p->next) {
- if (!p->key->cmp(key)) {
- return p;
- }
- }
- return nullptr;
-}
-
-int GooHash::hash(const GooString *key) {
- const char *p;
- unsigned int h;
- int i;
-
- h = 0;
- for (p = key->getCString(), i = 0; i < key->getLength(); ++p, ++i) {
- h = 17 * h + (int)(*p & 0xff);
- }
- return (int)(h % size);
-}
-
-int GooHash::hash(const char *key) {
- const char *p;
- unsigned int h;
-
- h = 0;
- for (p = key; *p; ++p) {
- h = 17 * h + (int)(*p & 0xff);
- }
- return (int)(h % size);
-}
diff --git a/Build/source/libs/poppler/poppler-src/goo/GooHash.h b/Build/source/libs/poppler/poppler-src/goo/GooHash.h
deleted file mode 100644
index 57f883c6898..00000000000
--- a/Build/source/libs/poppler/poppler-src/goo/GooHash.h
+++ /dev/null
@@ -1,93 +0,0 @@
-//========================================================================
-//
-// GooHash.h
-//
-// Copyright 2001-2003 Glyph & Cog, LLC
-//
-//========================================================================
-
-//========================================================================
-//
-// Modified under the Poppler project - http://poppler.freedesktop.org
-//
-// All changes made under the Poppler project to this file are licensed
-// under GPL version 2 or later
-//
-// Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
-// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
-//
-// To see a description of the changes please see the Changelog file that
-// came with your tarball or type make ChangeLog if you are building from git
-//
-//========================================================================
-
-#ifndef GHASH_H
-#define GHASH_H
-
-#ifdef USE_GCC_PRAGMAS
-#pragma interface
-#endif
-
-#include "gtypes.h"
-
-class GooString;
-struct GooHashBucket;
-struct GooHashIter;
-
-//------------------------------------------------------------------------
-
-class GooHash {
-public:
-
- GooHash(GBool deleteKeysA = gFalse);
- ~GooHash();
- void add(GooString *key, void *val);
- void add(GooString *key, int val);
- void replace(GooString *key, void *val);
- void replace(GooString *key, int val);
- void *lookup(GooString *key);
- int lookupInt(const GooString *key);
- void *lookup(const char *key);
- int lookupInt(const char *key);
- void *remove(GooString *key);
- int removeInt(GooString *key);
- void *remove(const char *key);
- int removeInt(const char *key);
- int getLength() { return len; }
- void startIter(GooHashIter **iter);
- GBool getNext(GooHashIter **iter, GooString **key, void **val);
- GBool getNext(GooHashIter **iter, GooString **key, int *val);
- void killIter(GooHashIter **iter);
-
-private:
- GooHash(const GooHash &other);
- GooHash& operator=(const GooHash &other);
-
- void expand();
- GooHashBucket *find(const GooString *key, int *h);
- GooHashBucket *find(const char *key, int *h);
- int hash(const GooString *key);
- int hash(const char *key);
-
- GBool deleteKeys; // set if key strings should be deleted
- int size; // number of buckets
- int len; // number of entries
- GooHashBucket **tab;
-};
-
-#define deleteGooHash(hash, T) \
- do { \
- GooHash *_hash = (hash); \
- { \
- GooHashIter *_iter; \
- GooString *_key; \
- void *_p; \
- _hash->startIter(&_iter); \
- while (_hash->getNext(&_iter, &_key, &_p)) { \
- delete (T*)_p; \
- } \
- delete _hash; \
- } \
- } while(0)
-
-#endif
diff --git a/Build/source/libs/poppler/poppler-src/goo/GooString.h b/Build/source/libs/poppler/poppler-src/goo/GooString.h
index 87fd5a8559b..78ebd85b81a 100644
--- a/Build/source/libs/poppler/poppler-src/goo/GooString.h
+++ b/Build/source/libs/poppler/poppler-src/goo/GooString.h
@@ -20,7 +20,7 @@
// Copyright (C) 2008-2010, 2012, 2014, 2017 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2012-2014 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2013 Jason Crain <jason@aquaticape.us>
-// Copyright (C) 2015 Adam Reichold <adam.reichold@t-online.de>
+// Copyright (C) 2015, 2018 Adam Reichold <adam.reichold@t-online.de>
// Copyright (C) 2016 Jakub Alba <jakubalba@gmail.com>
// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
@@ -39,6 +39,7 @@
#include <stdarg.h>
#include <stdlib.h> // for NULL
+#include <string>
#include "gtypes.h"
#ifdef __clang__
@@ -171,6 +172,10 @@ public:
// The caller owns the return value
GooString *sanitizedName(GBool psmode) const;
+ // Conversion from and to std::string
+ explicit GooString(const std::string& str) : GooString(str.data(), str.size()) {}
+ std::string toStr() const { return std::string(getCString(), getLength()); }
+
private:
GooString(const GooString &other);
GooString& operator=(const GooString &other);