chromium/chrome/services/cups_proxy/public/cpp/ipp_messages.h

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_SERVICES_CUPS_PROXY_PUBLIC_CPP_IPP_MESSAGES_H_
#define CHROME_SERVICES_CUPS_PROXY_PUBLIC_CPP_IPP_MESSAGES_H_

#include <cups/cups.h>
#include <stddef.h>

#include <string>
#include <vector>

#include "chrome/services/ipp_parser/public/cpp/ipp_converter.h"
#include "printing/backend/cups_ipp_helper.h"

// POD representations of HTTP/IPP objects.
namespace cups_proxy {

// Helpful wrapper for a HTTP Request request-line.
struct HttpRequestLine {
  std::string method;
  std::string endpoint;
  std::string http_version;
};

// POD representation of an IPP request and assorted metadata.
struct IppRequest {
  // Explicitly declared/defined defaults since [chromium-style] flagged this as
  // a complex struct.
  IppRequest();

  IppRequest(const IppRequest&) = delete;
  IppRequest& operator=(const IppRequest&) = delete;

  IppRequest(IppRequest&& other);

  ~IppRequest();

  // Implicitly deleted by DISALLOW, so adding back in.
  IppRequest& operator=(IppRequest&& other) = default;

  std::vector<uint8_t> buffer;

  HttpRequestLine request_line;
  std::vector<ipp_converter::HttpHeader> headers;
  printing::ScopedIppPtr ipp;
  std::vector<uint8_t> ipp_data;
};

// Helpful wrapper for a HTTP Response status-line.
struct HttpStatusLine {
  std::string http_version;
  std::string status_code;
  std::string reason_phrase;
};

// POD representation of an IPP response and assorted metadata.
struct IppResponse {
  // Explicitly declared/defined defaults since [chromium-style] flagged this as
  // a complex struct.
  IppResponse();

  IppResponse(const IppResponse&) = delete;
  IppResponse& operator=(const IppResponse&) = delete;

  IppResponse(IppResponse&& other);

  ~IppResponse();

  // Implicitly deleted by DISALLOW, so adding back in.
  IppResponse& operator=(IppResponse&& other) = default;

  std::vector<uint8_t> buffer;

  HttpStatusLine status_line;
  std::vector<ipp_converter::HttpHeader> headers;
  printing::ScopedIppPtr ipp;
  std::vector<uint8_t> ipp_data;
};

}  // namespace cups_proxy

#endif  // CHROME_SERVICES_CUPS_PROXY_PUBLIC_CPP_IPP_MESSAGES_H_