#ifndef BUILD_DEFAULTS_CLASS
#define BUILD_DEFAULTS_CLASS

/*****************************************************************************\
*                                                                             *
*  Name   : write_build_config                                                *
*  Author : Chris Koeritz                                                     *
*                                                                             *
*  Purpose:                                                                   *
*                                                                             *
*    This class creates a header file that will provide macros that govern    *
*  how the build is created under win32 using visual studio project files.    *
*  This file is not on other platforms, nor with the clam makefile system.    *
*                                                                             *
*******************************************************************************
* Copyright (c) 1995-$now By Author.  This program is free software; you can  *
* redistribute it and/or modify it under the terms of the GNU General Public  *
* License as published by the Free Software Foundation; either version 2 of   *
* the License or (at your option) any later version.  This is online at:      *
*     http://www.fsf.org/copyleft/gpl.html                                    *
* Please send any updates to: fred@gruntose.com                               *
\*****************************************************************************/

#include <basis/istring.h>
#include <opsystem/application_shell.h>

// forward.
class string_set;
class version;

class write_build_config : public application_shell
{
public:
  write_build_config();
  ~write_build_config();

  IMPLEMENT_CLASS_NAME("write_build_config");

  int execute();
    //!< performs the main action of creating our build configuration header.

  const string_set &exclusions();
    //!< returns the set of symbols that we will not include in the header.

  outcome output_macro(const istring &symbol, const istring &value,
          istring &accumulator);
    //!< sends a macro definition for "symbol" with "value" to "accumulator".

  outcome output_decorated_macro(const istring &symbol, const istring &value,
          istring &cfg_accumulator, istring &ver_accumulator);
    //!< produces a new macro by adding a uniquifying string to "symbol".
    /*!< if the item is a version component, it will be output to the
    "ver_accumulator" but otherwise it goes to the "cfg_accumulator". */

  outcome output_definition_macro(const istring &embedded_value,
          istring &accumulator);
    //!< parses a 'name=value' pair out of "embedded_value" and writes a macro.

  bool process_version_parts(const istring &symbol, const istring &value);
    //!< checks on "symbol" to see if it's a version component.  stores if so.
    /*!< if the string was a version component, then true is returned. */

  bool check_nesting(const istring &to_check);
    //!< if "to_check" is a make conditional, the nesting level is adjusted.
    /*!< also if it's a conditional, true is returned, which means the line
    can be dropped. */

  bool write_output_file(const istring &filename, const istring &contents);
    //!< writes "contents" to "filename" if it differs from current contents.

private:
  istring *_end_matter;  // stuff that isn't part of the real file.
  version *_ver;  // accumulated when we see the right parts.
  int _nesting;  // how many levels of conditionals do we see?

  // not provided.
  write_build_config(const write_build_config &);
  write_build_config &operator =(const write_build_config &);
};

#endif

