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

Keeps a map from IDs to T objects, such as XXNode. More...

#include <SVFFileSystem.h>

Public Member Functions

template<typename IdObjCreator >
void createObjs (const cJSON *idObjArrayJson, IdObjCreator idObjCreator)
 idObjcreator : (const cJSON*) -> (id, T*) with id set
 
TgetPtr (unsigned id) const
 
template<typename FillFunc >
void fillObjs (FillFunc fillFunc)
 
size_t size () const
 
template<typename Map >
void saveToIDToObjMap (Map &idToObjMap) const
 

Private Types

using IDToPairMapTy = OrderedMap< unsigned, std::pair< const cJSON *, T * > >
 

Private Attributes

IDToPairMapTy idMap
 

Detailed Description

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

Keeps a map from IDs to T objects, such as XXNode.

Template Parameters
TThe type of the objects.

Definition at line 682 of file SVFFileSystem.h.

Member Typedef Documentation

◆ IDToPairMapTy

template<typename T >
using SVF::ReaderIDToObjMap< T >::IDToPairMapTy = OrderedMap<unsigned, std::pair<const cJSON*, T*> >
private

Definition at line 685 of file SVFFileSystem.h.

Member Function Documentation

◆ createObjs()

template<typename T >
template<typename IdObjCreator >
void SVF::ReaderIDToObjMap< T >::createObjs ( const cJSON idObjArrayJson,
IdObjCreator  idObjCreator 
)
inline

idObjcreator : (const cJSON*) -> (id, T*) with id set

Definition at line 691 of file SVFFileSystem.h.

692 {
693 assert(idMap.empty() &&
694 "idToObjMap should be empty when creating objects");
695 ABORT_IFNOT(jsonIsArray(idObjArrayJson), "expects an array");
696
698 {
699 ABORT_IFNOT(jsonIsObject(objJson), "expects an object");
701 // creator is allowed to change objFieldJson
703 auto pair = std::pair<const cJSON*, T*>(objFieldJson, idObj.second);
704 bool inserted = idMap.emplace(idObj.first, pair).second;
705 ABORT_IFNOT(inserted, "ID " << idObj.first << " duplicated in "
706 << idObjArrayJson->string);
707 }
708 }
#define ABORT_IFNOT(condition, msg)
#define jsonForEach(field, array)
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::ReaderIDToObjMap< T >::fillObjs ( FillFunc  fillFunc)
inline

Definition at line 717 of file SVFFileSystem.h.

718 {
719 for (auto& pair : idMap)
720 {
721 const cJSON* objFieldJson = pair.second.first;
722 T* obj = pair.second.second;
724
725 ABORT_IFNOT(!objFieldJson, "json should be consumed by filler, but "
726 << objFieldJson->string << " left");
727 }
728 }

◆ getPtr()

template<typename T >
T * SVF::ReaderIDToObjMap< T >::getPtr ( unsigned  id) const
inline

Definition at line 710 of file SVFFileSystem.h.

711 {
712 auto it = idMap.find(id);
713 ABORT_IFNOT(it != idMap.end(), "ID " << id << " not found");
714 return it->second.second;
715 }

◆ saveToIDToObjMap()

template<typename T >
template<typename Map >
void SVF::ReaderIDToObjMap< T >::saveToIDToObjMap ( Map idToObjMap) const
inline

Definition at line 735 of file SVFFileSystem.h.

736 {
737 for (auto& pair : idMap)
738 {
739 unsigned id = pair.first;
740 T* obj = pair.second.second;
741 assert(obj && "obj should not be null");
742 idToObjMap.insert(std::make_pair(id, obj));
743 }
744 }

◆ size()

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

Definition at line 730 of file SVFFileSystem.h.

731 {
732 return idMap.size();
733 }

Member Data Documentation

◆ idMap

template<typename T >
IDToPairMapTy SVF::ReaderIDToObjMap< T >::idMap
private

Definition at line 686 of file SVFFileSystem.h.


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