mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-30 05:29:47 +00:00
41bdcd4aed
* Update logging * Remove duplicate code * Update unit tests * Clean up includes * Merge ProtobufSerializer into protobuf_util namespace * Precompile regex * Add const * Add Split() convenience method, update log level/ID parsing * Move log.h to legacy folder * Elimininate gotos * Fixes for gcc 13 * Update compiler flags * Update default folder handling * Use references instead of pointers * Move code for better encapsulation * Move code * Remove unused method argument * Move device logger * Remove redundant to_string * Rename for consistency * Update handling of protobuf pointers * Simplify protobuf usage * Memory handling update * Add hasher
51 lines
1002 B
C++
51 lines
1002 B
C++
//---------------------------------------------------------------------------
|
|
//
|
|
// SCSI Target Emulator PiSCSI
|
|
// for Raspberry Pi
|
|
//
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
//
|
|
//---------------------------------------------------------------------------
|
|
|
|
#include "generated/piscsi_interface.pb.h"
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
using namespace std;
|
|
using namespace piscsi_interface;
|
|
|
|
class ScsictlParser
|
|
{
|
|
|
|
public:
|
|
|
|
ScsictlParser() = default;
|
|
~ScsictlParser() = default;
|
|
|
|
PbOperation ParseOperation(string_view) const;
|
|
PbDeviceType ParseType(const string&) const;
|
|
|
|
private:
|
|
|
|
const unordered_map<int, PbOperation> operations = {
|
|
{ 'a', ATTACH },
|
|
{ 'd', DETACH },
|
|
{ 'e', EJECT },
|
|
{ 'i', INSERT },
|
|
{ 'p', PROTECT },
|
|
{ 's', DEVICES_INFO },
|
|
{ 'u', UNPROTECT }
|
|
};
|
|
|
|
const unordered_map<int, PbDeviceType> device_types = {
|
|
{ 'b', SCBR },
|
|
{ 'c', SCCD },
|
|
{ 'd', SCDP },
|
|
{ 'h', SCHD },
|
|
{ 'l', SCLP },
|
|
{ 'm', SCMO },
|
|
{ 'r', SCRM },
|
|
{ 's', SCHS }
|
|
};
|
|
};
|