// Load traits
use IteratorTrait;
- /**
- * Magic for this index
- */
- const INDEX_MAGIC = 'INDEXv0.1';
-
- /**
- * Separator group->hash
- */
- const SEPARATOR_GROUP_HASH = 0x01;
-
- /**
- * Separator hash->gap position
- */
- const SEPARATOR_HASH_GAP_POSITION = 0x02;
-
- /**
- * Separator gap position->length
- */
- const SEPARATOR_GAP_LENGTH = 0x03;
-
/**
* Minimum block length
*/
if (count($header) != 2) {
// Bad header
throw new UnexpectedValueException(sprintf('header()=%d is not expected value 2', count($header)));
- } elseif ($header[0] !== self::INDEX_MAGIC) {
+ } elseif ($header[0] !== Indexable::INDEX_MAGIC) {
// Magic must be in first element
- throw new UnexpectedValueException(sprintf('header[0]=%s is not the expected magic (%s)', $header[0], self::INDEX_MAGIC));
+ throw new UnexpectedValueException(sprintf('header[0]=%s is not the expected magic (%s)', $header[0], Indexable::INDEX_MAGIC));
} elseif (strlen($header[1]) != BaseBinaryFile::LENGTH_COUNT) {
// Length of total entries not matching
throw new UnexpectedValueException(sprintf('header[1](%d)=%s does not have expected length %d', strlen($header[1]), $header[1], BaseBinaryFile::LENGTH_COUNT));
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-INDEX: CALLED!');
$header = sprintf('%s%s%s%s',
// Magic
- self::INDEX_MAGIC,
+ Indexable::INDEX_MAGIC,
// Separator header data
chr(BaseBinaryFile::SEPARATOR_HEADER_DATA),
// Calculate header size
$this->getIteratorInstance()->setHeaderSize(
- strlen(self::INDEX_MAGIC) +
+ strlen(Indexable::INDEX_MAGIC) +
strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA)) +
BaseBinaryFile::LENGTH_COUNT +
strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES))
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,hash=%s,gap=%d,length=%d - CALLED!', $groupId, $data[StackableFile::ARRAY_NAME_HASH], $data[StackableFile::ARRAY_NAME_GAP_POSITION], $data[StackableFile::ARRAY_NAME_DATA_LENGTH]));
$rawData = sprintf('%s%s%s%s%s%s%s',
$groupId,
- self::SEPARATOR_GROUP_HASH,
+ Indexable::SEPARATOR_GROUP_HASH,
hex2bin($data[StackableFile::ARRAY_NAME_HASH]),
- self::SEPARATOR_HASH_GAP_POSITION,
+ Indexable::SEPARATOR_HASH_GAP_POSITION,
$data[StackableFile::ARRAY_NAME_GAP_POSITION],
- self::SEPARATOR_GAP_LENGTH,
+ Indexable::SEPARATOR_GAP_LENGTH,
$data[StackableFile::ARRAY_NAME_DATA_LENGTH]
);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface Indexable extends FrameworkInterface {
+ /**
+ * Magic for this index
+ */
+ const INDEX_MAGIC = 'INDEXv0.1';
+
+ /**
+ * Separator group->hash
+ */
+ const SEPARATOR_GROUP_HASH = 0x01;
+
+ /**
+ * Separator hash->gap position
+ */
+ const SEPARATOR_HASH_GAP_POSITION = 0x02;
+
+ /**
+ * Separator gap position->length
+ */
+ const SEPARATOR_GAP_LENGTH = 0x03;
}