Skip to content

Commit

Permalink
made several parameters and methods const
Browse files Browse the repository at this point in the history
  • Loading branch information
mgieseki committed Jan 7, 2025
1 parent b97fcf3 commit 15e6e5e
Show file tree
Hide file tree
Showing 35 changed files with 127 additions and 127 deletions.
6 changes: 3 additions & 3 deletions src/MiKTeXCom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ MiKTeXCom::~MiKTeXCom () {


/** Returns the MiKTeX version number. */
string MiKTeXCom::getVersion () {
string MiKTeXCom::getVersion () const {
#ifdef _MSC_VER
MiKTeXSetupInfo info = _session->GetMiKTeXSetupInfo();
#else
Expand All @@ -71,7 +71,7 @@ string MiKTeXCom::getVersion () {


/** Returns the path of the directory where the MiKTeX binaries are located. */
string MiKTeXCom::getBinDir () {
string MiKTeXCom::getBinDir () const {
#ifdef _MSC_VER
MiKTeXSetupInfo info = _session->GetMiKTeXSetupInfo();
#else
Expand All @@ -86,7 +86,7 @@ string MiKTeXCom::getBinDir () {
/** Try to lookup a given file in the MiKTeX directory tree.
* @param[in] fname name of file to lookup
* @return path of the file or 0 if it can't be found */
const char* MiKTeXCom::findFile (const char *fname) {
const char* MiKTeXCom::findFile (const char *fname) const {
try {
_bstr_t path;
static string ret;
Expand Down
6 changes: 3 additions & 3 deletions src/MiKTeXCom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class MiKTeXCom {
public:
MiKTeXCom ();
~MiKTeXCom ();
std::string getBinDir ();
std::string getVersion ();
const char* findFile (const char* fname);
std::string getBinDir () const;
std::string getVersion () const;
const char* findFile (const char* fname) const;

private:
#ifdef _MSC_VER
Expand Down
6 changes: 3 additions & 3 deletions src/PSPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void PSPattern::apply (SpecialActions &actions) {

/////////////////////////////////////////////////////////////////////////////

PSTilingPattern::PSTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep)
PSTilingPattern::PSTilingPattern (int id, const BoundingBox &bbox, const Matrix &matrix, double xstep, double ystep)
: PSPattern(id), _bbox(bbox), _matrix(matrix), _xstep(xstep), _ystep(ystep)
{
_groupNode = PSTilingPattern::createGroupNode();
Expand Down Expand Up @@ -120,15 +120,15 @@ void PSTilingPattern::apply (SpecialActions &actions) {

/////////////////////////////////////////////////////////////////////////////

PSColoredTilingPattern::PSColoredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep)
PSColoredTilingPattern::PSColoredTilingPattern (int id, const BoundingBox &bbox, const Matrix &matrix, double xstep, double ystep)
: PSTilingPattern(id, bbox, matrix, xstep, ystep)
{
}


/////////////////////////////////////////////////////////////////////////////

PSUncoloredTilingPattern::PSUncoloredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep)
PSUncoloredTilingPattern::PSUncoloredTilingPattern (int id, const BoundingBox &bbox, const Matrix &matrix, double xstep, double ystep)
: PSTilingPattern(id, bbox, matrix, xstep, ystep), _applied()
{
}
Expand Down
6 changes: 3 additions & 3 deletions src/PSPattern.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class PSTilingPattern : public PSPattern {


protected:
PSTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep);
PSTilingPattern (int id, const BoundingBox &bbox, const Matrix &matrix, double xstep, double ystep);
std::unique_ptr<XMLElement> createPatternNode () const override;
virtual std::unique_ptr<XMLElement> createClipNode () const;
virtual std::unique_ptr<XMLElement> createGroupNode () const;
Expand All @@ -78,13 +78,13 @@ class PSTilingPattern : public PSPattern {

class PSColoredTilingPattern final : public PSTilingPattern {
public:
PSColoredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep);
PSColoredTilingPattern (int id, const BoundingBox &bbox, const Matrix &matrix, double xstep, double ystep);
};


class PSUncoloredTilingPattern final : public PSTilingPattern {
public:
PSUncoloredTilingPattern (int id, BoundingBox &bbox, Matrix &matrix, double xstep, double ystep);
PSUncoloredTilingPattern (int id, const BoundingBox &bbox, const Matrix &matrix, double xstep, double ystep);
std::string svgID () const override;
void setColor (Color color) override {_currentColor = color;}
void apply (SpecialActions &actions) override;
Expand Down
2 changes: 1 addition & 1 deletion src/PathClipper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void PathClipper::reconstruct (const Polygons &polygons, CurvedPath &path) {
/** Reconstructs a curved path from a single polygon.
* @param[in] polygon polygon to reconstruct
* @param[out] path the reconstructed curved path */
void PathClipper::reconstruct (const Polygon &polygon, CurvedPath &path) {
void PathClipper::reconstruct (const Polygon &polygon, CurvedPath &path) const {
size_t num_points = polygon.size();
if (num_points < 2)
return;
Expand Down
2 changes: 1 addition & 1 deletion src/PathClipper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PathClipper {
protected:
CurvedPath combine (ClipperLib::ClipType op, const CurvedPath &p1, const CurvedPath &p2);
void flatten (const CurvedPath &gp, ClipperLib::Paths &polygons);
void reconstruct (const ClipperLib::Path &polygon, CurvedPath &path);
void reconstruct (const ClipperLib::Path &polygon, CurvedPath &path) const;
void reconstruct (const ClipperLib::Paths &polygons, CurvedPath &path);
static void callback (IntPoint &e1bot, IntPoint &e1top, IntPoint &e2bot, IntPoint &e2top, IntPoint &ip);

Expand Down
8 changes: 4 additions & 4 deletions src/PsSpecialHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ static string image_base_path (const SpecialActions &actions) {
* @param[in] bbox bounding box of the image
* @param[in] clip if true, the image is clipped to its bounding box
* @return pointer to the element or nullptr if there's no image data */
PsSpecialHandler::ImageNode PsSpecialHandler::createImageNode (FileType type, const string &fname, int pageno, BoundingBox bbox, bool clip) {
PsSpecialHandler::ImageNode PsSpecialHandler::createImageNode (FileType type, const string &fname, int pageno, const BoundingBox &bbox, bool clip) {
ImageNode imgnode;
string pathstr;
if (const char *path = FileFinder::instance().lookup(fname, false))
Expand All @@ -412,7 +412,7 @@ PsSpecialHandler::ImageNode PsSpecialHandler::createImageNode (FileType type, co
}


PsSpecialHandler::ImageNode PsSpecialHandler::createBitmapNode (const string &fname, const string &path, int pageno, BoundingBox bbox) {
PsSpecialHandler::ImageNode PsSpecialHandler::createBitmapNode (const string &fname, const string &path, int pageno, const BoundingBox &bbox) const {
ImageNode imgnode(util::make_unique<SVGElement>("image"));
imgnode.element->addAttribute("x", 0);
imgnode.element->addAttribute("y", 0);
Expand All @@ -434,7 +434,7 @@ PsSpecialHandler::ImageNode PsSpecialHandler::createBitmapNode (const string &fn
}


PsSpecialHandler::ImageNode PsSpecialHandler::createPSNode (const string &fname, const string &path, int pageno, BoundingBox bbox, bool clip) {
PsSpecialHandler::ImageNode PsSpecialHandler::createPSNode (const string &fname, const string &path, int pageno, const BoundingBox &bbox, bool clip) {
ImageNode imgnode(util::make_unique<SVGElement>("g")); // put SVG nodes created from the EPS/PDF file in this group
_xmlnode = imgnode.element.get();
_psi.execute(
Expand Down Expand Up @@ -462,7 +462,7 @@ PsSpecialHandler::ImageNode PsSpecialHandler::createPSNode (const string &fname,
}


PsSpecialHandler::ImageNode PsSpecialHandler::createPDFNode (const string &fname, const string &path, int pageno, BoundingBox bbox, bool clip) {
PsSpecialHandler::ImageNode PsSpecialHandler::createPDFNode (const string &fname, const string &path, int pageno, const BoundingBox &bbox, bool clip) {
if (_pdfProc == "gs" || (_pdfProc.empty() && _psi.supportsPDF()))
return createPSNode(fname, path, pageno, bbox, clip);

Expand Down
8 changes: 4 additions & 4 deletions src/PsSpecialHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ class PsSpecialHandler : public SpecialHandler, protected PSActions {
void executeAndSync (std::istream &is, bool updatePos);
void processHeaderFile (const char *fname);
void imgfile (FileType type, const std::string &fname, const std::map<std::string,std::string> &attr);
ImageNode createImageNode (FileType type, const std::string &fname, int pageno, BoundingBox bbox, bool clip);
ImageNode createBitmapNode (const std::string &fname, const std::string &path, int pageno, BoundingBox bbox);
ImageNode createPSNode (const std::string &fname, const std::string &path, int pageno, BoundingBox bbox, bool clip);
ImageNode createPDFNode (const std::string &fname, const std::string &path, int pageno, BoundingBox bbox, bool clip);
ImageNode createImageNode (FileType type, const std::string &fname, int pageno, const BoundingBox &bbox, bool clip);
ImageNode createBitmapNode (const std::string &fname, const std::string &path, int pageno, const BoundingBox &bbox) const;
ImageNode createPSNode (const std::string &fname, const std::string &path, int pageno, const BoundingBox &bbox, bool clip);
ImageNode createPDFNode (const std::string &fname, const std::string &path, int pageno, const BoundingBox &bbox, bool clip);
void dviBeginPage (unsigned int pageno, SpecialActions &actions) override;
void dviEndPage (unsigned pageno, SpecialActions &actions) override;
void clip (Path path, bool evenodd);
Expand Down
2 changes: 1 addition & 1 deletion src/PsSpecialHandlerProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ inline unique_ptr<SpecialHandler> createPsSpecialHandler () {


/** Replaces this handler proxy with the actual PS special handler. */
SpecialHandler* PsSpecialHandlerProxy::replaceHandler () {
SpecialHandler* PsSpecialHandlerProxy::replaceHandler () const {
auto psSpecialHandler = createPsSpecialHandler();
if (_pswarning) {
#ifdef DISABLE_GS
Expand Down
2 changes: 1 addition & 1 deletion src/PsSpecialHandlerProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PsSpecialHandlerProxy : public SpecialHandler {
std::vector<const char*> prefixes () const override;

protected:
SpecialHandler* replaceHandler ();
SpecialHandler* replaceHandler () const;

private:
bool _pswarning;
Expand Down
10 changes: 5 additions & 5 deletions src/SVGTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void SVGTree::reset () {

/** Sets the bounding box of the document.
* @param[in] bbox bounding box in PS point units */
void SVGTree::setBBox (const BoundingBox &bbox) {
void SVGTree::setBBox (const BoundingBox &bbox) const {
if (ZOOM_FACTOR >= 0) {
_root->addAttribute("width", XMLString(bbox.width()*ZOOM_FACTOR)+"pt");
_root->addAttribute("height", XMLString(bbox.height()*ZOOM_FACTOR)+"pt");
Expand All @@ -77,21 +77,21 @@ void SVGTree::setBBox (const BoundingBox &bbox) {
}


void SVGTree::setFillColor (const Color &c) {
void SVGTree::setFillColor (const Color &c) const {
const Font *font = _charHandler->getFont();
if (!font || font->color() == Color::BLACK)
_charHandler->setFillColor(c);
}


void SVGTree::setStrokeColor (const Color &c) {
void SVGTree::setStrokeColor (const Color &c) const {
const Font *font = _charHandler->getFont();
if (!font || font->color() == Color::BLACK)
_charHandler->setStrokeColor(c);
}


void SVGTree::setFont (int num, const Font &font) {
void SVGTree::setFont (int num, const Font &font) const {
_charHandler->setFont(font, num);
// set default color assigned to the font
if (font.color() != Color::BLACK && getFillColor() != font.color())
Expand Down Expand Up @@ -162,7 +162,7 @@ void SVGTree::prependToPage (unique_ptr<XMLNode> node) {
}


void SVGTree::transformPage (const Matrix &usermatrix) {
void SVGTree::transformPage (const Matrix &usermatrix) const {
_page->setTransform(usermatrix);
}

Expand Down
10 changes: 5 additions & 5 deletions src/SVGTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ class SVGTree {
void popDefsContext ();
void pushPageContext (std::unique_ptr<SVGElement> node);
void popPageContext ();
void setBBox (const BoundingBox &bbox);
void setFont (int id, const Font &font);
void setBBox (const BoundingBox &bbox) const;
void setFont (int id, const Font &font) const;
std::pair<int,const Font*> getFontPair () const;
static bool setFontFormat (std::string formatstr);
void setX (double x) {_charHandler->notifyXAdjusted();}
void setY (double y) {_charHandler->notifyYAdjusted();}
void setMatrix (const Matrix &m) {_charHandler->setMatrix(m);}
void setFillColor (const Color &c);
void setStrokeColor (const Color &c);
void setFillColor (const Color &c) const;
void setStrokeColor (const Color &c) const;
void setOpacity (const Opacity &op) {_charHandler->setOpacity(op);}
void setVertical (bool state) {_charHandler->setVertical(state);}
void transformPage (const Matrix &m);
void transformPage (const Matrix &m) const;
Color getFillColor () const {return _charHandler->getFillColor();}
Color getStrokeColor () const {return _charHandler->getStrokeColor();}
const Opacity& getOpacity () const {return _charHandler->getOpacity();}
Expand Down
2 changes: 1 addition & 1 deletion src/SourceInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ bool TemporaryFile::create () {
* @param[in] buf buffer containing the characters to write
* @param[in] len number of characters to write
* @return true on success */
bool TemporaryFile::write (const char *buf, size_t len) {
bool TemporaryFile::write (const char *buf, size_t len) const {
return opened() && fdwrite(_fd, buf, len) >= 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/SourceInput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TemporaryFile {
~TemporaryFile () {close();}
bool create ();
bool opened () const {return _fd >= 0;}
bool write (const char *buf, size_t len);
bool write (const char *buf, size_t len) const;
bool close ();
const std::string& path () const {return _path;}

Expand Down
2 changes: 1 addition & 1 deletion src/SpecialActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
using namespace std;


inline string get_color_string (SpecialActions &actions, Color (SpecialActions::*getColor)() const) {
inline string get_color_string (const SpecialActions &actions, Color (SpecialActions::*getColor)() const) {
return SVGElement::USE_CURRENTCOLOR && SVGElement::CURRENTCOLOR == (actions.*getColor)()
? "currentColor"
: (actions.*getColor)().svgColorString();
Expand Down
2 changes: 1 addition & 1 deletion src/SpecialManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void SpecialManager::registerHandlers (vector<unique_ptr<SpecialHandler>> &handl


/** Removes a handler and the corresponding prefixes. */
void SpecialManager::unregisterHandler (SpecialHandler *handler) {
void SpecialManager::unregisterHandler (const SpecialHandler *handler) {
if (handler) {
auto it = find_if(_handlerPool.begin(), _handlerPool.end(), [=](unique_ptr<SpecialHandler> &h) {
return h.get() == handler;
Expand Down
2 changes: 1 addition & 1 deletion src/SpecialManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class SpecialManager {
static void registerHandler (std::unique_ptr<SpecialHandler> handler, const std::vector<std::string> &ignoredHandlerNames);
void registerHandler (std::unique_ptr<SpecialHandler> handler);
void registerHandlers (std::vector<std::unique_ptr<SpecialHandler>> &handlers, const char *ignorelist);
void unregisterHandler (SpecialHandler *handler);
void unregisterHandler (const SpecialHandler *handler);
void unregisterHandlers ();
void preprocess (const std::string &special, SpecialActions &actions) const;
bool process (const std::string &special, double dvi2bp, SpecialActions &actions) const;
Expand Down
24 changes: 12 additions & 12 deletions src/StreamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ istream& StreamReader::replaceStream (istream &in) {
/** Reads an unsigned integer from assigned input stream.
* @param[in] bytes number of bytes to read (max. 4)
* @return read integer */
uint32_t StreamReader::readUnsigned (int bytes) {
uint32_t StreamReader::readUnsigned (int bytes) const {
uint32_t ret = 0;
for (bytes--; bytes >= 0 && !_is->eof(); bytes--) {
auto b = uint32_t(_is->get());
Expand All @@ -51,7 +51,7 @@ uint32_t StreamReader::readUnsigned (int bytes) {
* @param[in] n number of bytes to read (max. 4)
* @param[in,out] hashfunc hash to update
* @return read integer */
uint32_t StreamReader::readUnsigned (int n, HashFunction &hashfunc) {
uint32_t StreamReader::readUnsigned (int n, HashFunction &hashfunc) const {
uint32_t ret = readUnsigned(n);
hashfunc.update(util::bytes(ret, n));
return ret;
Expand All @@ -61,7 +61,7 @@ uint32_t StreamReader::readUnsigned (int n, HashFunction &hashfunc) {
/** Reads an signed integer from assigned input stream.
* @param[in] bytes number of bytes to read (max. 4)
* @return read integer */
int32_t StreamReader::readSigned (int bytes) {
int32_t StreamReader::readSigned (int bytes) const {
auto ret = uint32_t(_is->get());
if (ret & 128) // negative value?
ret |= 0xffffff00;
Expand All @@ -75,15 +75,15 @@ int32_t StreamReader::readSigned (int bytes) {
* @param[in] n number of bytes to read (max. 4)
* @param[in,out] hashfunc hash to update
* @return read integer */
int32_t StreamReader::readSigned (int n, HashFunction &hashfunc) {
int32_t StreamReader::readSigned (int n, HashFunction &hashfunc) const {
int32_t ret = readSigned(n);
hashfunc.update(util::bytes(ret, n));
return ret;
}


/** Reads a string terminated by a 0-byte. */
string StreamReader::readString () {
string StreamReader::readString () const {
string ret;
if (_is) {
while (!_is->eof() && _is->peek() > 0)
Expand All @@ -98,7 +98,7 @@ string StreamReader::readString () {
* @param[in,out] hashfunc hash to update
* @param[in] finalZero consider final 0-byte in checksum
* @return the string read */
string StreamReader::readString (HashFunction &hashfunc, bool finalZero) {
string StreamReader::readString (HashFunction &hashfunc, bool finalZero) const {
string ret = readString();
hashfunc.update(ret.data(), ret.length());
if (finalZero)
Expand All @@ -110,7 +110,7 @@ string StreamReader::readString (HashFunction &hashfunc, bool finalZero) {
/** Reads a string of a given length.
* @param[in] length number of characters to read
* @return the string read */
string StreamReader::readString (int length) {
string StreamReader::readString (int length) const {
string str;
if (_is) {
str.resize(max(0, length));
Expand All @@ -124,37 +124,37 @@ string StreamReader::readString (int length) {
* @param[in] length number of characters to read
* @param[in,out] hashfunc hash to update
* @return the string read */
string StreamReader::readString (int length, HashFunction &hashfunc) {
string StreamReader::readString (int length, HashFunction &hashfunc) const {
string ret = readString(length);
hashfunc.update(ret.data(), length);
return ret;
}


vector<uint8_t> StreamReader::readBytes (int n) {
vector<uint8_t> StreamReader::readBytes (int n) const {
vector<uint8_t> bytes(n);
if (n > 0)
_is->read(reinterpret_cast<char*>(bytes.data()), n);
return bytes;
}


vector<uint8_t> StreamReader::readBytes (int n, HashFunction &hashfunc) {
vector<uint8_t> StreamReader::readBytes (int n, HashFunction &hashfunc) const {
vector<uint8_t> bytes = readBytes(n);
hashfunc.update(bytes);
return bytes;
}


vector<char> StreamReader::readBytesAsChars (int n) {
vector<char> StreamReader::readBytesAsChars (int n) const {
vector<char> chars(n);
if (n > 0)
_is->read(chars.data(), n);
return chars;
}


int StreamReader::readByte (HashFunction &hashfunc) {
int StreamReader::readByte (HashFunction &hashfunc) const {
int ret = readByte();
if (ret >= 0) {
char c = char(ret & 0xff);
Expand Down
Loading

0 comments on commit 15e6e5e

Please sign in to comment.