WriteSpice::writeHeader use std::filesystem
Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
parent
6a74352b1d
commit
0ddca3171d
|
|
@ -25,6 +25,7 @@
|
||||||
#include "spice/WriteSpice.hh"
|
#include "spice/WriteSpice.hh"
|
||||||
|
|
||||||
#include <algorithm> // swap
|
#include <algorithm> // swap
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#include "Debug.hh"
|
#include "Debug.hh"
|
||||||
#include "Units.hh"
|
#include "Units.hh"
|
||||||
|
|
@ -127,18 +128,6 @@ WriteSpice::initPowerGnd()
|
||||||
gnd_voltage_ = 0.0;
|
gnd_voltage_ = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use c++17 fs::path(filename).stem()
|
|
||||||
static string
|
|
||||||
filenameStem(const char *filename)
|
|
||||||
{
|
|
||||||
string filename1 = filename;
|
|
||||||
const size_t last_slash_idx = filename1.find_last_of("\\/");
|
|
||||||
if (last_slash_idx != std::string::npos)
|
|
||||||
return filename1.substr(last_slash_idx + 1);
|
|
||||||
else
|
|
||||||
return filename1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WriteSpice::writeHeader(string &title,
|
WriteSpice::writeHeader(string &title,
|
||||||
float max_time,
|
float max_time,
|
||||||
|
|
@ -146,9 +135,9 @@ WriteSpice::writeHeader(string &title,
|
||||||
{
|
{
|
||||||
streamPrint(spice_stream_, "* %s\n", title.c_str());
|
streamPrint(spice_stream_, "* %s\n", title.c_str());
|
||||||
streamPrint(spice_stream_, ".include \"%s\"\n", model_filename_);
|
streamPrint(spice_stream_, ".include \"%s\"\n", model_filename_);
|
||||||
string subckt_filename_stem = filenameStem(subckt_filename_);
|
std::filesystem::path subckt_filename
|
||||||
streamPrint(spice_stream_, ".include \"%s\"\n", subckt_filename_stem.c_str());
|
= std::filesystem::path(subckt_filename_).filename();
|
||||||
|
streamPrint(spice_stream_, ".include \"%s\"\n", subckt_filename.c_str());
|
||||||
streamPrint(spice_stream_, ".tran %.3g %.3g\n", time_step, max_time);
|
streamPrint(spice_stream_, ".tran %.3g %.3g\n", time_step, max_time);
|
||||||
// Suppress printing model parameters.
|
// Suppress printing model parameters.
|
||||||
if (ckt_sim_ == CircuitSim::hspice)
|
if (ckt_sim_ == CircuitSim::hspice)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue