mirror of
https://github.com/corda/corda.git
synced 2025-01-09 06:23:04 +00:00
74 lines
1.5 KiB
C++
74 lines
1.5 KiB
C++
/* Copyright (c) 2008, Avian Contributors
|
|
|
|
Permission to use, copy, modify, and/or distribute this software
|
|
for any purpose with or without fee is hereby granted, provided
|
|
that the above copyright notice and this permission notice appear
|
|
in all copies.
|
|
|
|
There is NO WARRANTY for this software. See license.txt for
|
|
details. */
|
|
|
|
#ifndef FINDER_H
|
|
#define FINDER_H
|
|
|
|
#include "common.h"
|
|
#include "system.h"
|
|
#include "allocator.h"
|
|
|
|
namespace vm {
|
|
|
|
class Finder {
|
|
public:
|
|
class IteratorImp {
|
|
public:
|
|
virtual const char* next(unsigned* size) = 0;
|
|
virtual void dispose() = 0;
|
|
};
|
|
|
|
class Iterator {
|
|
public:
|
|
Iterator(Finder* finder):
|
|
it(finder->iterator()),
|
|
current(it->next(¤tSize))
|
|
{ }
|
|
|
|
~Iterator() {
|
|
it->dispose();
|
|
}
|
|
|
|
bool hasMore() {
|
|
if (current) return true;
|
|
current = it->next(¤tSize);
|
|
return current != 0;
|
|
}
|
|
|
|
const char* next(unsigned* size) {
|
|
if (hasMore()) {
|
|
*size = currentSize;
|
|
const char* v = current;
|
|
current = 0;
|
|
return v;
|
|
} else {
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
IteratorImp* it;
|
|
const char* current;
|
|
unsigned currentSize;
|
|
};
|
|
|
|
virtual IteratorImp* iterator() = 0;
|
|
virtual System::Region* find(const char* name) = 0;
|
|
virtual bool exists(const char* name) = 0;
|
|
virtual const char* path() = 0;
|
|
virtual void dispose() = 0;
|
|
};
|
|
|
|
Finder*
|
|
makeFinder(System* s, const char* path, const char* bootLibrary);
|
|
|
|
} // namespace vm
|
|
|
|
#endif//FINDER_H
|