PandA-2024.02
Macros | Typedefs | Functions
fileIO.hpp File Reference

utility function used to read files. More...

#include "gzstream.hpp"
#include "refcount.hpp"
#include <filesystem>
#include <iostream>
#include <string>
Include dependency graph for fileIO.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TIMEOUT   124
 Return value of timeout signaling timeout has reached. More...
 
#define ULIMIT   153
 Return value of an application which was signaled by ulimit. More...
 

Typedefs

using fileIO_istreamRef = refcount< std::istream >
 RefCount type definition for the input stream object. More...
 
using fileIO_istreamConstRef = refcount< const std::istream >
 
using fileIO_ostreamRef = refcount< std::ostream >
 RefCount type definition for the input stream object. More...
 

Functions

 CONSTREF_FORWARD_DECL (Parameter)
 
fileIO_istreamRef fileIO_istream_open (const std::string &name)
 this function returns an istream compressed or not. More...
 
fileIO_istreamRef fileIO_istream_open_from_string (const std::string &input)
 Create a fileIO_istreamRef starting from a string. More...
 
fileIO_ostreamRef fileIO_ostream_open (const std::string &name)
 this function returns an ostream compressed or not. More...
 
void CopyStdout (const std::string &filename)
 Copy a file to the standard output. More...
 
std::string GetCurrentPath ()
 
std::string GetPath (std::filesystem::path path)
 
std::string relocate_compiler_path (const std::string &path, bool resolve_path=false)
 
void CopyFile (std::filesystem::path file_source, std::filesystem::path file_target)
 Copy file; if target already exist, overwrite. More...
 
int PandaSystem (const ParameterConstRef Param, const std::string &system_command, bool host_exec=true, const std::string &output="", const unsigned int type=3, const bool background=false, const size_t timeout=0)
 System call forcing execution with bash. More...
 
bool NaturalVersionOrder (const std::filesystem::path &_x, const std::filesystem::path &_y)
 
std::filesystem::path unique_path (const std::filesystem::path &model)
 

Detailed Description

utility function used to read files.

Author
Fabrizio Ferrandi fabri.nosp@m.zio..nosp@m.ferra.nosp@m.ndi@.nosp@m.polim.nosp@m.i.it
Marco Lattuada lattu.nosp@m.ada@.nosp@m.elet..nosp@m.poli.nosp@m.mi.it
Michele Fiorito miche.nosp@m.le.f.nosp@m.iorit.nosp@m.o@po.nosp@m.limi..nosp@m.it $Revision$ $Date$ Last modified by $Author$

Definition in file fileIO.hpp.

Macro Definition Documentation

◆ TIMEOUT

#define TIMEOUT   124

Return value of timeout signaling timeout has reached.

Definition at line 58 of file fileIO.hpp.

◆ ULIMIT

#define ULIMIT   153

Return value of an application which was signaled by ulimit.

Definition at line 61 of file fileIO.hpp.

Typedef Documentation

◆ fileIO_istreamConstRef

using fileIO_istreamConstRef = refcount<const std::istream>

Definition at line 67 of file fileIO.hpp.

◆ fileIO_istreamRef

using fileIO_istreamRef = refcount<std::istream>

RefCount type definition for the input stream object.

Definition at line 66 of file fileIO.hpp.

◆ fileIO_ostreamRef

using fileIO_ostreamRef = refcount<std::ostream>

RefCount type definition for the input stream object.

Definition at line 72 of file fileIO.hpp.

Function Documentation

◆ CONSTREF_FORWARD_DECL()

CONSTREF_FORWARD_DECL ( Parameter  )

◆ CopyFile()

void CopyFile ( std::filesystem::path  file_source,
std::filesystem::path  file_target 
)
inline

Copy file; if target already exist, overwrite.

Parameters
file_sourceis the file to be copied
file_targetis the destination

Definition at line 187 of file fileIO.hpp.

References line(), lenet_tvm::model, NaturalVersionOrder(), output, PandaSystem(), test_panda::type, and unique_path().

Referenced by AlteraBackendFlow::CheckSynthesisResults(), XilinxBackendFlow::CheckSynthesisResults(), CompilerWrapper::CompileFile(), and XilinxBackendFlow::parse_timing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CopyStdout()

void CopyStdout ( const std::string &  filename)
inline

◆ fileIO_istream_open()

fileIO_istreamRef fileIO_istream_open ( const std::string &  name)

this function returns an istream compressed or not.

It first check for a compressed file, then search for the compressed version of the file and finally in case no compressed file is found it look for the plain text file. this function is mainly based on the gzstream wrapper and on zlib library.

Parameters
nameis the file name.
Returns
the refcount to the istream

Definition at line 55 of file fileIO.cpp.

References THROW_ERROR.

Referenced by AsnParser::Exec(), AadlParser::Exec(), Parameter::GetFileFormat(), and TestVectorParser::ParseXMLFile().

Here is the caller graph for this function:

◆ fileIO_istream_open_from_string()

fileIO_istreamRef fileIO_istream_open_from_string ( const std::string &  input)
inline

Create a fileIO_istreamRef starting from a string.

Definition at line 87 of file fileIO.hpp.

Referenced by CInitializationParser::Parse().

Here is the caller graph for this function:

◆ fileIO_ostream_open()

fileIO_ostreamRef fileIO_ostream_open ( const std::string &  name)
inline

this function returns an ostream compressed or not.

this function is mainly based on the gzstream wrapper and on zlib library.

Parameters
nameis the file name.
Returns
the refcount to the ostream

Definition at line 98 of file fileIO.hpp.

Referenced by main().

Here is the caller graph for this function:

◆ GetCurrentPath()

std::string GetCurrentPath ( )
inline

◆ GetPath()

std::string GetPath ( std::filesystem::path  path)
inline

Definition at line 140 of file fileIO.hpp.

References GetCurrentPath().

Referenced by RTLCharacterization::AnalyzeCell(), minimal_interface::build_wrapper(), buildCircuit(), SpiderParameter::CheckParameters(), BambuParameter::CheckParameters(), AlteraBackendFlow::CheckSynthesisResults(), LatticeBackendFlow::CheckSynthesisResults(), NanoXploreBackendFlow::CheckSynthesisResults(), BackendFlow::CreateScripts(), HWDiscrepancyAnalysis::Exec(), GenerateTasteHDLArchitecture::Exec(), WriteHLSSummary::Exec(), WriteTechnology::Exec(), tree_panda_gcc_parameter::Exec(), SpiderParameter::Exec(), EucalyptusParameter::Exec(), Evaluation::Exec(), BambuParameter::Exec(), create_tree_manager::Exec(), SimulationTool::GenerateSimulationScript(), XilinxTasteBackendFlow::GenerateSynthesisScripts(), CompilerWrapper::GetSystemIncludes(), HLS_constraints::HLS_constraints(), TasteInterfaceGeneration::InternalExec(), ControlFlowChecker::InternalExec(), port_swapping::InternalExec(), parametric_list_based::InternalExec(), generic_device::load_devices(), main(), Parameter::ManageDefaultOptions(), PandaSystem(), DataXmlParser::Parse(), TestVectorParser::ParseXMLFile(), SpiderParameter::SetDefaults(), BambuParameter::SetDefaults(), fu_binding::specialise_fu(), fu_binding::specialize_memory_unit(), HDL_manager::write_components(), flopoco_wrapper::writeVHDL(), flopoco_wrapper::writeVHDLcommon(), and RTLCharacterization::xwrite_device_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NaturalVersionOrder()

bool NaturalVersionOrder ( const std::filesystem::path &  _x,
const std::filesystem::path &  _y 
)

Definition at line 195 of file fileIO.cpp.

References distance(), and x.

Referenced by BambuParameter::CheckParameters(), EucalyptusParameter::CheckParameters(), and CopyFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PandaSystem()

int PandaSystem ( const ParameterConstRef  Param,
const std::string &  system_command,
bool  host_exec = true,
const std::string &  output = "",
const unsigned int  type = 3,
const bool  background = false,
const size_t  timeout = 0 
)

System call forcing execution with bash.

Parameters
Paramis the set of input parameters
system_commandis the to be executed
host_execspecifies if the executable is expected to be in the host system or distributed within the AppImage
outputis the file where output has to be saved
typespecifies which streams have to be saved; possible values are 0 (none), 1 (stdout), 2 (stderr), 3(stdout and stderr)
backgroundspecifies if the command has to be executed in background
timeoutis the timeout for the command (in minutes)
Returns
the value returned by the shell

Definition at line 78 of file fileIO.cpp.

References test_panda::command, counter, GetCurrentPath(), GetPath(), OUTPUT_LEVEL_PEDANTIC, STR, STR_CST_file_IO_shell_output_file, STR_CST_file_IO_shell_script, THROW_ASSERT, and THROW_UNREACHABLE.

Referenced by CompilerWrapper::CompileFile(), CopyFile(), CompilerWrapper::CreateExecutable(), CTestbenchExecution::Exec(), BasicBlocksProfiling::Exec(), create_tree_manager::Exec(), ToolManager::execute_command(), FindMaxTransformations::ExecuteBambu(), NonDeterministicFlows::ExecuteTool(), XilinxTasteBackendFlow::GenerateSynthesisScripts(), CompilerWrapper::GetSystemIncludes(), main(), and CompilerWrapper::QueryCompilerConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ relocate_compiler_path()

std::string relocate_compiler_path ( const std::string &  path,
bool  resolve_path = false 
)
inline

◆ unique_path()

std::filesystem::path unique_path ( const std::filesystem::path &  model)

Definition at line 286 of file fileIO.cpp.

References array_rand(), and ran.

Referenced by BambuParameter::CheckParameters(), CompilerWrapper::CompileFile(), CopyFile(), CompilerWrapper::FillTreeManager(), main(), and Parameter::ManageDefaultOptions().

Here is the call graph for this function:
Here is the caller graph for this function:

Generated on Mon Feb 12 2024 13:03:35 for PandA-2024.02 by doxygen 1.8.13