CBMC
jar_pool.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 #include "jar_pool.h"
10 #include "jar_file.h"
11 
12 jar_filet &jar_poolt::operator()(const std::string &file_name)
13 {
14  const auto it = m_archives.find(file_name);
15  if(it == m_archives.end())
16  return m_archives.emplace(file_name, jar_filet(file_name)).first->second;
17  else
18  return it->second;
19 }
20 
22  const std::string &buffer_name,
23  const void *pmem,
24  size_t size)
25 {
26  const auto it = m_archives.find(buffer_name);
27  if(it == m_archives.end())
28  {
29  // VS: Can't construct in place
30  auto file = jar_filet(pmem, size);
31  return m_archives.emplace(buffer_name, std::move(file)).first->second;
32  }
33  else
34  return it->second;
35 }
Class representing a .jar archive.
Definition: jar_file.h:22
jar_filet & add_jar(const std::string &buffer_name, const void *pmem, size_t size)
Add a jar archive or retrieve from cache if already added.
Definition: jar_pool.cpp:21
jar_filet & operator()(const std::string &jar_path)
Load jar archive or retrieve from cache if already loaded.
Definition: jar_pool.cpp:12
std::map< std::string, jar_filet > m_archives
Jar files that have been loaded.
Definition: jar_pool.h:37