Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
SVF::ReaderPtrPool< T > Class Template Reference

Reverse of WriterPtrPool where T is object type without ID field. More...

#include <SVFFileSystem.h>

Public Member Functions

void reserve (size_t size)
 
template<typename Creator >
void createObjs (const cJSON *objArrayJson, Creator creator)
 
TgetPtr (size_t id) const
 
template<typename FillFunc >
void fillObjs (FillFunc fillFunc)
 
size_t size () const
 
template<typename Set >
void saveToSet (Set &set) const
 

Private Attributes

std::vector< const cJSON * > jsonArray
 
std::vector< T * > ptrPool
 

Detailed Description

template<typename T>
class SVF::ReaderPtrPool< T >

Reverse of WriterPtrPool where T is object type without ID field.

Template Parameters
T

Definition at line 749 of file SVFFileSystem.h.

Member Function Documentation

◆ createObjs()

template<typename T >
template<typename Creator >
void SVF::ReaderPtrPool< T >::createObjs ( const cJSON objArrayJson,
Creator  creator 
)
inline
Template Parameters
Creator
Parameters
objArrayJson
creator

Definition at line 767 of file SVFFileSystem.h.

768 {
769 assert(jsonArray.empty() &&
770 "jsonArray should be empty when creating objects");
771 ABORT_IFNOT(jsonIsArray(objArrayJson), "expects an array");
772
774 {
775 ABORT_IFNOT(jsonIsObject(objJson), "expects objects in array");
778 jsonArray.push_back(objFieldJson);
779 ptrPool.push_back(obj);
780 }
781 }
#define ABORT_IFNOT(condition, msg)
#define jsonForEach(field, array)
std::vector< T * > ptrPool
std::vector< const cJSON * > jsonArray
bool jsonIsArray(const cJSON *item)
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
bool jsonIsObject(const cJSON *item)
Definition cJSON.h:104
struct cJSON * child
Definition cJSON.h:109

◆ fillObjs()

template<typename T >
template<typename FillFunc >
void SVF::ReaderPtrPool< T >::fillObjs ( FillFunc  fillFunc)
inline

Definition at line 790 of file SVFFileSystem.h.

791 {
792 assert(jsonArray.size() == ptrPool.size() &&
793 "jsonArray and ptrPool should have same size");
794 for (size_t i = 0; i < jsonArray.size(); ++i)
795 {
796 const cJSON*& objFieldJson = jsonArray[i];
798 ABORT_IFNOT(!objFieldJson, "json should be consumed by filler, but "
799 << objFieldJson->string << " left");
800 }
801 jsonArray.clear();
802 jsonArray.shrink_to_fit();
803 }

◆ getPtr()

template<typename T >
T * SVF::ReaderPtrPool< T >::getPtr ( size_t  id) const
inline

Definition at line 783 of file SVFFileSystem.h.

784 {
785 ABORT_IFNOT(id <= ptrPool.size(),
786 "Invalid ID " << id << ". Max ID = " << ptrPool.size());
787 return id ? ptrPool[id - 1] : nullptr;
788 }

◆ reserve()

template<typename T >
void SVF::ReaderPtrPool< T >::reserve ( size_t  size)
inline

Definition at line 756 of file SVFFileSystem.h.

757 {
758 jsonArray.reserve(size);
759 ptrPool.reserve(size);
760 }
size_t size() const

◆ saveToSet()

template<typename T >
template<typename Set >
void SVF::ReaderPtrPool< T >::saveToSet ( Set set) const
inline

Definition at line 810 of file SVFFileSystem.h.

811 {
812 for (T* obj : ptrPool)
813 {
814 set.insert(obj);
815 }
816 }
set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) add_llvm_executable(wpa wpa.cpp) target_link_libraries(wpa PUBLIC $
Definition CMakeLists.txt:1

◆ size()

template<typename T >
size_t SVF::ReaderPtrPool< T >::size ( ) const
inline

Definition at line 805 of file SVFFileSystem.h.

806 {
807 return ptrPool.size();
808 }

Member Data Documentation

◆ jsonArray

template<typename T >
std::vector<const cJSON*> SVF::ReaderPtrPool< T >::jsonArray
private

Definition at line 752 of file SVFFileSystem.h.

◆ ptrPool

template<typename T >
std::vector<T*> SVF::ReaderPtrPool< T >::ptrPool
private

Definition at line 753 of file SVFFileSystem.h.


The documentation for this class was generated from the following file: