Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Unified Diff: icu46/source/i18n/nfrlist.h

Issue 5516007: Check in the pristine copy of ICU 4.6... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « icu46/source/i18n/name2uni.cpp ('k') | icu46/source/i18n/nfrs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: icu46/source/i18n/nfrlist.h
===================================================================
--- icu46/source/i18n/nfrlist.h (revision 0)
+++ icu46/source/i18n/nfrlist.h (revision 0)
@@ -0,0 +1,97 @@
+/*
+******************************************************************************
+* Copyright (C) 1997-2008, International Business Machines
+* Corporation and others. All Rights Reserved.
+******************************************************************************
+* file name: nfrlist.h
+* encoding: US-ASCII
+* tab size: 8 (not used)
+* indentation:4
+*
+* Modification history
+* Date Name Comments
+* 10/11/2001 Doug Ported from ICU4J
+*/
+
+#ifndef NFRLIST_H
+#define NFRLIST_H
+
+#include "unicode/rbnf.h"
+
+#if U_HAVE_RBNF
+
+#include "unicode/uobject.h"
+#include "nfrule.h"
+
+#include "cmemory.h"
+
+U_NAMESPACE_BEGIN
+
+// unsafe class for internal use only. assume memory allocations succeed, indexes are valid.
+// should be a template, but we can't use them
+
+class NFRuleList : public UMemory {
+protected:
+ NFRule** fStuff;
+ uint32_t fCount;
+ uint32_t fCapacity;
+public:
+ NFRuleList(uint32_t capacity = 10)
+ : fStuff(capacity ? (NFRule**)uprv_malloc(capacity * sizeof(NFRule*)) : NULL)
+ , fCount(0)
+ , fCapacity(capacity) {};
+ ~NFRuleList() {
+ if (fStuff) {
+ for(uint32_t i = 0; i < fCount; ++i) {
+ delete fStuff[i];
+ }
+ uprv_free(fStuff);
+ }
+ }
+ NFRule* operator[](uint32_t index) const { return fStuff != NULL ? fStuff[index] : NULL; }
+ NFRule* remove(uint32_t index) {
+ if (fStuff == NULL) {
+ return NULL;
+ }
+ NFRule* result = fStuff[index];
+ fCount -= 1;
+ for (uint32_t i = index; i < fCount; ++i) { // assumes small arrays
+ fStuff[i] = fStuff[i+1];
+ }
+ return result;
+ }
+ void add(NFRule* thing) {
+ if (fCount == fCapacity) {
+ fCapacity += 10;
+ fStuff = (NFRule**)uprv_realloc(fStuff, fCapacity * sizeof(NFRule*)); // assume success
+ }
+ if (fStuff != NULL) {
+ fStuff[fCount++] = thing;
+ } else {
+ fCapacity = 0;
+ fCount = 0;
+ }
+ }
+ uint32_t size() const { return fCount; }
+ NFRule* last() const { return (fCount > 0 && fStuff != NULL) ? fStuff[fCount-1] : NULL; }
+ NFRule** release() {
+ add(NULL); // ensure null termination
+ NFRule** result = fStuff;
+ fStuff = NULL;
+ fCount = 0;
+ fCapacity = 0;
+ return result;
+ }
+
+private:
+ NFRuleList(const NFRuleList &other); // forbid copying of this class
+ NFRuleList &operator=(const NFRuleList &other); // forbid copying of this class
+};
+
+U_NAMESPACE_END
+
+/* U_HAVE_RBNF */
+#endif
+
+// NFRLIST_H
+#endif
Property changes on: icu46/source/i18n/nfrlist.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « icu46/source/i18n/name2uni.cpp ('k') | icu46/source/i18n/nfrs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698