/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 2009 Oracle. All rights reserved.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using BerkeleyDB.Internal;
namespace BerkeleyDB {
///
/// A class to represent the database byte order.
///
public class ByteOrder {
private int _lorder;
internal int lorder { get { return _lorder; } }
///
/// The host byte order of the machine where the Berkeley DB library was
/// compiled.
///
public static ByteOrder MACHINE = new ByteOrder(0);
///
/// Little endian byte order
///
public static ByteOrder LITTLE_ENDIAN = new ByteOrder(1234);
///
/// Big endian byte order
///
public static ByteOrder BIG_ENDIAN = new ByteOrder(4321);
///
/// Convert from the integer constant used to represent byte order in
/// the C library to its corresponding ByteOrder object.
///
/// The C library constant
///
/// The ByteOrder object corresponding to the given constant
///
public static ByteOrder FromConst(int order) {
switch (order) {
case 0: return MACHINE;
case 1234: return LITTLE_ENDIAN;
case 4321: return BIG_ENDIAN;
}
throw new ArgumentException("Invalid byte order constant.");
}
private ByteOrder(int order) {
_lorder = order;
}
}
}