Static Value-Flow Analysis
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 678 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 681 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 687 of file SVFFileSystem.h.

688 {
689 assert(idMap.empty() &&
690 "idToObjMap should be empty when creating objects");
691 ABORT_IFNOT(jsonIsArray(idObjArrayJson), "expects an array");
692
694 {
695 ABORT_IFNOT(jsonIsObject(objJson), "expects an object");
697 // creator is allowed to change objFieldJson
699 auto pair = std::pair<const cJSON*, T*>(objFieldJson, idObj.second);
700 bool inserted = idMap.emplace(idObj.first, pair).second;
701 ABORT_IFNOT(inserted, "ID " << idObj.first << " duplicated in "
702 << idObjArrayJson->string);
703 }
704 }
#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 713 of file SVFFileSystem.h.

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

◆ getPtr()

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

Definition at line 706 of file SVFFileSystem.h.

707 {
708 auto it = idMap.find(id);
709 ABORT_IFNOT(it != idMap.end(), "ID " << id << " not found");
710 return it->second.second;
711 }

◆ saveToIDToObjMap()

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

Definition at line 731 of file SVFFileSystem.h.

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

◆ size()

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

Definition at line 726 of file SVFFileSystem.h.

727 {
728 return idMap.size();
729 }

Member Data Documentation

◆ idMap

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

Definition at line 682 of file SVFFileSystem.h.


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