/* Copyright (c) 2022 Alex Diener This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Alex Diener alex@ludobloom.com */ #ifndef __DocumentList_H__ #define __DocumentList_H__ #ifdef __cplusplus extern "C" { #endif typedef struct DocumentList DocumentList; #define DocumentList_superclass StemObject #include "stemobject/StemObject.h" typedef struct DocumentListEntry { char * filePath; bool fileExists; } DocumentListEntry; #define DocumentList_ivars \ StemObject_ivars \ \ unsigned int documentCount; \ DocumentListEntry * documents; #define DocumentList_vtable(self_type) \ StemObject_vtable(self_type) stemobject_declare(DocumentList) DocumentList * DocumentList_create(void); bool DocumentList_init(DocumentList * self); void DocumentList_dispose(DocumentList * self); // Added file paths are unique. If the path being added is already in the list, it will be reordered to the maximum index. // If pruntToCount is nonzero and adding this document would make the list longer than the value specified, the oldest // document is removed from the list. void DocumentList_addDocument(DocumentList * self, const char * filePath, unsigned int pruneToCount); void DocumentList_removeAllDocuments(DocumentList * self); void DocumentList_removeDeletedDocuments(DocumentList * self); void DocumentList_removeDocumentAtIndex(DocumentList * self, unsigned int documentIndex); void DocumentList_removeDocumentWithFilePath(DocumentList * self, const char * filePath); // Removes items from the beginning of the list until the total count is no greater than countMax void DocumentList_pruneToCount(DocumentList * self, unsigned int countMax); void DocumentList_reorderDocument(DocumentList * self, unsigned int fromIndex, unsigned int toIndex); void DocumentList_validateFilesExist(DocumentList * self); #ifdef __cplusplus } #endif #endif