Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  MsiDatabase.h

  Sprache: C
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


#ifndef MsiDatabase_h_
#define MsiDatabase_h_

#include "mozilla/Maybe.h"
#include "mozilla/UniquePtr.h"
#include "nsWindowsHelpers.h"

#include <windows.h>
#include <msi.h>
#include <msiquery.h>

namespace mozilla {

class MsiDatabase final {
  static UniquePtr<wchar_t[]> GetRecordString(MSIHANDLE aRecord,
                                              UINT aFieldIndex);

  nsAutoMsiHandle mDatabase;

  MsiDatabase() = default;
  explicit MsiDatabase(const wchar_t* aDatabasePath);

 public:
  // A callback function passed to ExecuteSingleColumnQuery uses this type
  // to control the enumeration loop.
  enum class CallbackResult { Continue, Stop };

  static Maybe<MsiDatabase> FromProductId(const wchar_t* aProductId);

  MsiDatabase(const MsiDatabase&) = delete;
  MsiDatabase& operator=(const MsiDatabase&) = delete;
  MsiDatabase(MsiDatabase&& aOther) : mDatabase(aOther.mDatabase.disown()) {}
  MsiDatabase& operator=(MsiDatabase&& aOther) {
    if (this != &aOther) {
      mDatabase.own(aOther.mDatabase.disown());
    }
    return *this;
  }

  explicit operator bool() const;

  template <typename CallbackT>
  bool ExecuteSingleColumnQuery(const wchar_t* aQuery,
                                const CallbackT& aCallback) const {
    MSIHANDLE handle;
    UINT ret = ::MsiDatabaseOpenViewW(mDatabase, aQuery, &handle);
    if (ret != ERROR_SUCCESS) {
      return false;
    }

    nsAutoMsiHandle view(handle);

    ret = ::MsiViewExecute(view, 0);
    if (ret != ERROR_SUCCESS) {
      return false;
    }

    for (;;) {
      ret = ::MsiViewFetch(view, &handle);
      if (ret == ERROR_NO_MORE_ITEMS) {
        break;
      } else if (ret != ERROR_SUCCESS) {
        return false;
      }

      nsAutoMsiHandle record(handle);
      UniquePtr<wchar_t[]> guidStr = GetRecordString(record, 1);
      if (!guidStr) {
        continue;
      }

      CallbackResult result = aCallback(guidStr.get());
      if (result == CallbackResult::Continue) {
        continue;
      } else if (result == CallbackResult::Stop) {
        break;
      } else {
        MOZ_ASSERT_UNREACHABLE("Unexpected CallbackResult.");
      }
    }

    return true;
  }
};

}  // namespace mozilla

#endif  // MsiDatabase_h_

Messung V0.5 in Prozent
C=95 H=98 G=96

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002