Browse code

new sp

Xiuwen Zheng authored on 06/03/2020 20:24:13
Showing1 changed files
... ...
@@ -38,6 +38,8 @@ using namespace CoreArray;
38 38
 #define COREARRAY_FILE_PREFIX    "COREARRAYx0A"
39 39
 
40 40
 
41
+static const char *ERR_OBJ_RELEASE = "%s(), Release() should return ZERO.";
42
+
41 43
 
42 44
 // =====================================================================
43 45
 // CdGDSObj
... ...
@@ -50,6 +52,7 @@ static const char *VAR_ATTRLIST = "ATTRLIST";
50 52
 
51 53
 static const char *ERR_ATTR_NAME = "No Attribute Name ('%s').";
52 54
 static const char *ERR_ATTR_NAME_EXIST = "Attribute '%s' has existed.";
55
+static const char *ERR_ATTR_INVALID_NAME = "Invalid zero-length name.";
53 56
 
54 57
 CdObjAttr::CdObjAttr(CdGDSObj &vOwner): CdObject(), fOwner(vOwner)
55 58
 { }
... ...
@@ -259,18 +262,25 @@ void CdObjAttr::SetName(int Index, const UTF8String &NewName)
259 262
 void CdObjAttr::_ValidateName(const UTF8String &name)
260 263
 {
261 264
 	if (name.empty())
262
-        throw ErrGDSObj("Invalid name: ZERO length.");
265
+        throw ErrGDSObj(ERR_ATTR_INVALID_NAME);
263 266
 }
264 267
 
265 268
 
266 269
 // CdGDSObj
267 270
 
268
-static const char *ERR_NO_NAME        = "No name exists!";
269
-static const char *ERR_NO_OBJECT      = "No parent folder.";
270
-static const char *ERR_DUP_NAME       = "Duplicate name!";
271
-static const char *ERR_MOVE_TO_ADD    = "Please call 'AddObj' to add an object.";
272
-static const char *ERR_NOT_SHARE_FILE = "'MoveTo' should be within the same GDS file.";
273
-static const char *ERR_MOVE_TO_CHILD  = "Cannot move to its sub folder.";
271
+static const char *ERR_NO_NAME      = "No name exists!";
272
+static const char *ERR_NO_OBJECT    = "No parent folder.";
273
+static const char *ERR_DUP_NAME     = "Duplicate name!";
274
+static const char *ERR_MOVE_TO_ADD  = "Please call 'AddObj' to add an object.";
275
+static const char *ERR_SAME_FILE    = "'MoveTo' should be within the same GDS file.";
276
+static const char *ERR_MOVETO_CHILD = "Cannot move to its sub folder.";
277
+static const char *ERR_GDS_READONLY = "The GDS file is read-only.";
278
+static const char *ERR_GDSStream    = "%s: GDSStream should not be NULL.";
279
+
280
+static const char *ERR_INVALID_ASSIGN  = "Invalid assignment.";
281
+static const char *ERR_INVALID_ASSIGN2 = "Invalid assignment to '%s' from '%s'.";
282
+static const char *ERR_INVALID_ASSIGN3 = "Invalid assignment to '%s'.";
283
+static const char *ERR_INVALID_ASSIGN4 = "Invalid assignment from '%s'.";
274 284
 
275 285
 CdGDSObj::CdGDSObj(): CdObjMsg(), fAttr(*this)
276 286
 {
... ...
@@ -389,7 +399,7 @@ void CdGDSObj::MoveTo(CdGDSFolder &folder)
389 399
 			if (dynamic_cast<CdGDSFolder*>(this))
390 400
 			{
391 401
 				if (static_cast<CdGDSFolder*>(this)->HasChild(&folder, true))
392
-					throw ErrGDSObj(ERR_MOVE_TO_CHILD);
402
+					throw ErrGDSObj(ERR_MOVETO_CHILD);
393 403
 			}
394 404
 			if ((fFolder!=&folder) && (this!=&folder))
395 405
 			{
... ...
@@ -403,7 +413,7 @@ void CdGDSObj::MoveTo(CdGDSFolder &folder)
403 413
 				fFolder = &folder;
404 414
 			}
405 415
 		} else
406
-			throw ErrGDSObj(ERR_NOT_SHARE_FILE);
416
+			throw ErrGDSObj(ERR_SAME_FILE);
407 417
 	} else
408 418
 		throw ErrGDSObj(ERR_MOVE_TO_ADD);
409 419
 }
... ...
@@ -488,13 +498,13 @@ void CdGDSObj::_CheckWritable()
488 498
 {
489 499
 	CdGDSFile *file = GDSFile();
490 500
 	if (file && file->ReadOnly())
491
-		throw ErrGDSObj("The GDS file is read-only.");
501
+		throw ErrGDSObj(ERR_GDS_READONLY);
492 502
 }
493 503
 
494 504
 void CdGDSObj::_CheckGDSStream()
495 505
 {
496 506
 	if (!fGDSStream)
497
-		throw ErrGDSObj("CdGDSObj: GDSStream should not be NULL.");
507
+		throw ErrGDSObj(ERR_GDSStream, "CdGDSObj");
498 508
 }
499 509
 
500 510
 void CdGDSObj::RaiseInvalidAssign(const char *ThisClass, CdGDSObj *Source)
... ...
@@ -510,14 +520,14 @@ void CdGDSObj::RaiseInvalidAssign(const char *ThisClass, CdGDSObj *Source)
510 520
 	if (ThisClass)
511 521
 	{
512 522
 		if (SourceClass)
513
-			throw ErrGDSObj("Invalid assignment to '%s' from '%s'.", ThisClass, SourceClass);
523
+			throw ErrGDSObj(ERR_INVALID_ASSIGN2, ThisClass, SourceClass);
514 524
 		else
515
-			throw ErrGDSObj("Invalid assignment to '%s'.", ThisClass);
525
+			throw ErrGDSObj(ERR_INVALID_ASSIGN3, ThisClass);
516 526
 	} else {
517 527
 		if (SourceClass)
518
-			throw ErrGDSObj("Invalid assignment from '%s'.", SourceClass);
528
+			throw ErrGDSObj(ERR_INVALID_ASSIGN4, SourceClass);
519 529
 		else
520
-			throw ErrGDSObj("Invalid assignment.");
530
+			throw ErrGDSObj(ERR_INVALID_ASSIGN);
521 531
 	}
522 532
 }
523 533
 
... ...
@@ -1284,9 +1294,9 @@ static const char *ERR_FOLDER_ITEM  = "Invalid index %d.";
1284 1294
 static const char *ERR_FOLDER_NAME  = "Invalid node name \"%s\".";
1285 1295
 static const char *ERR_NO_FOLDER    = "There is not a folder named \"%s\".";
1286 1296
 static const char *ERR_OBJ_INDEX    = "Invalid object index %d in the folder.";
1287
-static const char *ERR_INV_ASSOC    = "The object has been associated with a GDS file!";
1288
-static const char *ERR_INVALID_PATH = "The GDS node \"%s\" does not exist.";
1289
-
1297
+static const char *ERR_INVALID_ASSOC = "The object has been associated with a GDS file!";
1298
+static const char *ERR_INVALID_PATH  = "The GDS node \"%s\" does not exist.";
1299
+static const char *ERR_INVALID_INDEX = "%s(), invalid 'Index' %d.";
1290 1300
 
1291 1301
 CdGDSFolder::TNode::TNode()
1292 1302
 {
... ...
@@ -1386,10 +1396,13 @@ CdGDSObj *CdGDSFolder::AddObj(const UTF8String &Name, CdGDSObj *val)
1386 1396
 CdGDSObj *CdGDSFolder::InsertObj(int index, const UTF8String &Name,
1387 1397
 	CdGDSObj *val)
1388 1398
 {
1399
+	static const char *ERR_INSERT_DIFF_OWNER =
1400
+		"CdGDSFolder::InsertObj, 'val' has a different owner.";
1401
+
1389 1402
 	if ((index < -1) || (index > (int)fList.size()))
1390
-		throw ErrGDSObj("CdGDSFolder::InsertObj, invalid 'index' %d.", index);
1403
+		throw ErrGDSObj(ERR_INVALID_INDEX, "CdGDSFolder::InsertObj", index);
1391 1404
 	if (val && (val->fFolder!=NULL) && (val->fFolder!=this))
1392
-		throw ErrGDSObj("CdGDSFolder::InsertObj, 'val' has a different owner.");
1405
+		throw ErrGDSObj(ERR_INSERT_DIFF_OWNER);
1393 1406
 
1394 1407
 	_CheckWritable();
1395 1408
 	_CheckGDSStream();
... ...
@@ -1428,7 +1441,7 @@ CdGDSObj *CdGDSFolder::InsertObj(int index, const UTF8String &Name,
1428 1441
 		val->AddRef();
1429 1442
 		val->SaveToBlockStream();
1430 1443
 	} else
1431
-		throw ErrGDSObj(ERR_INV_ASSOC);
1444
+		throw ErrGDSObj(ERR_INVALID_ASSOC);
1432 1445
 
1433 1446
 	I.Name = Name; I.Obj = val;
1434 1447
 	if (index < 0)
... ...
@@ -1442,10 +1455,13 @@ CdGDSObj *CdGDSFolder::InsertObj(int index, const UTF8String &Name,
1442 1455
 
1443 1456
 void CdGDSFolder::MoveTo(int Index, int NewPos)
1444 1457
 {
1458
+	static const char *ERR_MOVETO_INVALID_NEWPOS =
1459
+		"CdGDSFolder::MoveTo, invalid 'NewPos' %d.";
1460
+
1445 1461
 	if ((Index < -1) || (Index >= (int)fList.size()))
1446
-		throw ErrGDSObj("CdGDSFolder::MoveTo, invalid 'Index' %d.", Index);
1462
+		throw ErrGDSObj(ERR_INVALID_INDEX, "CdGDSFolder::MoveTo", Index);
1447 1463
 	if ((NewPos < -1) || (NewPos >= (int)fList.size()))
1448
-		throw ErrGDSObj("CdGDSFolder::MoveTo, invalid 'NewPos' %d.", NewPos);
1464
+		throw ErrGDSObj(ERR_MOVETO_INVALID_NEWPOS, NewPos);
1449 1465
 	_CheckWritable();
1450 1466
 
1451 1467
 	if (Index != NewPos)
... ...
@@ -1472,13 +1488,14 @@ void CdGDSFolder::UnloadObj(int Index)
1472 1488
 	vector<TNode>::iterator it = fList.begin() + Index;
1473 1489
 	if (it->Obj)
1474 1490
 	{
1491
+		static const char *ERR_IS_FOLDER = "Not allowed to unload a folder.";
1492
+		static const char *ERR_UNLOAD = "Fails to unload %p.";
1493
+
1475 1494
 		if (dynamic_cast<CdGDSAbsFolder*>(it->Obj))
1476
-			throw ErrGDSObj("Not allowed to unload a folder.");
1495
+			throw ErrGDSObj(ERR_IS_FOLDER);
1477 1496
 	#ifdef COREARRAY_CODE_DEBUG
1478 1497
 		if (it->Obj->Release() != 0)
1479
-		{
1480
-			throw ErrGDSObj("Fails to unload %p.", (void*)(it->Obj));
1481
-		}
1498
+			throw ErrGDSObj(ERR_UNLOAD, (void*)(it->Obj));
1482 1499
 	#else
1483 1500
 		it->Obj->Release();
1484 1501
 	#endif
... ...
@@ -1524,18 +1541,16 @@ void CdGDSFolder::DeleteObj(int Index, bool force)
1524 1541
 			CdGDSFolder *folder = static_cast<CdGDSFolder*>(it->Obj);
1525 1542
 			if (!force && (folder->NodeCount()>0))
1526 1543
 			{
1527
-				throw ErrGDSObj(
1528
-					"Please delete the item(s) in the folder before removing it.");
1544
+				static const char *ERR_REMOVE_FIRST =
1545
+					"Please delete the item(s) in the folder before removing it.";
1546
+				throw ErrGDSObj(ERR_REMOVE_FIRST);
1529 1547
 			}
1530 1548
 			folder->ClearObj(force);
1531 1549
 		}
1532 1550
 
1533 1551
 	#ifdef COREARRAY_CODE_DEBUG
1534 1552
 		if (it->Obj->Release() != 0)
1535
-		{
1536
-			throw ErrGDSObj(
1537
-				"Internal Error: Object 'Release()' should return ZERO.");
1538
-		}
1553
+			throw ErrGDSObj(ERR_OBJ_RELEASE, "CdGDSFolder::DeleteObj");
1539 1554
 	#else
1540 1555
 		it->Obj->Release();
1541 1556
 	#endif
... ...
@@ -1782,7 +1797,7 @@ void CdGDSFolder::_ClearFolder()
1782 1797
 		{
1783 1798
 		#ifdef COREARRAY_CODE_DEBUG
1784 1799
 			if (it->Obj->Release() != 0)
1785
-				throw ErrGDSObj("Object Release() should return ZERO.");
1800
+				throw ErrGDSObj(ERR_OBJ_RELEASE, "CdGDSFolder::_ClearFolder");
1786 1801
 		#else
1787 1802
 			it->Obj->Release();
1788 1803
 		#endif
... ...
@@ -2052,8 +2067,8 @@ void CdGDSVirtualFolder::_CheckLinked()
2052 2067
 {
2053 2068
 	if (!IsLoaded(false))
2054 2069
 	{
2055
-		throw ErrGDSObj("Fail to link the GDS file '%s'.",
2056
-			fLinkFileName.c_str());
2070
+		static const char *ERR_FAIL_LINK = "Fail to link the GDS file '%s'.";
2071
+		throw ErrGDSObj(ERR_FAIL_LINK, fLinkFileName.c_str());
2057 2072
 	}
2058 2073
 }
2059 2074
 
... ...
@@ -2067,7 +2082,6 @@ void CdGDSVirtualFolder::SetLinkFile(const UTF8String &FileName)
2067 2082
 			fLinkFile = NULL;
2068 2083
 			delete file;
2069 2084
 		}
2070
-
2071 2085
 		fLinkFileName = FileName;
2072 2086
 		fHasTried = false;
2073 2087
 		fChanged = true;
... ...
@@ -2266,7 +2280,7 @@ void CdGDSStreamContainer::Loading(CdReader &Reader, TdVersion Version)
2266 2280
 {
2267 2281
 	CdGDSObjPipe::Loading(Reader, Version);
2268 2282
 
2269
-	if (fGDSStream != NULL)
2283
+	if (fGDSStream)
2270 2284
 	{
2271 2285
 		vAllocID = 0;
2272 2286
 		Reader[VAR_DATA] >> vAllocID;
... ...
@@ -2280,9 +2294,7 @@ void CdGDSStreamContainer::Loading(CdReader &Reader, TdVersion Version)
2280 2294
 		if (fPipeInfo)
2281 2295
 			fPipeInfo->PushReadPipe(*fBufStream);
2282 2296
 	} else {
2283
-		throw ErrGDSStreamContainer(
2284
-			"'CdGDSStreamContainer' object should be combined with a GDS file!"
2285
-		);
2297
+		throw ErrGDSStreamContainer(ERR_GDSStream, "CdGDSStreamContainer");
2286 2298
 	}
2287 2299
 }
2288 2300
 
... ...
@@ -2290,7 +2302,7 @@ void CdGDSStreamContainer::Saving(CdWriter &Writer)
2290 2302
 {
2291 2303
 	CdGDSObjPipe::Saving(Writer);
2292 2304
 
2293
-	if (fGDSStream != NULL)
2305
+	if (fGDSStream)
2294 2306
 	{
2295 2307
 		if (vAllocStream == NULL)
2296 2308
 		{
... ...
@@ -2307,8 +2319,7 @@ void CdGDSStreamContainer::Saving(CdWriter &Writer)
2307 2319
 		Writer[VAR_DATA] << Entry;
2308 2320
 		vAlloc_Ptr = Writer.PropPosition(VAR_DATA);
2309 2321
 	} else {
2310
-		throw ErrGDSStreamContainer(
2311
-		"'CdGDSStreamContainer' object should be combined with a GDS file!");
2322
+		throw ErrGDSStreamContainer(ERR_GDSStream, "CdGDSStreamContainer");
2312 2323
 	}
2313 2324
 }
2314 2325
 
... ...
@@ -2511,13 +2522,12 @@ UTF8String CdGDSRoot::Name() const
2511 2522
 
2512 2523
 void CdGDSRoot::SetName(const UTF8String &NewName)
2513 2524
 {
2525
+	static const char *ERR_ROOT_NAME =
2526
+		"The root of a GDS file is not allowed to have a name.";
2514 2527
 	if (fVFolder)
2515
-	{
2516 2528
 		fVFolder->SetName(NewName);
2517
-	} else {
2518
-		throw ErrGDSFile(
2519
-			"The root of a GDS file is not allowed to have a name.");
2520
-	}
2529
+	else
2530
+		throw ErrGDSFile(ERR_ROOT_NAME);
2521 2531
 }
2522 2532
 
2523 2533
 
... ...
@@ -2664,7 +2674,8 @@ void CdGDSFile::LoadStream(CdStream *Stream, bool ReadOnly, bool AllowError)
2664 2674
 		fRoot.fGDSStream->AddRef();
2665 2675
 
2666 2676
 	#ifdef COREARRAY_CODE_USING_LOG
2667
-		Log().Add(CdLogRecord::LOG_INFO, "Load the root folder from the entry (size: %g).",
2677
+		Log().Add(CdLogRecord::LOG_INFO,
2678
+			"Load the root folder from the entry (size: %g).",
2668 2679
 			(double)fRoot.fGDSStream->Size());
2669 2680
 	#endif
2670 2681
 
Browse code

new C GDS_Node_Unload() & GDS_Node_Load()

Xiuwen Zheng authored on 14/01/2020 21:30:19
Showing1 changed files
... ...
@@ -1470,12 +1470,14 @@ void CdGDSFolder::UnloadObj(int Index)
1470 1470
 		throw ErrGDSObj(ERR_OBJ_INDEX, Index);
1471 1471
 
1472 1472
 	vector<TNode>::iterator it = fList.begin() + Index;
1473
-	if (it->Obj && !dynamic_cast<CdGDSAbsFolder*>(it->Obj))
1473
+	if (it->Obj)
1474 1474
 	{
1475
+		if (dynamic_cast<CdGDSAbsFolder*>(it->Obj))
1476
+			throw ErrGDSObj("Not allowed to unload a folder.");
1475 1477
 	#ifdef COREARRAY_CODE_DEBUG
1476 1478
 		if (it->Obj->Release() != 0)
1477 1479
 		{
1478
-			throw ErrGDSObj("Internal Error: Object 'Release()' should return ZERO.");
1480
+			throw ErrGDSObj("Fails to unload %p.", (void*)(it->Obj));
1479 1481
 		}
1480 1482
 	#else
1481 1483
 		it->Obj->Release();
Browse code

more information when GDS file crashes

Xiuwen Zheng authored on 05/01/2020 03:47:17
Showing1 changed files
... ...
@@ -8,7 +8,7 @@
8 8
 //
9 9
 // dFile.cpp: Functions and classes for CoreArray Genomic Data Structure (GDS)
10 10
 //
11
-// Copyright (C) 2007-2019    Xiuwen Zheng
11
+// Copyright (C) 2007-2020    Xiuwen Zheng
12 12
 //
13 13
 // This file is part of CoreArray.
14 14
 //
... ...
@@ -439,13 +439,10 @@ CdGDSFile *CdGDSObj::GDSFile()
439 439
 
440 440
 void CdGDSObj::LoadStruct(CdReader &Reader, TdVersion Version)
441 441
 {
442
-	// call load function ::Loading
442
+	// call the function 'Loading'
443 443
 	CdObjMsg::LoadStruct(Reader, Version);
444
-
445
-	// load attribute
446
-	COREARRAY_READER_CALL_SILENT(
447
-		fAttr.Loading(Reader, Version)
448
-	);
444
+	// load attributes
445
+	COREARRAY_READER_CALL_SILENT(fAttr.Loading(Reader, Version));
449 446
 }
450 447
 
451 448
 void CdGDSObj::SaveStruct(CdWriter &Writer, bool IncludeName)
... ...
@@ -458,13 +455,10 @@ void CdGDSObj::SaveStruct(CdWriter &Writer, bool IncludeName)
458 455
 		Writer.Storage() << C_UInt16(Version);
459 456
 		Writer.WriteClassName(dName());
460 457
 	}
461
-
462 458
 	// call save function ::Saving
463 459
 	this->Saving(Writer);
464
-
465 460
 	// save attribute
466 461
 	fAttr.Saving(Writer);
467
-
468 462
 	// ending ...
469 463
 	Writer.EndStruct();
470 464
 	fChanged = false;
... ...
@@ -527,14 +521,10 @@ void CdGDSObj::RaiseInvalidAssign(const char *ThisClass, CdGDSObj *Source)
527 521
 	}
528 522
 }
529 523
 
530
-void CdGDSObj::_GDSObjInitProc(CdObjClassMgr &Sender, CdObject *dObj,
531
-	void *Data)
524
+void CdGDSObj::_GDSObjInitProc(CdObjClassMgr &Sender, CdObject *Obj, void *Data)
532 525
 {
533
-	if (dynamic_cast<CdGDSObj*>(dObj))
534
-	{
535
-		static_cast<CdGDSObj*>(dObj)->fGDSStream =
536
-			(CdBlockStream*)Data;
537
-	}
526
+	if (dynamic_cast<CdGDSObj*>(Obj))
527
+		static_cast<CdGDSObj*>(Obj)->fGDSStream = (CdBlockStream*)Data;
538 528
 }
539 529
 
540 530
 
... ...
@@ -594,7 +584,7 @@ namespace CoreArray
594 584
 		}
595 585
 		virtual CdStream *FreePipe()
596 586
 		{
597
-			if (fPStream) fPStream->Release();
587
+			if (fPStream) { fPStream->Release(); fPStream = NULL; }
598 588
 			return fStream;
599 589
 		}
600 590
 	};
... ...
@@ -628,7 +618,7 @@ namespace CoreArray
628 618
 		}
629 619
 		virtual CdStream *FreePipe()
630 620
 		{
631
-			if (fPStream) fPStream->Release();
621
+			if (fPStream) { fPStream->Release(); fPStream = NULL; }
632 622
 			return fStream;
633 623
 		}
634 624
 	};
... ...
@@ -1829,11 +1819,14 @@ CdGDSFolder::TNode &CdGDSFolder::_NameItem(const UTF8String &Name)
1829 1819
 
1830 1820
 void CdGDSFolder::_LoadItem(TNode &I)
1831 1821
 {
1822
+	static const char *ERR_INVALID_GDS_OBJ =
1823
+		"Invalid GDS object (it should be inherited from CdGDSObj).";
1824
+
1832 1825
 	if (I.Obj == NULL)
1833 1826
 	{
1834 1827
 		_CheckGDSStream();
1835
-		CdReader Reader(fGDSStream->Collection()[I.StreamID],
1836
-			&GDSFile()->Log());
1828
+		CdBlockStream *IStream = fGDSStream->Collection()[I.StreamID];
1829
+		CdReader Reader(IStream, &GDSFile()->Log());
1837 1830
 
1838 1831
 		if (I.IsFlagType(CdGDSFolder::TNode::FLAG_TYPE_LABEL))
1839 1832
 		{
... ...
@@ -1846,9 +1839,9 @@ void CdGDSFolder::_LoadItem(TNode &I)
1846 1839
 			_INTERNAL::CdObject_LoadStruct(*vObj, Reader, 0x100);
1847 1840
 			Reader.EndStruct();
1848 1841
 
1849
-			vObj->fGDSStream = dynamic_cast<CdBlockStream*>(&Reader.Stream());
1850 1842
 			/// todo: check
1851
-			vObj->fGDSStream->AddRef();
1843
+			vObj->fGDSStream = IStream;
1844
+			IStream->AddRef();
1852 1845
 
1853 1846
 		} else if (I.IsFlagType(CdGDSFolder::TNode::FLAG_TYPE_FOLDER))
1854 1847
 		{
... ...
@@ -1861,9 +1854,9 @@ void CdGDSFolder::_LoadItem(TNode &I)
1861 1854
 			vObj->LoadStruct(Reader, COREARRAY_CLASS_VERSION);
1862 1855
 			Reader.EndStruct();
1863 1856
 
1864
-			vObj->fGDSStream = dynamic_cast<CdBlockStream*>(&Reader.Stream());
1865 1857
 			/// todo: check
1866
-			vObj->fGDSStream->AddRef();
1858
+			vObj->fGDSStream = IStream;
1859
+			IStream->AddRef();
1867 1860
 
1868 1861
 		} else if (I.IsFlagType(CdGDSFolder::TNode::FLAG_TYPE_VIRTUAL_FOLDER))
1869 1862
 		{
... ...
@@ -1876,9 +1869,9 @@ void CdGDSFolder::_LoadItem(TNode &I)
1876 1869
 			vObj->LoadStruct(Reader, COREARRAY_CLASS_VERSION);
1877 1870
 			Reader.EndStruct();
1878 1871
 
1879
-			vObj->fGDSStream = dynamic_cast<CdBlockStream*>(&Reader.Stream());
1880 1872
 			/// todo: check
1881
-			vObj->fGDSStream->AddRef();
1873
+			vObj->fGDSStream = IStream;
1874
+			IStream->AddRef();
1882 1875
 
1883 1876
 		} else if (I.IsFlagType(CdGDSFolder::TNode::FLAG_TYPE_STREAM))
1884 1877
 		{
... ...
@@ -1887,9 +1880,9 @@ void CdGDSFolder::_LoadItem(TNode &I)
1887 1880
 			vObj->fFolder = this;
1888 1881
 			I.Obj = vObj;
1889 1882
 
1890
-			vObj->fGDSStream = dynamic_cast<CdBlockStream*>(&Reader.Stream());
1891 1883
 			/// todo: check
1892
-			vObj->fGDSStream->AddRef();
1884
+			vObj->fGDSStream = IStream;
1885
+			IStream->AddRef();
1893 1886
 
1894 1887
 			Reader.BeginNameSpace();
1895 1888
 			vObj->LoadStruct(Reader, COREARRAY_CLASS_VERSION);
... ...
@@ -1900,8 +1893,7 @@ void CdGDSFolder::_LoadItem(TNode &I)
1900 1893
 			CdObjRef *obj = NULL;
1901 1894
 
1902 1895
 			try{
1903
-				obj =
1904
-					fGDSStream->Collection().ClassMgr()->
1896
+				obj = fGDSStream->Collection().ClassMgr()->
1905 1897
 					ToObj(Reader, _GDSObjInitProc, fGDSStream, false);
1906 1898
 			}
1907 1899
 			catch (exception &E)
... ...
@@ -1916,13 +1908,11 @@ void CdGDSFolder::_LoadItem(TNode &I)
1916 1908
 			{
1917 1909
 				I.Obj = static_cast<CdGDSObj*>(obj);
1918 1910
 				I.Obj->fFolder = this;
1919
-				I.Obj->fGDSStream = dynamic_cast<CdBlockStream*>(
1920
-					&Reader.Stream());
1921
-				I.Obj->fGDSStream->AddRef();
1911
+				I.Obj->fGDSStream = IStream;
1912
+				IStream->AddRef();
1922 1913
 			} else {
1923 1914
 				if (obj) delete obj;
1924
-				throw ErrGDSObj(
1925
-					"Invalid GDS object (it should be inherited from CdGDSObj).");
1915
+				throw ErrGDSObj(ERR_INVALID_GDS_OBJ);
1926 1916
 			}
1927 1917
 		}
1928 1918
 
... ...
@@ -2561,8 +2551,8 @@ void CdGDSUnknown::SaveStruct(CdWriter &Writer, bool IncludeName)
2561 2551
 // =====================================================================
2562 2552
 
2563 2553
 static const char *ERR_GDS_OPEN_MODE = "Invalid open mode in CdGDSFile.";
2564
-static const char *ERR_GDS_PREFIX    = "Invalid prefix of stream!";
2565
-static const char *ERR_GDS_ENTRY     = "Invalid entry point(%d).";
2554
+static const char *ERR_GDS_MAGIC     = "Invalid magic number!";
2555
+static const char *ERR_GDS_ENTRY     = "Invalid entry point(0x%04X).";
2566 2556
 static const char *ERR_GDS_SAVE      = "Should save it to a GDS file first!";
2567 2557
 
2568 2558
 #ifdef COREARRAY_CODE_DEBUG
... ...
@@ -2578,8 +2568,7 @@ void CdGDSFile::_Init()
2578 2568
 {
2579 2569
 	fVersion = COREARRAY_FILE_VERSION;
2580 2570
 	fRoot.AddRef();
2581
-	fCodeStart = strlen(GDSFilePrefix()) +
2582
-		sizeof(TdVersion) + GDS_BLOCK_ID_SIZE;
2571
+	fCodeStart = strlen(GDSFilePrefix()) + sizeof(TdVersion) + GDS_BLOCK_ID_SIZE;
2583 2572
 	fReadOnly = false;
2584 2573
 	fLog = new CdLogRecord; fLog->AddRef();
2585 2574
 	fprocess_id = GetCurrentProcessID();
... ...
@@ -2630,7 +2619,7 @@ CdGDSFile::~CdGDSFile()
2630 2619
 	if (fLog) fLog->Release();
2631 2620
 }
2632 2621
 
2633
-void CdGDSFile::LoadStream(CdStream *Stream, bool ReadOnly)
2622
+void CdGDSFile::LoadStream(CdStream *Stream, bool ReadOnly, bool AllowError)
2634 2623
 {
2635 2624
 	// Initialize
2636 2625
 	CloseFile();
... ...
@@ -2638,19 +2627,19 @@ void CdGDSFile::LoadStream(CdStream *Stream, bool ReadOnly)
2638 2627
 	fReadOnly = ReadOnly;
2639 2628
 
2640 2629
 	// Check the prefix
2641
-	const size_t L = strlen(GDSFilePrefix());
2630
+	const char *prefix = GDSFilePrefix();
2631
+	const size_t L = strlen(prefix);  // should be > 0 always
2642 2632
 	vector<char> buf(L);
2643 2633
 	Stream->ReadData((void*)&buf[0], L);
2644
-	if (memcmp((void*)GDSFilePrefix(), (void*)&buf[0], L) !=0)
2645
-		throw ErrGDSFile(ERR_GDS_PREFIX);
2634
+	if (memcmp((void*)prefix, (void*)&buf[0], L) !=0)
2635
+		throw ErrGDSFile(ERR_GDS_MAGIC);
2646 2636
 
2647 2637
 	// Load Version
2648 2638
 	fVersion = Stream->R8b();
2649 2639
 	fVersion |= Stream->R8b() << 8;
2650 2640
 
2651 2641
 #ifdef COREARRAY_CODE_USING_LOG
2652
-	Log().Add(CdLogRecord::logInfo,
2653
-		"Open a GDS file (File Version, major: %02d, minor: %02d).",
2642
+	Log().Add(CdLogRecord::LOG_INFO, "Open a GDS file (File Version: v%d.%d).",
2654 2643
 		int(fVersion >> 8), int(fVersion & 0xFF));
2655 2644
 #endif
2656 2645
 
... ...
@@ -2658,11 +2647,11 @@ void CdGDSFile::LoadStream(CdStream *Stream, bool ReadOnly)
2658 2647
 	TdGDSBlockID Entry;
2659 2648
 	BYTE_LE<CdStream>(Stream) >> Entry;
2660 2649
 
2661
-	// To identify the block stream
2662
-	CdBlockCollection::LoadStream(Stream, ReadOnly);
2650
+	// Block construction
2651
+	CdBlockCollection::LoadStream(Stream, ReadOnly, AllowError, &Log());
2663 2652
 
2664 2653
 #ifdef COREARRAY_CODE_USING_LOG
2665
-	Log().Add(CdLogRecord::logInfo,
2654
+	Log().Add(CdLogRecord::LOG_INFO,
2666 2655
 		"Load all data stream (%d in total) with an entry id (0x%04X).",
2667 2656
 		(int)BlockList().size(), Entry.Get());
2668 2657
 #endif
... ...
@@ -2673,8 +2662,7 @@ void CdGDSFile::LoadStream(CdStream *Stream, bool ReadOnly)
2673 2662
 		fRoot.fGDSStream->AddRef();
2674 2663
 
2675 2664
 	#ifdef COREARRAY_CODE_USING_LOG
2676
-		Log().Add(CdLogRecord::logInfo,
2677
-			"Load the root folder from the entry (size: %g).",
2665
+		Log().Add(CdLogRecord::LOG_INFO, "Load the root folder from the entry (size: %g).",
2678 2666
 			(double)fRoot.fGDSStream->Size());
2679 2667
 	#endif
2680 2668
 
... ...
@@ -2716,27 +2704,27 @@ void CdGDSFile::SaveStream(CdStream *Stream)
2716 2704
 	fRoot.SaveToBlockStream();
2717 2705
 }
2718 2706
 
2719
-void CdGDSFile::LoadFile(const UTF8String &fn, bool ReadOnly)
2707
+void CdGDSFile::LoadFile(const UTF8String &fn, bool ReadOnly, bool AllowError)
2720 2708
 {
2721 2709
 	TdAutoRef<CdStream> F(new CdFileStream(RawText(fn).c_str(),
2722 2710
 		ReadOnly ? CdFileStream::fmOpenRead : CdFileStream::fmOpenReadWrite));
2723
-	LoadStream(F.get(), ReadOnly);
2711
+	LoadStream(F.get(), ReadOnly, AllowError);
2724 2712
 	fFileName = fn;
2725 2713
 }
2726 2714
 
2727
-void CdGDSFile::LoadFile(const char *fn, bool ReadOnly)
2715
+void CdGDSFile::LoadFile(const char *fn, bool ReadOnly, bool AllowError)
2728 2716
 {
2729 2717
 	TdAutoRef<CdStream> F(new CdFileStream(fn,
2730 2718
 		ReadOnly ? CdFileStream::fmOpenRead : CdFileStream::fmOpenReadWrite));
2731
-	LoadStream(F.get(), ReadOnly);
2719
+	LoadStream(F.get(), ReadOnly, AllowError);
2732 2720
 	fFileName = UTF8Text(fn);
2733 2721
 }
2734 2722
 
2735
-void CdGDSFile::LoadFileFork(const char *fn, bool ReadOnly)
2723
+void CdGDSFile::LoadFileFork(const char *fn, bool ReadOnly, bool AllowError)
2736 2724
 {
2737 2725
 	TdAutoRef<CdStream> F(new CdForkFileStream(fn,
2738 2726
 		ReadOnly ? CdFileStream::fmOpenRead : CdFileStream::fmOpenReadWrite));
2739
-	LoadStream(F.get(), ReadOnly);
2727
+	LoadStream(F.get(), ReadOnly, AllowError);
2740 2728
 	fFileName = UTF8Text(fn);
2741 2729
 }
2742 2730
 
... ...
@@ -2813,6 +2801,7 @@ void CdGDSFile::CloseFile()
2813 2801
 		fLog->List().clear();
2814 2802
 		fRoot.Attribute().Clear();
2815 2803
 		fRoot._ClearFolder();
2804
+
2816 2805
 		if (fRoot.fGDSStream)
2817 2806
 		{
2818 2807
 			// todo: check
Browse code

new function unload.gdsn()

Xiuwen Zheng authored on 14/10/2019 19:04:19
Showing1 changed files
... ...
@@ -8,7 +8,7 @@
8 8
 //
9 9
 // dFile.cpp: Functions and classes for CoreArray Genomic Data Structure (GDS)
10 10
 //
11
-// Copyright (C) 2007-2018    Xiuwen Zheng
11
+// Copyright (C) 2007-2019    Xiuwen Zheng
12 12
 //
13 13
 // This file is part of CoreArray.
14 14
 //
... ...
@@ -1474,6 +1474,42 @@ void CdGDSFolder::MoveTo(int Index, int NewPos)
1474 1474
 	}
1475 1475
 }
1476 1476
 
1477
+void CdGDSFolder::UnloadObj(int Index)
1478
+{
1479
+	if ((Index < 0) || (Index >= (int)fList.size()))
1480
+		throw ErrGDSObj(ERR_OBJ_INDEX, Index);
1481
+
1482
+	vector<TNode>::iterator it = fList.begin() + Index;
1483
+	if (it->Obj && !dynamic_cast<CdGDSAbsFolder*>(it->Obj))
1484
+	{
1485
+	#ifdef COREARRAY_CODE_DEBUG
1486
+		if (it->Obj->Release() != 0)
1487
+		{
1488
+			throw ErrGDSObj("Internal Error: Object 'Release()' should return ZERO.");
1489
+		}
1490
+	#else
1491
+		it->Obj->Release();
1492
+	#endif
1493
+		it->Obj = NULL;
1494
+	}
1495
+}
1496
+
1497
+void CdGDSFolder::UnloadObj(CdGDSObj *val)
1498
+{
1499
+	if (val == NULL) return;
1500
+	vector<CdGDSFolder::TNode>::iterator it;
1501
+	int Index = 0;
1502
+	for (it = fList.begin(); it != fList.end(); it++, Index++)
1503
+	{
1504
+		if (it->Obj == val)
1505
+		{
1506
+			UnloadObj(Index);
1507
+			return;
1508
+		}
1509
+	}
1510
+	throw ErrGDSObj();
1511
+}
1512
+
1477 1513
 void CdGDSFolder::DeleteObj(int Index, bool force)
1478 1514
 {
1479 1515
 	if ((Index < 0) || (Index >= (int)fList.size()))
... ...
@@ -1532,7 +1568,6 @@ void CdGDSFolder::DeleteObj(int Index, bool force)
1532 1568
 void CdGDSFolder::DeleteObj(CdGDSObj *val, bool force)
1533 1569
 {
1534 1570
 	if (val == NULL) return;
1535
-
1536 1571
 	vector<CdGDSFolder::TNode>::iterator it;
1537 1572
 	int Index = 0;
1538 1573
 	for (it = fList.begin(); it != fList.end(); it++, Index++)
... ...
@@ -2073,6 +2108,18 @@ void CdGDSVirtualFolder::MoveTo(int Index, int NewPos)
2073 2108
 	fLinkFile->Root().MoveTo(Index, NewPos);
2074 2109
 }
2075 2110
 
2111
+void CdGDSVirtualFolder::UnloadObj(int Index)
2112
+{
2113
+	_CheckLinked();
2114
+	fLinkFile->Root().UnloadObj(Index);
2115
+}
2116
+
2117
+void CdGDSVirtualFolder::UnloadObj(CdGDSObj *val)
2118
+{
2119
+	_CheckLinked();
2120
+	fLinkFile->Root().UnloadObj(val);
2121
+}
2122
+
2076 2123
 void CdGDSVirtualFolder::DeleteObj(int Index, bool force)
2077 2124
 {
2078 2125
 	_CheckLinked();
Browse code

packedreal8 optimization + using utf8string internally

Xiuwen Zheng authored on 22/12/2018 09:34:39
Showing1 changed files
... ...
@@ -80,7 +80,7 @@ void CdObjAttr::Assign(CdObjAttr &Source)
80 80
 	}
81 81
 }
82 82
 
83
-CdAny &CdObjAttr::Add(const UTF16String &Name)
83
+CdAny &CdObjAttr::Add(const UTF8String &Name)
84 84
 {
85 85
 	_ValidateName(Name);
86 86
 	vector<TdPair*>::iterator it = _Find(Name);
... ...
@@ -92,10 +92,10 @@ CdAny &CdObjAttr::Add(const UTF16String &Name)
92 92
 		Changed();
93 93
 		return I->val;
94 94
 	} else
95
-		throw ErrGDSObj(ERR_ATTR_NAME_EXIST, UTF16ToUTF8(Name).c_str());
95
+		throw ErrGDSObj(ERR_ATTR_NAME_EXIST, Name.c_str());
96 96
 }
97 97
 
98
-int CdObjAttr::IndexName(const UTF16String &Name)
98
+int CdObjAttr::IndexName(const UTF8String &Name)
99 99
 {
100 100
 	vector<TdPair*>::iterator it = _Find(Name);
101 101
 	if (it != fList.end())
... ...
@@ -104,16 +104,16 @@ int CdObjAttr::IndexName(const UTF16String &Name)
104 104
 		return -1;
105 105
 }
106 106
 
107
-bool CdObjAttr::HasName(const UTF16String &Name)
107
+bool CdObjAttr::HasName(const UTF8String &Name)
108 108
 {
109 109
 	return (IndexName(Name) >= 0);
110 110
 }
111 111
 
112
-void CdObjAttr::Delete(const UTF16String &Name)
112
+void CdObjAttr::Delete(const UTF8String &Name)
113 113
 {
114 114
 	vector<TdPair*>::iterator it = _Find(Name);
115 115
 	if (it == fList.end())
116
-		throw ErrGDSObj(ERR_ATTR_NAME, UTF16ToUTF8(Name).c_str());
116
+		throw ErrGDSObj(ERR_ATTR_NAME, Name.c_str());
117 117
 	TdPair *p = *it;
118 118
 	*it = NULL;
119 119
 	fList.erase(it);
... ...
@@ -152,11 +152,11 @@ void CdObjAttr::Changed()
152 152
 	this->fOwner.fChanged = true;
153 153
 }
154 154
 
155
-CdAny & CdObjAttr::operator[](const UTF16String &Name)
155
+CdAny & CdObjAttr::operator[](const UTF8String &Name)
156 156
 {
157 157
 	vector<TdPair*>::iterator it = _Find(Name);
158 158
 	if (it == fList.end())
159
-		throw ErrGDSObj(ERR_ATTR_NAME, UTF16ToUTF8(Name).c_str());
159
+		throw ErrGDSObj(ERR_ATTR_NAME, Name.c_str());
160 160
 	return (*it)->val;
161 161
 }
162 162
 
... ...
@@ -188,7 +188,7 @@ void CdObjAttr::Loading(CdReader &Reader, TdVersion Version)
188 188
 		{
189 189
 			TdPair *I = new TdPair;
190 190
 			try {
191
-				I->name = Reader.Storage().RpUTF16();
191
+				I->name = UTF16ToUTF8(Reader.Storage().RpUTF16()); // TODO
192 192
 				Reader >> I->val;
193 193
 			} catch (...) {
194 194
 				delete I;
... ...
@@ -210,14 +210,14 @@ void CdObjAttr::Saving(CdWriter &Writer)
210 210
 		vector<TdPair*>::iterator it;
211 211
 		for (it=fList.begin(); it != fList.end(); it++)
212 212
 		{
213
-			Writer.Storage().WpUTF16((*it)->name);
213
+			Writer.Storage().WpUTF16(UTF8ToUTF16((*it)->name)); // TODO
214 214
 			Writer << (*it)->val;
215 215
 		}
216 216
 		Writer.EndStruct();
217 217
 	}
218 218
 }
219 219
 
220
-vector<CdObjAttr::TdPair*>::iterator CdObjAttr::_Find(const UTF16String &Name)
220
+vector<CdObjAttr::TdPair*>::iterator CdObjAttr::_Find(const UTF8String &Name)
221 221
 {
222 222
 	vector<TdPair*>::iterator it;
223 223
 	for (it = fList.begin(); it != fList.end(); it++)
... ...
@@ -228,35 +228,35 @@ vector<CdObjAttr::TdPair*>::iterator CdObjAttr::_Find(const UTF16String &Name)
228 228
 	return it;
229 229
 }
230 230
 
231
-void CdObjAttr::SetName(const UTF16String &OldName, const UTF16String &NewName)
231
+void CdObjAttr::SetName(const UTF8String &OldName, const UTF8String &NewName)
232 232
 {
233 233
 	_ValidateName(NewName);
234 234
 	vector<TdPair*>::iterator it = _Find(OldName);
235 235
 	if (it == fList.end())
236
-		throw ErrGDSObj(ERR_ATTR_NAME, UTF16ToUTF8(OldName).c_str());
236
+		throw ErrGDSObj(ERR_ATTR_NAME, OldName.c_str());
237 237
 	if (OldName != NewName)
238 238
 	{
239 239
 		if (HasName(NewName))
240
-			throw ErrGDSObj(ERR_ATTR_NAME_EXIST, UTF16ToUTF8(NewName).c_str());
240
+			throw ErrGDSObj(ERR_ATTR_NAME_EXIST, NewName.c_str());
241 241
 		(*it)->name = NewName;
242 242
 		Changed();
243 243
 	}
244 244
 }
245 245
 
246
-void CdObjAttr::SetName(int Index, const UTF16String &NewName)
246
+void CdObjAttr::SetName(int Index, const UTF8String &NewName)
247 247
 {
248 248
 	TdPair &p = *fList.at(Index); // check range
249 249
 	_ValidateName(NewName);
250 250
 	if (p.name != NewName)
251 251
 	{
252 252
 		if (HasName(NewName))
253
-			throw ErrGDSObj(ERR_ATTR_NAME_EXIST, UTF16ToUTF8(NewName).c_str());
253
+			throw ErrGDSObj(ERR_ATTR_NAME_EXIST, NewName.c_str());
254 254
 		p.name = NewName;
255 255
 		Changed();
256 256
 	}
257 257
 }
258 258
 
259
-void CdObjAttr::_ValidateName(const UTF16String &name)
259
+void CdObjAttr::_ValidateName(const UTF8String &name)
260 260
 {
261 261
 	if (name.empty())
262 262
         throw ErrGDSObj("Invalid name: ZERO length.");
... ...
@@ -290,7 +290,7 @@ void CdGDSObj::AssignAttribute(CdGDSObj &Source)
290 290
 	fAttr.Assign(Source.Attribute());
291 291
 }
292 292
 
293
-UTF16String CdGDSObj::Name() const
293
+UTF8String CdGDSObj::Name() const
294 294
 {
295 295
 	if (fFolder)
296 296
 	{
... ...
@@ -304,9 +304,10 @@ UTF16String CdGDSObj::Name() const
304 304
 	throw ErrGDSObj(ERR_NO_NAME);
305 305
 }
306 306
 
307
-UTF16String CdGDSObj::FullName(const UTF16String &Delimiter) const
307
+UTF8String CdGDSObj::FullName() const
308 308
 {
309
-	UTF16String rv = Name();
309
+	const UTF8String Delimiter = "/";
310
+	UTF8String rv = Name();
310 311
 	CdGDSFolder *p = fFolder;
311 312
 	if (p != NULL)
312 313
 	{
... ...
@@ -319,12 +320,7 @@ UTF16String CdGDSObj::FullName(const UTF16String &Delimiter) const
319 320
 	return rv;
320 321
 }
321 322
 
322
-UTF16String CdGDSObj::FullName(const char *Delimiter) const
323
-{
324
-	return FullName(UTF16Text(Delimiter));
325
-}
326
-
327
-void CdGDSObj::SetName(const UTF16String &NewName)
323
+void CdGDSObj::SetName(const UTF8String &NewName)
328 324
 {
329 325
 	if (fFolder)
330 326
 	{
... ...
@@ -488,7 +484,7 @@ void CdGDSObj::SaveToBlockStream()
488 484
 string CdGDSObj::LogValue()
489 485
 {
490 486
 	if (fFolder)
491
-		return RawText(FullName("/"));
487
+		return FullName();
492 488
 	else
493 489
 		return "/";
494 490
 }
... ...
@@ -1293,7 +1289,7 @@ void CdGDSLabel::Assign(CdGDSObj &Source, bool Full)
1293 1289
 // =====================================================================
1294 1290
 
1295 1291
 static const char *ERR_NAME_EXIST   = "The GDS node \"%s\" exists.";
1296
-static const char *ERR_NAME_INVALID = "The GDS node name \"%s\" should not contain '/'.";
1292
+static const char *ERR_NAME_INVALID = "The GDS node name \"%s\" should not contain '/' or '\x0'.";
1297 1293
 static const char *ERR_FOLDER_ITEM  = "Invalid index %d.";
1298 1294
 static const char *ERR_FOLDER_NAME  = "Invalid node name \"%s\".";
1299 1295
 static const char *ERR_NO_FOLDER    = "There is not a folder named \"%s\".";
... ...
@@ -1365,15 +1361,15 @@ void CdGDSFolder::AssignFolder(CdGDSAbsFolder &Source)
1365 1361
 	}
1366 1362
 }
1367 1363
 
1368
-CdGDSObj *CdGDSFolder::AddFolder(const UTF16String &Name)
1364
+CdGDSObj *CdGDSFolder::AddFolder(const UTF8String &Name)
1369 1365
 {
1370 1366
 	_CheckWritable();
1371 1367
 	_CheckGDSStream();
1372 1368
 
1373 1369
 	if (!_ValidName(Name))
1374
-		throw ErrGDSObj(ERR_NAME_INVALID, UTF16ToUTF8(Name).c_str());
1370
+		throw ErrGDSObj(ERR_NAME_INVALID, Name.c_str());
1375 1371
 	if (_HasName(Name))
1376
-		throw ErrGDSObj(ERR_NAME_EXIST, UTF16ToUTF8(Name).c_str());
1372
+		throw ErrGDSObj(ERR_NAME_EXIST, Name.c_str());
1377 1373
 
1378 1374
 	CdGDSFolder *rv = new CdGDSFolder;
1379 1375
 	rv->fFolder = this;
... ...
@@ -1392,12 +1388,12 @@ CdGDSObj *CdGDSFolder::AddFolder(const UTF16String &Name)
1392 1388
 	return rv;
1393 1389
 }
1394 1390
 
1395
-CdGDSObj *CdGDSFolder::AddObj(const UTF16String &Name, CdGDSObj *val)
1391
+CdGDSObj *CdGDSFolder::AddObj(const UTF8String &Name, CdGDSObj *val)
1396 1392
 {
1397 1393
 	return InsertObj(-1, Name, val);
1398 1394
 }
1399 1395
 
1400
-CdGDSObj *CdGDSFolder::InsertObj(int index, const UTF16String &Name,
1396
+CdGDSObj *CdGDSFolder::InsertObj(int index, const UTF8String &Name,
1401 1397
 	CdGDSObj *val)
1402 1398
 {
1403 1399
 	if ((index < -1) || (index > (int)fList.size()))
... ...
@@ -1409,9 +1405,9 @@ CdGDSObj *CdGDSFolder::InsertObj(int index, const UTF16String &Name,
1409 1405
 	_CheckGDSStream();
1410 1406
 
1411 1407
 	if (!_ValidName(Name))
1412
-		throw ErrGDSObj(ERR_NAME_INVALID, UTF16ToUTF8(Name).c_str());
1408
+		throw ErrGDSObj(ERR_NAME_INVALID, Name.c_str());
1413 1409
 	if (_HasName(Name))
1414
-		throw ErrGDSObj(ERR_NAME_EXIST, UTF16ToUTF8(Name).c_str());
1410
+		throw ErrGDSObj(ERR_NAME_EXIST, Name.c_str());
1415 1411
 
1416 1412
 	TNode I;
1417 1413
 	if (val == NULL)
... ...
@@ -1571,17 +1567,17 @@ CdGDSFolder & CdGDSFolder::DirItem(int Index)
1571 1567
 	if (dynamic_cast<CdGDSFolder*>(I.Obj))
1572 1568
 		return *static_cast<CdGDSFolder*>(I.Obj);
1573 1569
 	else
1574
-    	throw ErrGDSObj(ERR_NO_FOLDER, UTF16ToUTF8(I.Name).c_str());
1570
+    	throw ErrGDSObj(ERR_NO_FOLDER, I.Name.c_str());
1575 1571
 }
1576 1572
 
1577
-CdGDSFolder & CdGDSFolder::DirItem(const UTF16String &Name)
1573
+CdGDSFolder & CdGDSFolder::DirItem(const UTF8String &Name)
1578 1574
 {
1579 1575
 	CdGDSFolder::TNode &I = _NameItem(Name);
1580 1576
 	_LoadItem(I);
1581 1577
 	if (dynamic_cast<CdGDSFolder*>(I.Obj))
1582 1578
 		return *static_cast<CdGDSFolder*>(I.Obj);
1583 1579
 	else
1584
-    	throw ErrGDSObj(ERR_NO_FOLDER, UTF16ToUTF8(I.Name).c_str());
1580
+    	throw ErrGDSObj(ERR_NO_FOLDER, I.Name.c_str());
1585 1581
 }
1586 1582
 
1587 1583
 CdGDSObj *CdGDSFolder::ObjItem(int Index)
... ...
@@ -1593,7 +1589,7 @@ CdGDSObj *CdGDSFolder::ObjItem(int Index)
1593 1589
 	return I.Obj;
1594 1590
 }
1595 1591
 
1596
-CdGDSObj *CdGDSFolder::ObjItem(const UTF16String &Name)
1592
+CdGDSObj *CdGDSFolder::ObjItem(const UTF8String &Name)
1597 1593
 {
1598 1594
 	CdGDSFolder::TNode &I = _NameItem(Name);
1599 1595
 	_LoadItem(I);
... ...
@@ -1609,7 +1605,7 @@ CdGDSObj *CdGDSFolder::ObjItemEx(int Index)
1609 1605
 	return I.Obj;
1610 1606
 }
1611 1607
 
1612
-CdGDSObj *CdGDSFolder::ObjItemEx(const UTF16String &Name)
1608
+CdGDSObj *CdGDSFolder::ObjItemEx(const UTF8String &Name)
1613 1609
 {
1614 1610
 	vector<CdGDSFolder::TNode>::iterator it;
1615 1611
 	for (it = fList.begin(); it != fList.end(); it++)
... ...
@@ -1623,18 +1619,18 @@ CdGDSObj *CdGDSFolder::ObjItemEx(const UTF16String &Name)
1623 1619
 	return NULL;
1624 1620
 }
1625 1621
 
1626
-CdGDSObj *CdGDSFolder::Path(const UTF16String &FullName)
1622
+CdGDSObj *CdGDSFolder::Path(const UTF8String &FullName)
1627 1623
 {
1628 1624
 	CdGDSObj *rv = PathEx(FullName);
1629 1625
 	if (!rv)
1630
-		throw ErrGDSObj(ERR_INVALID_PATH, UTF16ToUTF8(FullName).c_str());
1626
+		throw ErrGDSObj(ERR_INVALID_PATH, FullName.c_str());
1631 1627
 	return rv;
1632 1628
 }
1633 1629
 
1634
-CdGDSObj *CdGDSFolder::PathEx(const UTF16String &FullName)
1630
+CdGDSObj *CdGDSFolder::PathEx(const UTF8String &FullName)
1635 1631
 {
1636
-	static const C_UTF16 delimit = '/';
1637
-	const C_UTF16 *p = FullName.c_str();
1632
+	const char delimit = '/';
1633
+	const char *p = FullName.c_str();
1638 1634
 
1639 1635
 	CdGDSObj *rv = this;
1640 1636
 	while ((*p) && (rv))
... ...
@@ -1643,32 +1639,17 @@ CdGDSObj *CdGDSFolder::PathEx(const UTF16String &FullName)
1643 1639
 			return NULL;
1644 1640
 		if (*p == delimit) p ++;
1645 1641
 
1646
-		const C_UTF16 *s = p;
1642
+		const char *s = p;
1647 1643
 		while ((*p != delimit) && (*p != 0))
1648 1644
 			p ++;
1649 1645
 		if (s == p)
1650 1646
 			return rv;
1651
-		rv = ((CdGDSAbsFolder*)rv)->ObjItemEx(UTF16String(s, p));
1647
+		rv = ((CdGDSAbsFolder*)rv)->ObjItemEx(UTF8String(s, p));
1652 1648
 	}
1653 1649
 
1654 1650
 	return rv;
1655 1651
 }
1656 1652
 
1657
-void CdGDSFolder::SplitPath(const UTF16String &FullName, UTF16String &Path,
1658
-	UTF16String &Name)
1659
-{
1660
-	static const C_UTF16 delimit = '/';
1661
-	size_t pos = FullName.find(delimit);
1662
-	if (pos == UTF16String::npos)
1663
-	{
1664
-		Path.clear();
1665
-		Name = FullName;
1666
-	} else {
1667
-		Path = FullName.substr(0, pos);
1668
-        Name = FullName.substr(pos+1, FullName.size()-pos-1);
1669
-    }
1670
-}
1671
-
1672 1653
 int CdGDSFolder::IndexObj(CdGDSObj *Obj)
1673 1654
 {
1674 1655
 	vector<CdGDSObj*> lst;
... ...
@@ -1783,7 +1764,7 @@ void CdGDSFolder::_ClearFolder()
1783 1764
 	fList.clear();
1784 1765
 }
1785 1766
 
1786
-bool CdGDSFolder::_HasName(const UTF16String &Name)
1767
+bool CdGDSFolder::_HasName(const UTF8String &Name)
1787 1768
 {
1788 1769
 	vector<CdGDSFolder::TNode>::iterator it;
1789 1770
 	for (it = fList.begin(); it != fList.end(); it++)
... ...
@@ -1792,23 +1773,23 @@ bool CdGDSFolder::_HasName(const UTF16String &Name)
1792 1773
 	return false;
1793 1774
 }
1794 1775
 
1795
-bool CdGDSFolder::_ValidName(const UTF16String &Name)
1776
+bool CdGDSFolder::_ValidName(const UTF8String &Name)
1796 1777
 {
1797 1778
 	for (size_t i=0; i < Name.size(); i++)
1798 1779
 	{
1799
-		if (Name[i] == '/')
1800
-			return false;
1780
+		char ch = Name[i];
1781
+		if (ch=='/' || ch=='\x0') return false;
1801 1782
 	}
1802 1783
 	return true;
1803 1784
 }
1804 1785
 
1805
-CdGDSFolder::TNode &CdGDSFolder::_NameItem(const UTF16String &Name)
1786
+CdGDSFolder::TNode &CdGDSFolder::_NameItem(const UTF8String &Name)
1806 1787
 {
1807 1788
 	vector<CdGDSFolder::TNode>::iterator it;
1808 1789
 	for (it = fList.begin(); it != fList.end(); it++)
1809 1790
 		if (it->Name == Name)
1810 1791
 			return *it;
1811
-	throw ErrGDSObj(ERR_FOLDER_NAME, UTF16ToUTF8(Name).c_str());
1792
+	throw ErrGDSObj(ERR_FOLDER_NAME, Name.c_str());
1812 1793
 }
1813 1794
 
1814 1795
 void CdGDSFolder::_LoadItem(TNode &I)
... ...
@@ -1880,7 +1861,6 @@ void CdGDSFolder::_LoadItem(TNode &I)
1880 1861
 			Reader.EndStruct();
1881 1862
 
1882 1863
 		} else {
1883
-
1884 1864
 			// it is a class object
1885 1865
 			CdObjRef *obj = NULL;
1886 1866
 
... ...
@@ -2068,19 +2048,19 @@ void CdGDSVirtualFolder::SetLinkFile(const UTF8String &FileName)
2068 2048
 	}
2069 2049
 }
2070 2050
 
2071
-CdGDSObj *CdGDSVirtualFolder::AddFolder(const UTF16String &Name)
2051
+CdGDSObj *CdGDSVirtualFolder::AddFolder(const UTF8String &Name)
2072 2052
 {
2073 2053
 	_CheckLinked();
2074 2054
 	return fLinkFile->Root().AddFolder(Name);
2075 2055
 }
2076 2056
 
2077
-CdGDSObj *CdGDSVirtualFolder::AddObj(const UTF16String &Name, CdGDSObj *val)
2057
+CdGDSObj *CdGDSVirtualFolder::AddObj(const UTF8String &Name, CdGDSObj *val)
2078 2058
 {
2079 2059
 	_CheckLinked();
2080 2060
 	return fLinkFile->Root().AddObj(Name, val);
2081 2061
 }
2082 2062
 
2083
-CdGDSObj *CdGDSVirtualFolder::InsertObj(int index, const UTF16String &Name,
2063
+CdGDSObj *CdGDSVirtualFolder::InsertObj(int index, const UTF8String &Name,
2084 2064
 	CdGDSObj *val)
2085 2065
 {
2086 2066
 	_CheckLinked();
... ...
@@ -2117,7 +2097,7 @@ CdGDSObj *CdGDSVirtualFolder::ObjItem(int Index)
2117 2097
 	return fLinkFile->Root().ObjItem(Index);
2118 2098
 }
2119 2099
 
2120
-CdGDSObj *CdGDSVirtualFolder::ObjItem(const UTF16String &Name)
2100
+CdGDSObj *CdGDSVirtualFolder::ObjItem(const UTF8String &Name)
2121 2101
 {
2122 2102
 	_CheckLinked();
2123 2103
 	return fLinkFile->Root().ObjItem(Name);
... ...
@@ -2129,19 +2109,19 @@ CdGDSObj *CdGDSVirtualFolder::ObjItemEx(int Index)
2129 2109
 	return fLinkFile->Root().ObjItemEx(Index);
2130 2110
 }
2131 2111
 
2132
-CdGDSObj *CdGDSVirtualFolder::ObjItemEx(const UTF16String &Name)
2112
+CdGDSObj *CdGDSVirtualFolder::ObjItemEx(const UTF8String &Name)
2133 2113
 {
2134 2114
 	_CheckLinked();
2135 2115
 	return fLinkFile->Root().ObjItemEx(Name);
2136 2116
 }
2137 2117
 
2138
-CdGDSObj *CdGDSVirtualFolder::Path(const UTF16String &FullName)
2118
+CdGDSObj *CdGDSVirtualFolder::Path(const UTF8String &FullName)
2139 2119
 {
2140 2120
 	_CheckLinked();
2141 2121
 	return fLinkFile->Root().Path(FullName);
2142 2122
 }
2143 2123
 
2144
-CdGDSObj *CdGDSVirtualFolder::PathEx(const UTF16String &FullName)
2124
+CdGDSObj *CdGDSVirtualFolder::PathEx(const UTF8String &FullName)
2145 2125
 {
2146 2126
 	_CheckLinked();
2147 2127
 	return fLinkFile->Root().PathEx(FullName);
... ...
@@ -2480,17 +2460,17 @@ CdGDSRoot::CdGDSRoot(): CdGDSFolder()
2480 2460
 	fVFolder = NULL;
2481 2461
 }
2482 2462
 
2483
-UTF16String CdGDSRoot::Name() const
2463
+UTF8String CdGDSRoot::Name() const
2484 2464
 {
2485 2465
 	if (fVFolder)
2486 2466
 	{
2487 2467
 		return fVFolder->Name();
2488 2468
 	} else {
2489
-		return UTF16String();
2469
+		return UTF8String();
2490 2470
 	}
2491 2471
 }
2492 2472
 
2493
-void CdGDSRoot::SetName(const UTF16String &NewName)
2473
+void CdGDSRoot::SetName(const UTF8String &NewName)
2494 2474
 {
2495 2475
 	if (fVFolder)
2496 2476
 	{
Browse code

NOEXCEPT in virtual destructor function

Xiuwen Zheng authored on 12/12/2018 06:20:39
Showing1 changed files
... ...
@@ -2597,18 +2597,10 @@ CdGDSFile::CdGDSFile(const char *fn, TdOpenMode Mode):
2597 2597
 	}
2598 2598
 }
2599 2599
 
2600
-CdGDSFile::~CdGDSFile() COREARRAY_NOEXCEPT_FALSE
2600
+CdGDSFile::~CdGDSFile()
2601 2601
 {
2602 2602
 	CloseFile();
2603
-	if (fLog)
2604
-	{
2605
-	#ifdef COREARRAY_CODE_DEBUG
2606
-		if (fLog->Release() != 0)
2607
-			throw ErrSerial("Log::Release() should return 0 here.");
2608
-	#else
2609
-		fLog->Release();
2610
-	#endif
2611
-	}
2603
+	if (fLog) fLog->Release();
2612 2604
 }
2613 2605
 
2614 2606
 void CdGDSFile::LoadStream(CdStream *Stream, bool ReadOnly)
Browse code

fix -Wterminate warnings

Xiuwen Zheng authored on 10/12/2018 20:18:33
Showing1 changed files
... ...
@@ -2597,7 +2597,7 @@ CdGDSFile::CdGDSFile(const char *fn, TdOpenMode Mode):
2597 2597
 	}
2598 2598
 }
2599 2599
 
2600
-CdGDSFile::~CdGDSFile()
2600
+CdGDSFile::~CdGDSFile() COREARRAY_NOEXCEPT_FALSE
2601 2601
 {
2602 2602
 	CloseFile();
2603 2603
 	if (fLog)
Browse code

new data type

Xiuwen Zheng authored on 04/12/2018 19:06:36
Showing1 changed files
... ...
@@ -1293,6 +1293,7 @@ void CdGDSLabel::Assign(CdGDSObj &Source, bool Full)
1293 1293
 // =====================================================================
1294 1294
 
1295 1295
 static const char *ERR_NAME_EXIST   = "The GDS node \"%s\" exists.";
1296
+static const char *ERR_NAME_INVALID = "The GDS node name \"%s\" should not contain '/'.";
1296 1297
 static const char *ERR_FOLDER_ITEM  = "Invalid index %d.";
1297 1298
 static const char *ERR_FOLDER_NAME  = "Invalid node name \"%s\".";
1298 1299
 static const char *ERR_NO_FOLDER    = "There is not a folder named \"%s\".";
... ...
@@ -1369,6 +1370,8 @@ CdGDSObj *CdGDSFolder::AddFolder(const UTF16String &Name)
1369 1370
 	_CheckWritable();
1370 1371
 	_CheckGDSStream();
1371 1372
 
1373
+	if (!_ValidName(Name))
1374
+		throw ErrGDSObj(ERR_NAME_INVALID, UTF16ToUTF8(Name).c_str());
1372 1375
 	if (_HasName(Name))
1373 1376
 		throw ErrGDSObj(ERR_NAME_EXIST, UTF16ToUTF8(Name).c_str());
1374 1377
 
... ...
@@ -1405,6 +1408,8 @@ CdGDSObj *CdGDSFolder::InsertObj(int index, const UTF16String &Name,
1405 1408
 	_CheckWritable();
1406 1409
 	_CheckGDSStream();
1407 1410
 
1411
+	if (!_ValidName(Name))
1412
+		throw ErrGDSObj(ERR_NAME_INVALID, UTF16ToUTF8(Name).c_str());
1408 1413
 	if (_HasName(Name))
1409 1414
 		throw ErrGDSObj(ERR_NAME_EXIST, UTF16ToUTF8(Name).c_str());
1410 1415
 
... ...
@@ -1787,6 +1792,16 @@ bool CdGDSFolder::_HasName(const UTF16String &Name)
1787 1792
 	return false;
1788 1793
 }
1789 1794
 
1795
+bool CdGDSFolder::_ValidName(const UTF16String &Name)
1796
+{
1797
+	for (size_t i=0; i < Name.size(); i++)
1798
+	{
1799
+		if (Name[i] == '/')
1800
+			return false;
1801
+	}
1802
+	return true;
1803
+}
1804
+
1790 1805
 CdGDSFolder::TNode &CdGDSFolder::_NameItem(const UTF16String &Name)
1791 1806
 {
1792 1807
 	vector<CdGDSFolder::TNode>::iterator it;
Browse code

enable lzma_ultra and lzma_ultra_max

Xiuwen Zheng authored on 13/04/2018 21:09:24
Showing1 changed files
... ...
@@ -8,7 +8,7 @@
8 8
 //
9 9
 // dFile.cpp: Functions and classes for CoreArray Genomic Data Structure (GDS)
10 10
 //
11
-// Copyright (C) 2007-2017    Xiuwen Zheng
11
+// Copyright (C) 2007-2018    Xiuwen Zheng
12 12
 //
13 13
 // This file is part of CoreArray.
14 14
 //
... ...
@@ -553,12 +553,14 @@ namespace CoreArray
553 553
 	static const char *VAR_PIPE_LEVEL  = "PIPE_LEVEL";
554 554
 	static const char *VAR_PIPE_BKSIZE = "PIPE_BKSIZE";
555 555
 
556
-	static const CdRecodeStream::TLevel CompressionLevels[5] =
556
+	static const CdRecodeStream::TLevel CompressionLevels[] =
557 557
 	{
558 558
 		CdRecodeStream::clMin,
559 559
 		CdRecodeStream::clFast,
560 560
 		CdRecodeStream::clDefault,
561 561
 		CdRecodeStream::clMax,
562
+		CdRecodeStream::clUltra,     // ultra  (LZMA 512MiB)
563
+		CdRecodeStream::clUltraMax,  // ultra_max  (LZMA 1536MiB)
562 564
 		CdRecodeStream::clDefault
563 565
 	};
564 566
 
... ...
@@ -729,7 +731,7 @@ namespace CoreArray
729 731
 				BYTE_LE<CdStream> S(Stream);
730 732
 				S.SetPosition(vSizeInfo_Ptr);
731 733
 				S << fStreamTotalIn << fStreamTotalOut;
732
-            }
734
+			}
733 735
 		}
734 736
 		virtual void LoadStream(CdReader &Reader, TdVersion Version)
735 737
 		{
... ...
@@ -751,11 +753,12 @@ namespace CoreArray
751 753
 			{
752 754
 				C_UInt8 I = 0;
753 755
 				Reader[VAR_PIPE_LEVEL] >> I;
754
-				if (I > 3)
756
+				if (I > 5)
755 757
 				{
756 758
 					// Since clNone=0, clFast=1, clDefault=2, clMax=3
757
-            	    throw ErrGDSObj("Invalid 'PIPE_LEVEL %d'", I);
758
-            	}
759
+					// clUltra=4, clUltraMax=5
760
+					throw ErrGDSObj("Invalid 'PIPE_LEVEL %d'", I);
761
+				}
759 762
 				fLevel = (CdRecodeStream::TLevel)I;
760 763
 			} else
761 764
 				fLevel = CdRecodeStream::clUnknown;
... ...
@@ -801,7 +804,7 @@ namespace CoreArray
801 804
 
802 805
 	static const char *ZIP_Strings[] =
803 806
 	{
804
-		"ZIP.min", "ZIP.fast", "ZIP.def", "ZIP.max", "ZIP", NULL
807
+		"ZIP.min", "ZIP.fast", "ZIP.def", "ZIP.max", "", "", "ZIP", NULL
805 808
 	};
806 809
 
807 810
 	class COREARRAY_DLL_DEFAULT CdPipeZIP:
... ...
@@ -832,7 +835,8 @@ namespace CoreArray
832 835
 
833 836
 	static const char *ZRA_Strings[] =
834 837
 	{
835
-		"ZIP_RA.min", "ZIP_RA.fast", "ZIP_RA.def", "ZIP_RA.max", "ZIP_RA", NULL
838
+		"ZIP_RA.min", "ZIP_RA.fast", "ZIP_RA.def", "ZIP_RA.max",
839
+		"", "", "ZIP_RA", NULL
836 840
 	};
837 841
 
838 842
 	class COREARRAY_DLL_DEFAULT CdPipeZRA:
... ...
@@ -866,7 +870,7 @@ namespace CoreArray
866 870
 
867 871
 	static const char *LZ4_Strings[] =
868 872
 	{
869
-		"LZ4.min", "LZ4.fast", "LZ4.hc", "LZ4.max", "LZ4", NULL
873
+		"LZ4.min", "LZ4.fast", "LZ4.hc", "LZ4.max", "", "", "LZ4", NULL
870 874
 	};
871 875
 	static const char *LZ4_Str_BSize[] =
872 876
 		{ "64K", "256K", "1M", "4M", NULL };
... ...
@@ -906,7 +910,8 @@ namespace CoreArray
906 910
 
907 911
 	static const char *LZ4RA_Strings[] =
908 912
 	{
909
-		"LZ4_RA.min", "LZ4_RA.fast", "LZ4_RA.hc", "LZ4_RA.max", "LZ4_RA", NULL
913
+		"LZ4_RA.min", "LZ4_RA.fast", "LZ4_RA.hc", "LZ4_RA.max",
914
+		"", "", "LZ4_RA", NULL
910 915
 	};
911 916
 
912 917
 	class COREARRAY_DLL_DEFAULT CdPipeLZ4RA:
... ...
@@ -948,7 +953,8 @@ namespace CoreArray
948 953
 
949 954
 	static const char *XZ_Strings[] =
950 955
 	{
951
-		"LZMA.min", "LZMA.fast", "LZMA.def", "LZMA.max", "LZMA", NULL
956
+		"LZMA.min", "LZMA.fast", "LZMA.def", "LZMA.max",
957
+		"LZMA.ultra", "LZMA.ultra_max", "LZMA", NULL
952 958
 	};
953 959
 
954 960
 	class COREARRAY_DLL_DEFAULT CdPipeXZ:
... ...
@@ -971,7 +977,7 @@ namespace CoreArray
971 977
 
972 978
 
973 979
 	// =====================================================================
974
-	// ZRA: ZIP Pipe with the support of random access
980
+	// XZ_RA: XZ Pipe with the support of random access
975 981
 	// =====================================================================
976 982
 
977 983
 	typedef CdStreamPipe2<CdXZDecoder_RA> CdXZReadPipe_RA;
... ...
@@ -979,7 +985,8 @@ namespace CoreArray
979 985
 
980 986
 	static const char *XZ_RA_Strings[] =
981 987
 	{
982
-		"LZMA_RA.min", "LZMA_RA.fast", "LZMA_RA.def", "LZMA_RA.max", "LZMA_RA", NULL
988
+		"LZMA_RA.min", "LZMA_RA.fast", "LZMA_RA.def", "LZMA_RA.max",
989
+		"LZMA_RA.ultra", "LZMA_RA.ultra_max", "LZMA_RA", NULL
983 990
 	};
984 991
 
985 992
 	class COREARRAY_DLL_DEFAULT CdPipeXZ_RA:
... ...
@@ -1048,6 +1055,40 @@ CdPipeMgrItem2::CdPipeMgrItem2(): CdPipeMgrItem()
1048 1055
 	fCoderIndex = fParamIndex = -1;
1049 1056
 }
1050 1057
 
1058
+string CdPipeMgrItem2::CoderOptString() const
1059
+{
1060
+	string rv;
1061
+	const char **ss = CoderList();
1062
+	for (; *ss; ss++)
1063
+	{
1064
+		if (strlen(*ss) > 0)
1065
+		{
1066
+			if (!rv.empty()) rv.append(", ");
1067
+			rv.append(*ss);
1068
+		}
1069
+	}
1070
+	return rv;
1071
+}
1072
+
1073
+string CdPipeMgrItem2::ExtOptString() const
1074
+{
1075
+	string rv;
1076
+	const char **ss = ParamList();
1077
+	if (ss)
1078
+	{
1079
+		for (; *ss; ss++)
1080
+		{
1081
+			if (strlen(*ss) > 0)
1082
+			{
1083
+				if (!rv.empty()) rv.append(", ");
1084
+				rv.append(":");
1085
+				rv.append(*ss);
1086
+			}
1087
+		}
1088
+	}
1089
+	return rv;
1090
+}
1091
+
1051 1092
 bool CdPipeMgrItem2::Equal(const char *Mode) const
1052 1093
 {
1053 1094
 	int ic, ip;
... ...
@@ -1088,7 +1129,7 @@ void CdPipeMgrItem2::ParseMode(const char *Mode, int &IdxCoder,
1088 1129
 	const char **ss = CoderList();
1089 1130
 	for (int i=0; *ss != NULL; ss++, i++)
1090 1131
 	{
1091
-		if (EqualText(s.c_str(), *ss))
1132
+		if (strlen(*ss)>0 && EqualText(s.c_str(), *ss))
1092 1133
 		{
1093 1134
 			IdxCoder = i;
1094 1135
 			break;
... ...
@@ -1101,7 +1142,7 @@ void CdPipeMgrItem2::ParseMode(const char *Mode, int &IdxCoder,
1101 1142
 	{
1102 1143
 		for (int i=0; *ss != NULL; ss++, i++)
1103 1144
 		{
1104
-			if (EqualText(Mode, *ss))
1145
+			if (strlen(*ss)>0 && EqualText(Mode, *ss))
1105 1146
 			{
1106 1147
 				IdxParam = i;
1107 1148
 				break;
Browse code

avoid deprecated functions

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/gdsfmt@127510 bc3139a8-67e5-0310-9ffc-ced21a209358

Xiuwen Zheng authored on 20/03/2017 08:15:57
Showing1 changed files
... ...
@@ -859,6 +859,8 @@ namespace CoreArray
859 859
 	// LZ4: LZ4 Pipe
860 860
 	// =====================================================================
861 861
 
862
+#ifndef COREARRAY_NO_LZ4
863
+
862 864
 	typedef CdStreamPipe2<CdLZ4Decoder> CdLZ4ReadPipe;
863 865
 	typedef CdWritePipe2<CdLZ4Encoder, CdBaseLZ4Stream::TLZ4Chunk> CdLZ4WritePipe;
864 866
 
... ...
@@ -932,11 +934,15 @@ namespace CoreArray
932 934
 		virtual const char **ParamList() const { return RA_Str_BSize; }
933 935
 	};
934 936
 
937
+#endif
938
+
935 939
 
936 940
 	// =====================================================================
937 941
 	// XZ: xz stream
938 942
 	// =====================================================================
939 943
 
944
+#ifndef COREARRAY_NO_LZMA
945
+
940 946
 	typedef CdStreamPipe2<CdXZDecoder> CdXZReadPipe;
941 947
 	typedef CdWritePipe<CdXZEncoder> CdXZWritePipe;
942 948
 
... ...
@@ -994,6 +1000,9 @@ namespace CoreArray
994 1000
 		virtual const char **CoderList() const { return XZ_RA_Strings; }
995 1001
 		virtual const char **ParamList() const { return RA_Str_BSize; }
996 1002
 	};
1003
+
1004
+#endif
1005
+
997 1006
 }
998 1007
 
999 1008
 
... ...
@@ -1112,10 +1121,14 @@ CdStreamPipeMgr::CdStreamPipeMgr(): CdAbstractManager()
1112 1121
 {
1113 1122
 	Register(new CdPipeZIP);
1114 1123
 	Register(new CdPipeZRA);
1124
+#ifndef COREARRAY_NO_LZ4
1115 1125
 	Register(new CdPipeLZ4);
1116 1126
 	Register(new CdPipeLZ4RA);
1127
+#endif
1128
+#ifndef COREARRAY_NO_LZMA
1117 1129
 	Register(new CdPipeXZ);
1118 1130
 	Register(new CdPipeXZ_RA);
1131
+#endif
1119 1132
 }
1120 1133
 
1121 1134
 CdStreamPipeMgr::~CdStreamPipeMgr()
Browse code

update liblzma and lz4

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/gdsfmt@127259 bc3139a8-67e5-0310-9ffc-ced21a209358

Xiuwen Zheng authored on 08/03/2017 21:05:21
Showing1 changed files
... ...
@@ -8,7 +8,7 @@
8 8
 //
9 9
 // dFile.cpp: Functions and classes for CoreArray Genomic Data Structure (GDS)
10 10
 //