Fix some indenting

This commit is contained in:
Marc Burns 2011-11-11 00:49:18 -05:00
parent 2392c8a492
commit 94667335f5
2 changed files with 49 additions and 47 deletions

View File

@ -70,15 +70,15 @@ void PosDb::acceptLogEntry(const LogEntry & l) {
break;
}
case ET_PRICE: {
upc_to_price[l.PriceChange.upc] = l.PriceChange.price;
break;
}
case ET_PRICE: {
upc_to_price[l.PriceChange.upc] = l.PriceChange.price;
break;
}
case ET_ADDUPC: {
upc_to_name[l.AddUPC.upc] = l.AddUPC.name;
break;
}
case ET_ADDUPC: {
upc_to_name[l.AddUPC.upc] = l.AddUPC.name;
break;
}
case ET_REVERT: {
sto_it q = serial_to_object.find(l.Revert.revert_serial);
@ -151,7 +151,7 @@ uint64_t PosDb::associateHash(const SHA1Hash & hash, uint32_t account) {
if(getAccountFromHash(hash)) {
return 0;
} else {
LogEntry l = log.newLogEntry(ET_HASH);
LogEntry l = log.newLogEntry(ET_HASH);
l.HashChange.uid = account;
l.HashChange.add = true;
hash.get((unsigned char *)l.HashChange.hash);
@ -172,31 +172,31 @@ uint64_t PosDb::deassociateHash(const SHA1Hash & hash) {
if(!acct) {
return 0;
} else {
LogEntry l = log.newLogEntry(ET_HASH);
l.HashChange.uid = acct;
l.HashChange.add = false;
hash.get((unsigned char *)l.HashChange.hash);
LogEntry l = log.newLogEntry(ET_HASH);
l.HashChange.uid = acct;
l.HashChange.add = false;
hash.get((unsigned char *)l.HashChange.hash);
acceptLogEntry(l);
return log.writeEntry(l);
acceptLogEntry(l);
return log.writeEntry(l);
}
}
int32_t PosDb::getUPCPrice(UPC upc) {
uts_it it = upc_to_price.find(upc);
if (it == upc_to_price.end()) {
return 0;
}
return it->second;
uts_it it = upc_to_price.find(upc);
if (it == upc_to_price.end()) {
return 0;
}
return it->second;
}
uint64_t PosDb::setUPCPrice(UPC upc, int32_t price) {
LogEntry l = log.newLogEntry(ET_PRICE);
l.PriceChange.upc = upc;
l.PriceChange.price = price;
LogEntry l = log.newLogEntry(ET_PRICE);
l.PriceChange.upc = upc;
l.PriceChange.price = price;
acceptLogEntry(l);
return log.writeEntry(l);
acceptLogEntry(l);
return log.writeEntry(l);
}
// NOTE: this in theory could be deprecated. The client should
@ -208,7 +208,7 @@ uint64_t PosDb::doTransaction(const SHA1Hash & hash, int32_t delta) {
if(!acct) {
return 0;
} else {
LogEntry l = log.newLogEntry(ET_TRANS);
LogEntry l = log.newLogEntry(ET_TRANS);
l.Transaction.delta = delta;
l.Transaction.uid = acct;
@ -218,7 +218,7 @@ uint64_t PosDb::doTransaction(const SHA1Hash & hash, int32_t delta) {
}
uint64_t PosDb::doTransaction(const uint32_t account, int32_t delta) {
LogEntry l = log.newLogEntry(ET_TRANS);
LogEntry l = log.newLogEntry(ET_TRANS);
l.Transaction.delta = delta;
l.Transaction.uid = account;
@ -243,7 +243,7 @@ uint64_t PosDb::revertTransaction(uint64_t serial) {
if(p != serial_to_object.end())
return 0;
LogEntry l = log.newLogEntry(ET_REVERT);
LogEntry l = log.newLogEntry(ET_REVERT);
l.Revert.revert_serial = serial;
acceptLogEntry(l);
@ -260,7 +260,7 @@ int32_t PosDb::getStock(UPC upc) {
}
uint64_t PosDb::doStockChange(UPC upc, int32_t delta) {
LogEntry l = log.newLogEntry(ET_SALE);
LogEntry l = log.newLogEntry(ET_SALE);
l.StockChange.delta = delta;
l.StockChange.upc = upc;
@ -269,21 +269,23 @@ uint64_t PosDb::doStockChange(UPC upc, int32_t delta) {
}
std::string PosDb::getUPCName(UPC upc) {
std::map<UPC, std::string>::iterator it = upc_to_name.find(upc);
if(it == upc_to_name.end()) return "UNKNOWN UPC";
return upc_to_name[upc];
std::map<UPC, std::string>::iterator it = upc_to_name.find(upc);
if(it == upc_to_name.end()) return "UNKNOWN UPC";
return upc_to_name[upc];
}
uint64_t PosDb::setUPCName (UPC upc, std::string name) {
LogEntry l = log.newLogEntry(ET_ADDUPC);
l.AddUPC.upc = upc;
strncpy(l.AddUPC.name, name.c_str(), 32);
l.AddUPC.name[32] = 0;
LogEntry l = log.newLogEntry(ET_ADDUPC);
l.AddUPC.upc = upc;
strncpy(l.AddUPC.name, name.c_str(), 32);
l.AddUPC.name[32] = 0;
acceptLogEntry(l);
return log.writeEntry(l);
acceptLogEntry(l);
return log.writeEntry(l);
}
std::vector<std::string> PosDb::toString() {
return log.toString();
return log.toString();
}

View File

@ -27,16 +27,16 @@ public:
uint64_t doTransaction(std::string account, int32_t delta);
uint64_t revertTransaction(uint64_t serial);
int32_t getUPCPrice(UPC upc);
uint64_t setUPCPrice(UPC upc, int32_t price);
int32_t getUPCPrice(UPC upc);
uint64_t setUPCPrice(UPC upc, int32_t price);
int32_t getStock(UPC upc);
int32_t getStock(UPC upc);
uint64_t doStockChange(UPC upc, int32_t delta);
std::string getUPCName(UPC upc);
uint64_t setUPCName (UPC upc, std::string name);
std::string getUPCName(UPC upc);
uint64_t setUPCName (UPC upc, std::string name);
std::vector<std::string> toString();
std::vector<std::string> toString();
private:
void acceptLogEntry(const LogEntry & l);
@ -45,8 +45,8 @@ private:
std::map<uint32_t, int32_t> account_to_balance;
std::map<UPC, int32_t, UPCLess> upc_to_stock;
std::map<UPC, int32_t, UPCLess> upc_to_price;
std::map<UPC, std::string, UPCLess> upc_to_name;
std::map<UPC, int32_t, UPCLess> upc_to_price;
std::map<UPC, std::string, UPCLess> upc_to_name;
std::map<uint64_t, LogEntry> serial_to_object;