VirtualBox

Changeset 57632 in vbox


Ignore:
Timestamp:
Sep 4, 2015 2:25:02 PM (9 years ago)
Author:
vboxsync
Message:

USBIdDatabaseGenerator: coding style

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/USBIdDatabaseGenerator.cpp

    r57625 r57632  
    1414#include <fstream>
    1515#include <iostream>
     16#include <iomanip>
    1617#include <algorithm>
    1718#include <vector>
     
    2324using namespace std;
    2425
    25 const char* header = "/*\n\
    26  * Copyright(C) 2005 - 2015 Oracle Corporation\n\
    27  *\n\
    28  * This file is part of VirtualBox Open Source Edition(OSE), as\n\
    29  * available from http ://www.virtualbox.org. This file is free software;\n\
    30  * you can redistribute it and / or modify it under the terms of the GNU\n\
    31  * General Public License(GPL) as published by the Free Software\n\
    32  * Foundation, in version 2 as it comes in the \"COPYING\" file of the\n\
    33  * VirtualBox OSE distribution.VirtualBox OSE is distributed in the\n\
    34  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.\n\
    35  *\n\
    36  */\
    37  \n\
    38  \n\
    39  #include \"USBIdDatabase.h\"\n\
    40  \n\
    41  /** USB devices aliases array.\n\
    42  *   Format: VendorId, ProductId, Vendor Name, Product Name\n\
    43  *   The source of the list is http://www.linux-usb.org/usb.ids\n\
    44  */\n\
    45  Product AliasDictionary::productArray[] = { \n";
    46 
    47 const char* footer = "};\n\
    48  \n\
    49  const size_t AliasDictionary::products_size = sizeof(AliasDictionary::productArray) / sizeof(Product); \n";
    50 
    51 const char* vendor_header = "\nVendor AliasDictionary::vendorArray[] = { \n";
    52 const char* vendor_footer = "};\n\
    53 \n\
    54 const size_t AliasDictionary::vendors_size = sizeof(AliasDictionary::vendorArray) / sizeof(Vendor);";
    55 
    56 const char* start_block = "# Vendors, devices and interfaces. Please keep sorted.";
    57 const char* end_block = "# List of known device classes, subclasses and protocols";
     26const char *header =
     27    "/*\n"
     28    " * Copyright(C) 2015 Oracle Corporation\n"
     29    " *\n"
     30    " * This file is part of VirtualBox Open Source Edition(OSE), as\n"
     31    " * available from http ://www.virtualbox.org. This file is free software;\n"
     32    " * you can redistribute it and / or modify it under the terms of the GNU\n"
     33    " * General Public License(GPL) as published by the Free Software\n"
     34    " * Foundation, in version 2 as it comes in the \"COPYING\" file of the\n"
     35    " * VirtualBox OSE distribution.VirtualBox OSE is distributed in the\n"
     36    " * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.\n"
     37    " */"
     38    "\n"
     39    "\n"
     40    "#include \"USBIdDatabase.h\"\n"
     41    "\n"
     42    "/**\n"
     43    " * USB devices aliases array.\n"
     44    " * Format: VendorId, ProductId, Vendor Name, Product Name\n"
     45    " * The source of the list is http://www.linux-usb.org/usb.ids\n"
     46    " */\n"
     47    "Product AliasDictionary::productArray[] =\n"
     48    "{\n";
     49
     50const char *footer =
     51    "};\n"
     52    "\n"
     53    "const size_t AliasDictionary::products_size = sizeof(AliasDictionary::productArray) / sizeof(Product);\n";
     54
     55const char *vendor_header =
     56    "\nVendor AliasDictionary::vendorArray[] =\n"
     57    "{\n";
     58const char *vendor_footer =
     59    "};\n"
     60    "\n"
     61    "const size_t AliasDictionary::vendors_size = sizeof(AliasDictionary::vendorArray) / sizeof(Vendor);\n";
     62
     63const char *start_block = "# Vendors, devices and interfaces. Please keep sorted.";
     64const char *end_block = "# List of known device classes, subclasses and protocols";
    5865
    5966#define USBKEY(vendorId, productId) (((vendorId) << 16) | (productId))
     
    116123ostream& operator <<(ostream& stream, const ProductRecord product)
    117124{
    118     stream << "{USBKEY(0x" << hex << product.vendorID
    119         << ", 0x" << product.productID << "), "
    120         << "\"" << conv(product.product).c_str() << "\" }," << endl;
     125    stream << "    { USBKEY(0x" << setfill('0') << setw(4) << hex << product.vendorID
     126           <<            ", 0x" << setfill('0') << setw(4) << product.productID << "), "
     127           << "\"" << conv(product.product).c_str() << "\" }," << endl;
    121128    return stream;
    122129}
     
    124131ostream& operator <<(ostream& stream, const VendorRecord vendor)
    125132{
    126     stream << "{0x" << hex << vendor.vendorID
    127         << ", \"" << conv(vendor.vendor).c_str() << "\" }," << endl;
     133    stream << "    { 0x" << setfill('0') << setw(4) << hex << vendor.vendorID
     134           << ", \"" << conv(vendor.vendor).c_str() << "\" }," << endl;
    128135    return stream;
    129136}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette