mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-23 13:25:27 +00:00
Replace usage of wcj by C API
This commit is contained in:
parent
b0c2dea772
commit
f26f04b5fe
@ -77,16 +77,12 @@ bool IOModesController::prepareForWriting()
|
|||||||
|
|
||||||
bool IOModesController::allChangesComitted()
|
bool IOModesController::allChangesComitted()
|
||||||
{
|
{
|
||||||
// Get a list of available write changes
|
RzCoreLocked core(Core());
|
||||||
CutterJson changes = Core()->cmdj("wcj");
|
for (auto c : CutterPVector<RzIOCache>(&core->io->cache)) {
|
||||||
|
if (!c->written) {
|
||||||
// Check if there is a change which isn't written to the file
|
|
||||||
for (CutterJson changeObject : changes) {
|
|
||||||
if (!changeObject["written"].toBool()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,32 @@
|
|||||||
(char *)it != (char *)(vec)->a + ((vec)->len * (vec)->elem_size); \
|
(char *)it != (char *)(vec)->a + ((vec)->len * (vec)->elem_size); \
|
||||||
it = (type *)((char *)it + (vec)->elem_size))
|
it = (type *)((char *)it + (vec)->elem_size))
|
||||||
|
|
||||||
|
template<typename T> class CutterPVector
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
const RzPVector * const vec;
|
||||||
|
|
||||||
|
public:
|
||||||
|
class iterator : public std::iterator<std::input_iterator_tag, T *>
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
T **p;
|
||||||
|
|
||||||
|
public:
|
||||||
|
iterator(T **p) : p(p) {}
|
||||||
|
iterator(const iterator &o) : p(o.p) {}
|
||||||
|
iterator &operator++() { p++; return *this; }
|
||||||
|
iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; }
|
||||||
|
bool operator==(const iterator &rhs) const {return p == rhs.p;}
|
||||||
|
bool operator!=(const iterator &rhs) const {return p != rhs.p;}
|
||||||
|
T *operator*() { return *p; }
|
||||||
|
};
|
||||||
|
|
||||||
|
CutterPVector(const RzPVector *vec) : vec(vec) {}
|
||||||
|
iterator begin() const { return iterator(reinterpret_cast<T **>(vec->v.a)); }
|
||||||
|
iterator end() const { return iterator(reinterpret_cast<T **>(vec->v.a) + vec->v.len); }
|
||||||
|
};
|
||||||
|
|
||||||
// Global information for Cutter
|
// Global information for Cutter
|
||||||
#define APPNAME "Cutter"
|
#define APPNAME "Cutter"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user