blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 5
146
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
7
| license_type
stringclasses 2
values | repo_name
stringlengths 6
79
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 4
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.07k
426M
⌀ | star_events_count
int64 0
27
| fork_events_count
int64 0
12
| gha_license_id
stringclasses 3
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 6
values | src_encoding
stringclasses 26
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 1
class | length_bytes
int64 20
6.28M
| extension
stringclasses 20
values | content
stringlengths 20
6.28M
| authors
listlengths 1
16
| author_lines
listlengths 1
16
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ccf107f4e49aea1092c1300c55f918383a6294c5 | fc4946d917dc2ea50798a03981b0274e403eb9b7 | /gentleman/gentleman/WindowsAPICodePack/WindowsAPICodePack/DirectX/DirectX/DirectWrite/DWriteStructs.h | 35200d318f5ef584e6962cb49d2b79f026da494d | []
| no_license | midnite8177/phever | f9a55a545322c9aff0c7d0c45be3d3ddd6088c97 | 45529e80ebf707e7299887165821ca360aa1907d | refs/heads/master | 2020-05-16T21:59:24.201346 | 2010-07-12T23:51:53 | 2010-07-12T23:51:53 | 34,965,829 | 3 | 2 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 36,954 | h | //Copyright (c) Microsoft Corporation. All rights reserved.
#pragma once
#include "DWriteEnums.h"
using namespace System::Runtime::InteropServices;
using namespace System::Runtime::CompilerServices;
namespace DWrite = Microsoft::WindowsAPICodePack::DirectX::DirectWrite;
namespace Microsoft { namespace WindowsAPICodePack { namespace DirectX { namespace DirectWrite {
/// <summary>
/// Line spacing parameters.
/// </summary>
/// <remarks>
/// For the default line spacing method, spacing depends solely on the content.
/// For uniform line spacing, the given line height will override the content.
/// </remarks>
public value struct LineSpacing
{
public:
/// <summary>
/// Constructor for LineSpacing
/// </summary>
/// <param name="lineSpacingMethod">Initializes the LineSpaceingMethod field.</param>
/// <param name="height">Initializes the Height field.</param>
/// <param name="baseline">Initializes the Baseline field.</param>
LineSpacing(
DWrite::LineSpacingMethod lineSpacingMethod,
Single height,
Single baseline
) : LineSpacingMethod(lineSpacingMethod), Height(height), Baseline(baseline)
{ }
/// <summary>
/// How line height is determined.
/// </summary>
DWrite::LineSpacingMethod LineSpacingMethod;
/// <summary>
/// The line height, or rather distance between one baseline to another.
/// </summary>
Single Height;
/// <summary>
/// Distance from top of line to baseline. A reasonable ratio to Height is 80%.
/// </summary>
Single Baseline;
};
/// <summary>
/// Specifies a range of text positions where format is applied.
/// </summary>
public value struct TextRange
{
public:
/// <summary>
/// Constructor for TextRange
/// </summary>
TextRange (
UINT32 startPosition,
UINT32 length
) : StartPosition(startPosition), Length(length)
{ }
/// <summary>
/// The start text position of the range.
/// </summary>
UINT32 StartPosition;
/// <summary>
/// The number of text positions in the range.
/// </summary>
UINT32 Length;
internal:
void CopyFrom(
const DWRITE_TEXT_RANGE & nativeStruct
)
{
StartPosition = nativeStruct.startPosition;
Length = nativeStruct.length;
}
void CopyTo(
DWRITE_TEXT_RANGE *pNativeStruct
)
{
pNativeStruct->startPosition = StartPosition;
pNativeStruct->length = Length;
}
};
/// <summary>
/// Geometry enclosing of text positions.
/// </summary>
public value struct HitTestMetrics
{
public:
/// <summary>
/// Constructor for HitTestMetrics
/// </summary>
HitTestMetrics(
UINT32 textPosition,
UINT32 length,
FLOAT left,
FLOAT top,
FLOAT width,
FLOAT height,
UINT32 bidiLevel,
Boolean isText,
Boolean isTrimmed
) :
TextPosition(textPosition),
Length(length),
Left(left),
Top(top),
Width(width),
Height(height),
BidiLevel(bidiLevel),
IsText(isText),
IsTrimmed(isTrimmed)
{ }
/// <summary>
/// First text position within the geometry.
/// </summary>
UINT32 TextPosition;
/// <summary>
/// Number of text positions within the geometry.
/// </summary>
UINT32 Length;
/// <summary>
/// Left position of the top-left coordinate of the geometry.
/// </summary>
FLOAT Left;
/// <summary>
/// Top position of the top-left coordinate of the geometry.
/// </summary>
FLOAT Top;
/// <summary>
/// Geometry's width.
/// </summary>
FLOAT Width;
/// <summary>
/// Geometry's height.
/// </summary>
FLOAT Height;
/// <summary>
/// Bidi level of text positions enclosed within the geometry.
/// </summary>
UINT32 BidiLevel;
/// <summary>
/// Geometry encloses text?
/// </summary>
Boolean IsText;
/// <summary>
/// Range is trimmed.
/// </summary>
Boolean IsTrimmed;
internal:
void CopyFrom(
const DWRITE_HIT_TEST_METRICS & nativeStruct
)
{
TextPosition = nativeStruct.textPosition;
Length = nativeStruct.length;
Left = nativeStruct.left;
Top = nativeStruct.top;
Width = nativeStruct.width;
Height = nativeStruct.height;
BidiLevel = nativeStruct.bidiLevel;
IsText = nativeStruct.isText != 0;
IsTrimmed = nativeStruct.isTrimmed != 0;
}
void CopyTo(
DWRITE_HIT_TEST_METRICS *pNativeStruct
)
{
pNativeStruct->textPosition = TextPosition;
pNativeStruct->length = Length;
pNativeStruct->left = Left;
pNativeStruct->top = Top;
pNativeStruct->width = Width;
pNativeStruct->height = Height;
pNativeStruct->bidiLevel = BidiLevel;
pNativeStruct->isText = IsText;
pNativeStruct->isTrimmed = IsTrimmed;
}
};
/// <summary>
/// Contains information about a formatted line of text.
/// </summary>
public value struct LineMetrics
{
public:
/// <summary>
/// Constructor for LineMetrics
/// </summary>
LineMetrics(
UINT32 length,
UINT32 trailingWhitespaceLength,
UINT32 newlineLength,
FLOAT height,
FLOAT baseline,
Boolean isTrimmed
) :
Length(length),
TrailingWhitespaceLength(trailingWhitespaceLength),
NewlineLength(newlineLength),
Height(height),
Baseline(baseline),
IsTrimmed(isTrimmed)
{ }
/// <summary>
/// The number of total text positions in the line.
/// This includes any trailing whitespace and newline characters.
/// </summary>
UINT32 Length;
/// <summary>
/// The number of whitespace positions at the end of the line. Newline
/// sequences are considered whitespace.
/// </summary>
UINT32 TrailingWhitespaceLength;
/// <summary>
/// The number of characters in the newline sequence at the end of the line.
/// If the count is zero, then the line was either wrapped or it is the
/// end of the text.
/// </summary>
UINT32 NewlineLength;
/// <summary>
/// Height of the line as measured from top to bottom.
/// </summary>
FLOAT Height;
/// <summary>
/// Distance from the top of the line to its baseline.
/// </summary>
FLOAT Baseline;
/// <summary>
/// The line is trimmed.
/// </summary>
Boolean IsTrimmed;
internal:
void CopyFrom(
const DWRITE_LINE_METRICS & nativeStruct
)
{
Length = nativeStruct.length;
TrailingWhitespaceLength = nativeStruct.trailingWhitespaceLength;
NewlineLength = nativeStruct.newlineLength;
Height = nativeStruct.height;
Baseline = nativeStruct.baseline;
IsTrimmed = nativeStruct.isTrimmed != 0;
}
void CopyTo(
DWRITE_LINE_METRICS *pNativeStruct
)
{
pNativeStruct->length = Length;
pNativeStruct->trailingWhitespaceLength = TrailingWhitespaceLength;
pNativeStruct->newlineLength = NewlineLength;
pNativeStruct->height = Height;
pNativeStruct->baseline = Baseline;
pNativeStruct->isTrimmed = IsTrimmed;
}
};
/// <summary>
/// Overall metrics associated with text after layout.
/// All coordinates are in device independent pixels (DIPs).
/// </summary>
public value struct TextMetrics
{
public:
/// <summary>
/// Constructor for TextMetrics
/// </summary>
TextMetrics(
FLOAT left,
FLOAT top,
FLOAT width,
FLOAT widthIncludingTrailingWhitespace,
FLOAT height,
FLOAT layoutWidth,
FLOAT layoutHeight,
UINT32 maxBidiReorderingDepth,
UINT32 lineCount)
:
Left(left),
Top(top),
Width(width),
WidthIncludingTrailingWhitespace(widthIncludingTrailingWhitespace),
Height(height),
LayoutWidth(layoutWidth),
LayoutHeight(layoutHeight),
MaxBidiReorderingDepth(maxBidiReorderingDepth),
LineCount(lineCount)
{ }
/// <summary>
/// Left-most point of formatted text relative to layout box
/// (excluding any glyph overhang).
/// </summary>
FLOAT Left;
/// <summary>
/// Top-most point of formatted text relative to layout box
/// (excluding any glyph overhang).
/// </summary>
FLOAT Top;
/// <summary>
/// The width of the formatted text ignoring trailing whitespace
/// at the end of each line.
/// </summary>
FLOAT Width;
/// <summary>
/// The width of the formatted text taking into account the
/// trailing whitespace at the end of each line.
/// </summary>
FLOAT WidthIncludingTrailingWhitespace;
/// <summary>
/// The height of the formatted text. The height of an empty string
/// is determined by the size of the default font's line height.
/// </summary>
FLOAT Height;
/// <summary>
/// Initial width given to the layout. Depending on whether the text
/// was wrapped or not, it can be either larger or smaller than the
/// text content width.
/// </summary>
FLOAT LayoutWidth;
/// <summary>
/// Initial height given to the layout. Depending on the length of the
/// text, it may be larger or smaller than the text content height.
/// </summary>
FLOAT LayoutHeight;
/// <summary>
/// The maximum reordering count of any line of text, used
/// to calculate the most number of hit-testing boxes needed.
/// If the layout has no bidirectional text or no text at all,
/// the minimum level is 1.
/// </summary>
UINT32 MaxBidiReorderingDepth;
/// <summary>
/// Total number of lines.
/// </summary>
UINT32 LineCount;
internal:
void CopyFrom(
const DWRITE_TEXT_METRICS & nativeStruct
)
{
Left = nativeStruct.left;
Top = nativeStruct.top;
Width = nativeStruct.width;
WidthIncludingTrailingWhitespace = nativeStruct.widthIncludingTrailingWhitespace;
Height = nativeStruct.height;
LayoutWidth = nativeStruct.layoutWidth;
LayoutHeight = nativeStruct.layoutHeight;
MaxBidiReorderingDepth = nativeStruct.maxBidiReorderingDepth;
LineCount = nativeStruct.lineCount;
}
void CopyTo(
DWRITE_TEXT_METRICS *pNativeStruct
)
{
pNativeStruct->left = Left ;
pNativeStruct->top = Top;
pNativeStruct->width = Width;
pNativeStruct->widthIncludingTrailingWhitespace = WidthIncludingTrailingWhitespace;
pNativeStruct->height = Height;
pNativeStruct->layoutWidth = LayoutWidth;
pNativeStruct->layoutHeight = LayoutHeight;
pNativeStruct->maxBidiReorderingDepth = MaxBidiReorderingDepth;
pNativeStruct->lineCount = LineCount;
}
};
/// <summary>
/// Holds information about how much any visible pixels
/// (in DIPs) overshoot each side of the layout or inline objects.
/// </summary>
/// <remarks>
/// Positive overhangs indicate that the visible area extends outside the layout
/// box or inline object, while negative values mean there is whitespace inside.
/// The returned values are unaffected by rendering transforms or pixel snapping.
/// Additionally, they may not exactly match final target's pixel bounds after
/// applying grid fitting and hinting.
/// </remarks>
[StructLayout(LayoutKind::Sequential)]
public value struct OverhangMetrics
{
public:
/// <summary>
/// Constructor for OverhangMetrics
/// </summary>
OverhangMetrics (
FLOAT left,
FLOAT top,
FLOAT right,
FLOAT bottom )
:
Left(left),
Top(top),
Right(right),
Bottom(bottom)
{ }
/// <summary>
/// The distance from the left-most visible DIP to its left alignment edge.
/// </summary>
FLOAT Left;
/// <summary>
/// The distance from the top-most visible DIP to its top alignment edge.
/// </summary>
FLOAT Top;
/// <summary>
/// The distance from the right-most visible DIP to its right alignment edge.
/// </summary>
FLOAT Right;
/// <summary>
/// The distance from the bottom-most visible DIP to its bottom alignment edge.
/// </summary>
FLOAT Bottom;
internal:
void CopyFrom(
const DWRITE_OVERHANG_METRICS & nativeStruct
)
{
Left = nativeStruct.left;
Top = nativeStruct.top;
Right = nativeStruct.right;
Bottom = nativeStruct.bottom;
}
void CopyTo(
DWRITE_OVERHANG_METRICS *pNativeStruct
)
{
pNativeStruct->left = Left ;
pNativeStruct->top = Top;
pNativeStruct->right = Right;
pNativeStruct->bottom = Bottom;
}
};
/// <summary>
/// Contains information about a glyph cluster.
/// </summary>
public value struct ClusterMetrics
{
public:
/// <summary>
/// Constructor for ClusterMetrics
/// </summary>
ClusterMetrics (
FLOAT width,
UINT16 length,
Boolean canWrapLineAfter,
Boolean isWhitespace,
Boolean isNewline,
Boolean isSoftHyphen,
Boolean isRightToLeft)
:
Width(width),
Length(length),
CanWrapLineAfter(canWrapLineAfter),
IsWhitespace(isWhitespace),
IsNewline(isNewline),
IsSoftHyphen(isSoftHyphen),
IsRightToLeft(isRightToLeft)
{ }
/// <summary>
/// The total advance width of all glyphs in the cluster.
/// </summary>
FLOAT Width;
/// <summary>
/// The number of text positions in the cluster.
/// </summary>
UINT16 Length;
/// <summary>
/// Indicate whether line can be broken right after the cluster.
/// </summary>
Boolean CanWrapLineAfter;
/// <summary>
/// Indicate whether the cluster corresponds to whitespace character.
/// </summary>
Boolean IsWhitespace;
/// <summary>
/// Indicate whether the cluster corresponds to a newline character.
/// </summary>
Boolean IsNewline;
/// <summary>
/// Indicate whether the cluster corresponds to soft hyphen character.
/// </summary>
Boolean IsSoftHyphen;
/// <summary>
/// Indicate whether the cluster is read from right to left.
/// </summary>
Boolean IsRightToLeft;
internal:
void CopyFrom(
const DWRITE_CLUSTER_METRICS & nativeStruct
)
{
Width = nativeStruct.width;
Length = nativeStruct.length;
CanWrapLineAfter = nativeStruct.canWrapLineAfter != 0;
IsWhitespace = nativeStruct.isWhitespace != 0;
IsNewline = nativeStruct.isNewline != 0;
IsSoftHyphen = nativeStruct.isSoftHyphen != 0;
IsRightToLeft = nativeStruct.isRightToLeft != 0;
}
void CopyTo(
DWRITE_CLUSTER_METRICS *pNativeStruct
)
{
pNativeStruct->width = Width;
pNativeStruct->length = Length;
pNativeStruct->canWrapLineAfter = CanWrapLineAfter ? 1 : 0;
pNativeStruct->isWhitespace = IsWhitespace ? 1 : 0;
pNativeStruct->isNewline = IsNewline ? 1 : 0;
pNativeStruct->isSoftHyphen = IsSoftHyphen ? 1 : 0;
pNativeStruct->isRightToLeft = IsRightToLeft ? 1 : 0;
}
};
/// <summary>
/// Specifies the trimming option for text overflowing the layout box.
/// </summary>
public value struct Trimming
{
public:
/// <summary>
/// Constructor for Trimming
/// </summary>
Trimming (
TrimmingGranularity granularity,
UINT32 delimiter,
UINT32 delimiterCount)
:
Granularity(granularity),
Delimiter(delimiter),
DelimiterCount(delimiterCount)
{ }
/// <summary>
/// Text granularity of which trimming applies.
/// </summary>
TrimmingGranularity Granularity;
/// <summary>
/// Character code used as the delimiter signaling the beginning of the portion of text to be preserved,
/// most useful for path ellipsis, where the delimeter would be a slash.
/// </summary>
UINT32 Delimiter;
/// <summary>
/// How many occurences of the delimiter to step back.
/// </summary>
UINT32 DelimiterCount;
internal:
void CopyFrom(
const DWRITE_TRIMMING & nativeStruct
)
{
Granularity = static_cast<TrimmingGranularity>(nativeStruct.granularity);
Delimiter = nativeStruct.delimiter;
DelimiterCount = nativeStruct.delimiterCount;
}
void CopyTo(
DWRITE_TRIMMING *pNativeStruct
)
{
pNativeStruct->granularity = static_cast<DWRITE_TRIMMING_GRANULARITY>(Granularity);
pNativeStruct->delimiter = Delimiter;
pNativeStruct->delimiterCount = DelimiterCount;
}
};
/// <summary>
/// Specifies the metrics of a font face that are applicable to all glyphs within the font face.
/// </summary>
public value struct FontMetrics
{
public:
/// <summary>
/// Constructor for FontMetrics
/// </summary>
FontMetrics (
UINT16 designUnitsPerEm,
UINT16 ascent,
UINT16 descent,
INT16 lineGap,
UINT16 capHeight,
UINT16 xHeight,
INT16 underlinePosition,
UINT16 underlineThickness,
INT16 strikethroughPosition,
UINT16 strikethroughThickness
)
:
DesignUnitsPerEm(designUnitsPerEm),
Ascent(ascent),
Descent(descent),
LineGap(lineGap),
CapHeight(capHeight),
XHeight(xHeight),
UnderlinePosition(underlinePosition),
UnderlineThickness(underlineThickness),
StrikethroughPosition(strikethroughPosition),
StrikethroughThickness(strikethroughThickness)
{ }
internal:
/// <summary>
/// Internal Constructor for FontMetrics
/// </summary>
FontMetrics (const DWRITE_FONT_METRICS & native)
:
DesignUnitsPerEm(native.designUnitsPerEm),
Ascent(native.ascent),
Descent(native.descent),
LineGap(native.lineGap),
CapHeight(native.capHeight),
XHeight(native.xHeight),
UnderlinePosition(native.underlinePosition),
UnderlineThickness(native.underlineThickness),
StrikethroughPosition(native.strikethroughPosition),
StrikethroughThickness(native.strikethroughThickness)
{ }
public:
/// <summary>
/// The number of font design units per em unit.
/// Font files use their own coordinate system of font design units.
/// A font design unit is the smallest measurable unit in the em square,
/// an imaginary square that is used to size and align glyphs.
/// The concept of em square is used as a reference scale factor when defining font size and device transformation semantics.
/// The size of one em square is also commonly used to compute the paragraph identation value.
/// </summary>
UINT16 DesignUnitsPerEm;
/// <summary>
/// Ascent value of the font face in font design units.
/// Ascent is the distance from the top of font character alignment box to English baseline.
/// </summary>
UINT16 Ascent;
/// <summary>
/// Descent value of the font face in font design units.
/// Descent is the distance from the bottom of font character alignment box to English baseline.
/// </summary>
UINT16 Descent;
/// <summary>
/// Line gap in font design units.
/// Recommended additional white space to add between lines to improve legibility. The recommended line spacing
/// (baseline-to-baseline distance) is thus the sum of ascent, descent, and lineGap. The line gap is usually
/// positive or zero but can be negative, in which case the recommended line spacing is less than the height
/// of the character alignment box.
/// </summary>
INT16 LineGap;
/// <summary>
/// Cap height value of the font face in font design units.
/// Cap height is the distance from English baseline to the top of a typical English capital.
/// Capital "H" is often used as a reference character for the purpose of calculating the cap height value.
/// </summary>
UINT16 CapHeight;
/// <summary>
/// x-height value of the font face in font design units.
/// x-height is the distance from English baseline to the top of lowercase letter "x", or a similar lowercase character.
/// </summary>
UINT16 XHeight;
/// <summary>
/// The underline position value of the font face in font design units.
/// Underline position is the position of underline relative to the English baseline.
/// The value is usually made negative in order to place the underline below the baseline.
/// </summary>
INT16 UnderlinePosition;
/// <summary>
/// The suggested underline thickness value of the font face in font design units.
/// </summary>
UINT16 UnderlineThickness;
/// <summary>
/// The strikethrough position value of the font face in font design units.
/// Strikethrough position is the position of strikethrough relative to the English baseline.
/// The value is usually made positive in order to place the strikethrough above the baseline.
/// </summary>
INT16 StrikethroughPosition;
/// <summary>
/// The suggested strikethrough thickness value of the font face in font design units.
/// </summary>
UINT16 StrikethroughThickness;
internal:
void CopyFrom(const DWRITE_FONT_METRICS & native)
{
DesignUnitsPerEm = native.designUnitsPerEm;
Ascent = native.ascent;
Descent = native.descent;
LineGap = native.lineGap;
CapHeight = native.capHeight;
XHeight = native.xHeight;
UnderlinePosition = native.underlinePosition;
UnderlineThickness = native.underlineThickness;
StrikethroughPosition = native.strikethroughPosition;
StrikethroughThickness = native.strikethroughThickness;
}
void CopyTo(DWRITE_FONT_METRICS *pNativeStruct)
{
pNativeStruct->designUnitsPerEm = DesignUnitsPerEm;
pNativeStruct->ascent = Ascent;
pNativeStruct->descent = Descent;
pNativeStruct->lineGap = LineGap;
pNativeStruct->capHeight = CapHeight;
pNativeStruct->xHeight = XHeight;
pNativeStruct->underlinePosition = UnderlinePosition;
pNativeStruct->underlineThickness = UnderlineThickness;
pNativeStruct->strikethroughPosition = StrikethroughPosition;
pNativeStruct->strikethroughThickness = StrikethroughThickness;
}
};
/// <summary>
/// Properties describing the geometric measurement of an
/// application-defined inline object.
/// </summary>
public value struct InlineObjectMetrics
{
/// <summary>
/// Constructor for InlineObjectMetrics
/// </summary>
InlineObjectMetrics (
Single width,
Single height,
Single baseline,
Boolean supportsSideways
)
:
Width(width),
Height(height),
Baseline(baseline),
SupportsSideways(supportsSideways)
{ }
/// <summary>
/// Width of the inline object.
/// </summary>
Single Width;
/// <summary>
/// Height of the inline object as measured from top to bottom.
/// </summary>
Single Height;
/// <summary>
/// Distance from the top of the object to the baseline where it is lined up with the adjacent text.
/// If the baseline is at the bottom, baseline simply equals height.
/// </summary>
Single Baseline;
/// <summary>
/// Flag indicating whether the object is to be placed upright or alongside the text baseline
/// for vertical text.
/// </summary>
Boolean SupportsSideways;
internal:
void CopyTo(DWRITE_INLINE_OBJECT_METRICS *pNativeStruct)
{
pNativeStruct->width = Width;
pNativeStruct->height = Height;
pNativeStruct->baseline = Baseline;
pNativeStruct->supportsSideways = SupportsSideways ? 1 : 0;
}
};
/// <summary>
/// The FontFeature structure specifies properties used to identify and execute typographic feature in the font.
/// </summary>
/// <remarks>
/// <para>A non-zero value generally enables the feature execution, while the zero value disables it.
/// A feature requiring a selector uses this value to indicate the selector index.</para>
/// <para>The OpenType standard provides access to typographic features available in the font by means
/// of a feature tag with the associated parameters. The OpenType feature tag is a 4-byte identifier of
/// the registered name of a feature. For example, the ‘kern’ feature name tag is used to identify
/// the ‘Kerning’ feature in OpenType font. Similarly, the OpenType feature tag for ‘Standard Ligatures’ and
/// ‘Fractions’ is ‘liga’ and ‘frac’ respectively. Since a single run can be associated with more than one
/// typographic features, the Text String API accepts typographic settings for a run as a list of features
/// and are executed in the order they are specified.</para>
/// <para>The value of the Tag member represents the OpenType name tag of the feature, while the param value
/// represents additional parameter for the execution of the feature referred by the tag member.
/// Both nameTag and param are stored as little endian, the same convention followed by GDI.
/// Most features treat the Param value as a binary value that indicates whether to turn the
/// execution of the feature on or off, with it being off by default in the majority of cases.
/// Some features, however, treat this value as an integral value representing the integer index to
/// the list of alternate results it may produce during the execution; for instance, the feature
/// ‘Stylistic Alternates’ or ‘salt’ uses the param value as an index to the list of alternate substituting
/// glyphs it could produce for a specified glyph. </para>
/// </remarks>
public value struct FontFeature
{
public:
/// <summary>
/// Constructor for FontFeature
/// </summary>
FontFeature (
FontFeatureTag nameTag,
UINT32 parameter
)
:
NameTag(nameTag),
Parameter(parameter)
{ }
/// <summary>
/// The feature OpenType name identifier.
/// </summary>
FontFeatureTag NameTag;
/// <summary>
/// Execution parameter of the feature.
/// </summary>
/// <remarks>
/// The parameter should be non-zero to enable the feature. Once enabled, a feature can't be disabled again within
/// the same range. Features requiring a selector use this value to indicate the selector index.
/// </remarks>
UINT32 Parameter;
internal:
void CopyFrom(const DWRITE_FONT_FEATURE & native)
{
NameTag = static_cast<FontFeatureTag>(native.nameTag);
Parameter = native.parameter;
}
void CopyTo(DWRITE_FONT_FEATURE *pNativeStruct)
{
pNativeStruct->nameTag = static_cast<DWRITE_FONT_FEATURE_TAG>(NameTag);
pNativeStruct->parameter = Parameter;
}
};
/// <summary>
/// The GlyphMetrics structure specifies the metrics of an individual glyph.
/// The units depend on how the metrics are obtained.
/// </summary>
public value struct GlyphMetrics
{
/// <summary>
/// Specifies the X offset from the glyph origin to the left edge of the black box.
/// The glyph origin is the current horizontal writing position.
/// A negative value means the black box extends to the left of the origin (often true for lowercase italic 'f').
/// </summary>
INT32 LeftSideBearing;
/// <summary>
/// Specifies the X offset from the origin of the current glyph to the origin of the next glyph when writing horizontally.
/// </summary>
UINT32 AdvanceWidth;
/// <summary>
/// Specifies the X offset from the right edge of the black box to the origin of the next glyph when writing horizontally.
/// The value is negative when the right edge of the black box overhangs the layout box.
/// </summary>
INT32 RightSideBearing;
/// <summary>
/// Specifies the vertical offset from the vertical origin to the top of the black box.
/// Thus, a positive value adds whitespace whereas a negative value means the glyph overhangs the top of the layout box.
/// </summary>
INT32 TopSideBearing;
/// <summary>
/// Specifies the Y offset from the vertical origin of the current glyph to the vertical origin of the next glyph when writing vertically.
/// (Note that the term "origin" by itself denotes the horizontal origin. The vertical origin is different.
/// Its Y coordinate is specified by verticalOriginY value,
/// and its X coordinate is half the advanceWidth to the right of the horizontal origin).
/// </summary>
UINT32 AdvanceHeight;
/// <summary>
/// Specifies the vertical distance from the black box's bottom edge to the advance height.
/// Positive when the bottom edge of the black box is within the layout box.
/// Negative when the bottom edge of black box overhangs the layout box.
/// </summary>
INT32 BottomSideBearing;
/// <summary>
/// Specifies the Y coordinate of a glyph's vertical origin, in the font's design coordinate system.
/// The y coordinate of a glyph's vertical origin is the sum of the glyph's top side bearing
/// and the top (i.e. yMax) of the glyph's bounding box.
/// </summary>
INT32 VerticalOriginY;
};
/// <summary>
/// Optional adjustment to a glyph's position. An glyph offset changes the position of a glyph without affecting
/// the pen position. Offsets are in logical, pre-transform units.
/// </summary>
public value struct GlyphOffset
{
/// <summary>
/// Constructor for FontFeature
/// </summary>
GlyphOffset (
FLOAT advanceOffset,
FLOAT ascenderOffset
)
:
AdvanceOffset(advanceOffset),
AscenderOffset(ascenderOffset)
{ }
/// <summary>
/// Offset in the advance direction of the run. A positive advance offset moves the glyph to the right
/// (in pre-transform coordinates) if the run is left-to-right or to the left if the run is right-to-left.
/// </summary>
FLOAT AdvanceOffset;
/// <summary>
/// Offset in the ascent direction, i.e., the direction ascenders point. A positive ascender offset moves
/// the glyph up (in pre-transform coordinates).
/// </summary>
FLOAT AscenderOffset;
};
ref class FontFace;
/// <summary>
/// Contains the information needed by renderers to draw glyph runs.
/// All coordinates are in device independent pixels (DIPs).
/// </summary>
public value struct GlyphRun
{
public:
/// <summary>
/// The physical font face to draw with.
/// </summary>
DWrite::FontFace^ FontFace;
/// <summary>
/// Logical size of the font in DIPs, not points (equals 1/96 inch).
/// </summary>
FLOAT FontEmSize;
/// <summary>
/// The indices to render.
/// </summary>
array<UINT16>^ GlyphIndices;
/// <summary>
/// Glyph advance widths.
/// </summary>
array<FLOAT>^ GlyphAdvances;
/// <summary>
/// Glyph offsets.
/// </summary>
array<GlyphOffset>^ GlyphOffsets;
/// <summary>
/// If true, specifies that glyphs are rotated 90 degrees to the left and
/// vertical metrics are used. Vertical writing is achieved by specifying
/// isSideways = true and rotating the entire run 90 degrees to the right
/// via a rotate transform.
/// </summary>
Boolean IsSideways;
/// <summary>
/// The implicit resolved bidi level of the run. Odd levels indicate
/// right-to-left languages like Hebrew and Arabic, while even levels
/// indicate left-to-right languages like English and Japanese (when
/// written horizontally). For right-to-left languages, the text origin
/// is on the right, and text should be drawn to the left.
/// </summary>
UInt32 BidiLevel;
internal:
void CopyTo(DWRITE_GLYPH_RUN *pNativeStruct);
};
} } } } | [
"lucemia@9e708c16-f4dd-11de-aa3c-59de0406b4f5"
]
| [
[
[
1,
1041
]
]
]
|
8d1e158a57dec60f12a72fa7269f806e1b894b83 | cb480b1c0fbf026576305311c8af98237161d49c | /trunk/src/core/data/playback-settings.h | 98be035fa3d356eed98f3e90027b1399004aee23 | [
"MIT"
]
| permissive | BackupTheBerlios/winamp-alarm-svn | 770a832880b0e65ff94fd468f5a983df9c1c78fe | fb10dd4adc643abc0509bd3d355ae31ad0ae9e43 | refs/heads/master | 2021-01-01T17:22:19.131562 | 2005-02-20T20:06:01 | 2005-02-20T20:06:01 | 40,773,150 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,425 | h | /*
Copyright (c) 2004 Harri Salokorpi <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject
to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef PLAYSETTINGS_H
#define PLAYSETTINGS_H
#include <string.h>
// Using standard library namespace (for strings)
using namespace std;
//! This class contains playback settings
class PlaybackSettings
{
public:
//! Returns default alarm volume (in percents)
int GetVolume();
//! Returns the fade time (in seconds)
int GetFadeTime();
//! Returns the state of the repeat flag.
/*!
* If true, repeat is on.
*/
bool IsRepeatOn();
//! Returns the state of the shuffle flag
/*!
If true, shuffle is on.
*/
bool IsShuffleOn();
//! Returns the snooze time in seconds
int GetSnoozeTime();
//! Returns the state of the snooze flag.
/*!
If true, snoozing is on.
*/
bool IsSnoozeOn();
//! Returns the state of the fade flag.
/*!
If true, music is faded in.
*/
bool IsFadeOn();
//! Enables or disables repeat
void SetIsRepeatOn( bool isRepeatOn_ );
//! Enables or disables shuffle
void SetIsShuffleOn( bool isShuffleOn_ );
//! Enables or disables snoozing
void SetIsSnoozeOn(bool snooze);
//! Sets the snooze time in seconds
void SetSnoozeTime( int snoozeSeconds_ );
//! Sets alarm volume
void SetVolume(int level);
//! Enables or disables fade
/*
Fade is done from 0% -> volume%
*/
void SetIsFadeOn(bool fadeInOn);
//! Sets fade time in seconds
void SetFadeTime( int fadeInTime );
//! Returns playlist filename
string& GetPlaylistFilename();
//! Sets playlist filename
void SetPlaylistFilename( string& playlistFilename_ );
//! Constructor
PlaybackSettings();
//! Destructor
virtual ~PlaybackSettings();
private:
//! This flag determines if shuffle is used in playback
bool _isShuffleOn;
//! This flag determines if repeat is used in playback
bool _isRepeatOn;
//! This flag determines if 24h time format should be used
bool _isTimeformat24h;
//! This field specifies the snooze time in seconds
int _snoozeTime;
//! This flag determines if snoozing is on
bool _isSnoozeOn;
//! This flag determines if fade is on
bool _isFadeOn;
//! This field specifies the fade time in seconds
int _fadeTime;
//! This field contains the playlist filename
string _playlistFileName;
};
#endif PLAYSETTINGS_H
| [
"gillet@03ee7669-e0e8-0310-81e0-e03ded02296e"
]
| [
[
[
1,
133
]
]
]
|
537ca64e96efd6e88e9b25862222cb66ac9203f0 | cb4e269b5e2e963f84ef7c2e9fb5e2ba0352e4ea | /src/graphics/graphics_zbuffer.h | d1f00d6b5c30de55692b659347ded27dc8ab4d79 | []
| no_license | dasch/graphics | e0ce22bf0cf205989127cd9be9c3036502d66be2 | ef5b90225623058de15c5332608cf0f41d0110e6 | refs/heads/master | 2020-05-19T19:22:55.136427 | 2010-04-05T19:33:01 | 2010-04-05T19:33:01 | 567,095 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,202 | h | #ifndef GRAPHICS_ZBUFFER_H
#define GRAPHICS_ZBUFFER_H
//
// Graphics Framework.
// Copyright (C) 2007 Department of Computer Science, University of Copenhagen
//
// Overhauled by kaiip dec 17, 2009.
//
#include <iostream>
#include <iomanip>
#include <stdexcept>
#include <vector>
#include <algorithm>
#include "graphics_state.h"
namespace graphics
{
/**
* A Z-Buffer.
* A z-buffer is basically a 2D array of z-values.
* Each row of the 2D array has ``width'' values and each column has ''height'' values.
* Notice that the (0,0) entry of the array corresponds to the lower-left corner
* on the ``screen'' (width-1,height-1) location corresponds to the upper right corner.
*/
template< typename math_types >
class ZBuffer
{
public:
/**
* The basic type which is the the type of the elements of vectors and matrices.
*/
typedef typename math_types::real_type real_type;
/**
* A vector with 3 entries both of type real_type.
*/
typedef typename math_types::vector3_type vector3_type;
protected:
std::vector<float> m_values; ///< The Z-values. A row format is adopted.
int m_width; ///< The number of pixels in a row.
int m_height; ///< The number of pixels in a column.
public:
/**
* Clear Z Buffer.
* This method should be used to setup the z-buffer before
* doing any kind of drawing.
*
* @param clear_value The value to be used to clear the buffer. Must be in the interval [0..1] otherwise an exception is thrown.
*
*/
void clear(real_type const& clear_value)
{
#ifdef KENNY_ZBUFFER
// Original Kenny
if (clear_value < 0 || clear_value > 1) {
throw std::invalid_argument("graphics_zbuffer::clear(real_type&): clear value must be in [0..1]");
}
std::fill(m_values.begin(), m_values.end(), clear_value);
#else
// Changed by kaiip 06.12.2008 - 01:44
if (clear_value > 0 || clear_value < -1) {
throw std::invalid_argument("graphics_zbuffer::clear(real_type&): clear value must be in [-1..0]");
}
std::fill(m_values.begin(), m_values.end(), clear_value);
#endif
}
/**
* Set Resolution.
*
* @param width The number of pixels in a row. Must be larger than 1 otherwise an exception is thrown.
* @param height The number of pixels in a colum. Must be larger than 1 otherwise an exception is thrown.
*/
void set_resolution(int width, int height)
{
if (width <= 1)
throw std::invalid_argument("graphics_zbuffer::set_resolution: width must be larger than 1");
if (height <= 1)
throw std::invalid_argument("graphics_zbuffer::set_resolution: height must be larger than 1");
m_values.resize(width*height);
m_width = width;
m_height = height;
}
/**
* Write Z-value.
*
* @param x The current x location of the pixel. Must be within [0..width-1] otherwise an exception is thrown.
* @param y The current y location of the pixel. Must be within [0..height-1] otherwise an exception is thrown.
* @param value The z-value to be written. Must be in the interval [0..1] otherwise an exception is thrown.
*
*/
void write(int x, int y, real_type const& z_value)
{
//--- Test to see if we actually got a real depth value
#ifdef KENNY_ZBUFFER
if (z_value < 0 || z_value > 1)
throw std::invalid_argument("graphics_zbuffer::write: depth must be within [0...1]");
#else
if (z_value > 0 || z_value < -1)
throw std::invalid_argument("graphics_zbuffer::write: depth must be within [-1...0]");
#endif
//--- Simple minded clipping against framebuffer
if (x < 0)
return;
if (y < 0)
return;
if (x >= m_width)
return;
if(y >= m_height)
return;
//--- Determine memory location of the pixel that should be written
int offset = (y * m_width + x);
//--- Wtite the pixel to the frame buffer
m_values[offset] = z_value;
}
/**
* Read Z-value.
*
* @param x The current x location of the pixel. Must be within [0..width-1] otherwise an exception is thrown.
* @param y The current y location of the pixel. Must be within [0..height-1] otherwise an exception is thrown.
*
*/
real_type const& read(int x, int y) const
{
static real_type const off_screen = 0.0;
//--- Simple minded clipping against framebuffer
if (x < 0)
return off_screen;
if (y < 0)
return off_screen;
if (x >= m_width)
return off_screen;
if (y >= m_height)
return off_screen;
//--- Determine memory location of the z-value
int offset = (y * m_width + x);
return m_values[offset];
}
};
}// end namespace graphics
// GRAPHICS_ZBUFFER_H
#endif
| [
"[email protected]"
]
| [
[
[
1,
161
]
]
]
|
e70680fb3c4862e1ad2c2ce89b5be7498e5dc483 | 8d1d891c3a1f9b4c09d6edf8cad30fcf03a214ed | /source/math/Function.cpp | 37d47b3076755f568d66df036233c7338b383f5e | []
| no_license | mightymouse2016/shootmii | 7a53a70d027ec8bc8e957c7113144de57ecfa1a5 | 6a44637da4db44ba05d5d14c9a742f5d053041fa | refs/heads/master | 2021-01-10T06:36:38.009975 | 2010-07-20T19:43:23 | 2010-07-20T19:43:23 | 54,534,472 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 84 | cpp | #include "Function.h"
namespace shootmii {
Function::Function()
{
}
}
| [
"Altarfinch@c8eafc54-4d23-11de-9e51-a92ed582648b",
"altarfinch@c8eafc54-4d23-11de-9e51-a92ed582648b"
]
| [
[
[
1,
1
],
[
5,
5
]
],
[
[
2,
4
],
[
6,
10
]
]
]
|
99144cbb0c443a5e0be3c5623a27e7abf891bf2e | 1f0fa663a76a7c976197ec711bede79e7daebadd | /src/stringmap/split_l.cpp | 3688e85d7ca1ccb3041ccfd1c580af41ff68ca0d | []
| no_license | mahmoudimus/flamingo | 002fbd5c31cacf63e9ba20dfa461058eb1da38ec | 61b46a9f57c9aa4050b0dd8b95a44e1abef0d006 | refs/heads/master | 2023-08-20T16:52:26.905555 | 2010-06-09T08:22:51 | 2010-06-09T08:22:51 | 711,125 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,613 | cpp | //
// $Id: split_l.cpp 5027 2010-02-18 19:41:48Z rares $
//
// split_l.cpp
//
// Copyright (C) 2003 - 2007 by The Regents of the University of
// California
//
// Redistribution of this file is permitted under the terms of the
// BSD license
//
// Date: March 2002
//
// Authors: Michael Ortega-Binderberger <miki (at) ics.uci.edu>
// Liang Jin <liangj (at) ics.uci.edu>
// Chen Li <chenli (at) ics.uci.edu>
//
#include <stdio.h>
#include "assert.h"
#include "index.h"
//#include "card.h"
#include "split_l.h"
/*-----------------------------------------------------------------------------
| Load branch buffer with branches from full node plus the extra branch.
-----------------------------------------------------------------------------*/
static void RTreeGetBranches(struct Node *N, struct Branch *B)
{
register struct Node *n = N;
register struct Branch *b = B;
register int i;
assert(n);
assert(b);
/* load the branch buffer */
for (i=0; i<NODECARD; i++)
{
assert(n->branch[i].child); /* every entry should be full */
BranchBuf[i] = n->branch[i];
}
BranchBuf[NODECARD] = *b;
BranchCount = NODECARD + 1;
/* calculate rect containing all in the set */
CoverSplit = BranchBuf[0].rect;
for (i=1; i<NODECARD+1; i++)
{
CoverSplit = RTreeCombineRect(&CoverSplit, &BranchBuf[i].rect);
}
RTreeInitNode(n);
}
/*-----------------------------------------------------------------------------
| Initialize a PartitionVars structure.
-----------------------------------------------------------------------------*/
static void RTreeInitPVars(struct PartitionVars *P, int maxrects, int minfill)
{
register struct PartitionVars *p = P;
register int i;
assert(p);
p->count[0] = p->count[1] = 0;
p->total = maxrects;
p->minfill = minfill;
for (i=0; i<maxrects; i++)
{
p->taken[i] = FALSE;
p->partition[i] = -1;
}
}
/*-----------------------------------------------------------------------------
| Put a branch in one of the groups.
-----------------------------------------------------------------------------*/
static void RTreeClassify(int i, int group, struct PartitionVars *p)
{
assert(p);
assert(!p->taken[i]);
p->partition[i] = group;
p->taken[i] = TRUE;
if (p->count[group] == 0)
p->cover[group] = BranchBuf[i].rect;
else
p->cover[group] = RTreeCombineRect(&BranchBuf[i].rect,
&p->cover[group]);
p->area[group] = RTreeRectSphericalVolume(&p->cover[group]);
p->count[group]++;
}
/*-----------------------------------------------------------------------------
| Pick two rects from set to be the first elements of the two groups.
| Pick the two that are separated most along any dimension, or overlap least.
| Distance for separation or overlap is measured modulo the width of the
| space covered by the entire set along that dimension.
-----------------------------------------------------------------------------*/
static void RTreePickSeeds(struct PartitionVars *P)
{
register struct PartitionVars *p = P;
register int i, dim, high;
register struct Rect *r, *rlow, *rhigh;
register float w, separation, bestSep;
RectReal width[NUMDIMS];
int leastUpper[NUMDIMS], greatestLower[NUMDIMS];
int seed0, seed1;
assert(p);
for (dim=0; dim<NUMDIMS; dim++)
{
high = dim + NUMDIMS;
/* find the rectangles farthest out in each direction
* along this dimens */
greatestLower[dim] = leastUpper[dim] = 0;
for (i=1; i<NODECARD+1; i++)
{
r = &BranchBuf[i].rect;
if (r->boundary[dim] >
BranchBuf[greatestLower[dim]].rect.boundary[dim])
{
greatestLower[dim] = i;
}
if (r->boundary[high] <
BranchBuf[leastUpper[dim]].rect.boundary[high])
{
leastUpper[dim] = i;
}
}
/* find width of the whole collection along this dimension */
width[dim] = CoverSplit.boundary[high] -
CoverSplit.boundary[dim];
}
/* pick the best separation dimension and the two seed rects */
for (dim=0; dim<NUMDIMS; dim++)
{
high = dim + NUMDIMS;
/* divisor for normalizing by width */
assert(width[dim] >= 0);
if (width[dim] == 0)
w = (RectReal)1;
else
w = width[dim];
rlow = &BranchBuf[leastUpper[dim]].rect;
rhigh = &BranchBuf[greatestLower[dim]].rect;
if (dim == 0)
{
seed0 = leastUpper[0];
seed1 = greatestLower[0];
separation = bestSep =
(rhigh->boundary[0] -
rlow->boundary[NUMDIMS]) / w;
}
else
{
separation =
(rhigh->boundary[dim] -
rlow->boundary[dim+NUMDIMS]) / w;
if (separation > bestSep)
{
seed0 = leastUpper[dim];
seed1 = greatestLower[dim];
bestSep = separation;
}
}
}
if (seed0 != seed1)
{
RTreeClassify(seed0, 0, p);
RTreeClassify(seed1, 1, p);
}
}
/*-----------------------------------------------------------------------------
| Put each rect that is not already in a group into a group.
| Process one rect at a time, using the following hierarchy of criteria.
| In case of a tie, go to the next test.
| 1) If one group already has the max number of elements that will allow
| the minimum fill for the other group, put r in the other.
| 2) Put r in the group whose cover will expand less. This automatically
| takes care of the case where one group cover contains r.
| 3) Put r in the group whose cover will be smaller. This takes care of the
| case where r is contained in both covers.
| 4) Put r in the group with fewer elements.
| 5) Put in group 1 (arbitrary).
|
| Also update the covers for both groups.
-----------------------------------------------------------------------------*/
static void RTreePigeonhole(struct PartitionVars *P)
{
register struct PartitionVars *p = P;
struct Rect newCover[2];
register int i, group;
RectReal newArea[2], increase[2];
for (i=0; i<NODECARD+1; i++)
{
if (!p->taken[i])
{
/* if one group too full, put rect in the other */
if (p->count[0] >= p->total - p->minfill)
{
RTreeClassify(i, 1, p);
continue;
}
else if (p->count[1] >= p->total - p->minfill)
{
RTreeClassify(i, 0, p);
continue;
}
/* find areas of the two groups' old and new covers */
for (group=0; group<2; group++)
{
if (p->count[group]>0)
newCover[group] = RTreeCombineRect(
&BranchBuf[i].rect,
&p->cover[group]);
else
newCover[group] = BranchBuf[i].rect;
newArea[group] = RTreeRectSphericalVolume(
&newCover[group]);
increase[group] = newArea[group]-p->area[group];
}
/* put rect in group whose cover will expand less */
if (increase[0] < increase[1])
RTreeClassify(i, 0, p);
else if (increase[1] < increase[0])
RTreeClassify(i, 1, p);
/* put rect in group that will have a smaller cover */
else if (p->area[0] < p->area[1])
RTreeClassify(i, 0, p);
else if (p->area[1] < p->area[0])
RTreeClassify(i, 1, p);
/* put rect in group with fewer elements */
else if (p->count[0] < p->count[1])
RTreeClassify(i, 0, p);
else
RTreeClassify(i, 1, p);
}
}
assert(p->count[0] + p->count[1] == NODECARD + 1);
}
/*-----------------------------------------------------------------------------
| Method 0 for finding a partition:
| First find two seeds, one for each group, well separated.
| Then put other rects in whichever group will be smallest after addition.
-----------------------------------------------------------------------------*/
static void RTreeMethodZero(struct PartitionVars *p, int minfill)
{
RTreeInitPVars(p, BranchCount, minfill);
RTreePickSeeds(p);
RTreePigeonhole(p);
}
/*-----------------------------------------------------------------------------
| Copy branches from the buffer into two nodes according to the partition.
-----------------------------------------------------------------------------*/
static void RTreeLoadNodes(struct Node *N, struct Node *Q,
struct PartitionVars *P)
{
register struct Node *n = N, *q = Q;
register struct PartitionVars *p = P;
register int i;
assert(n);
assert(q);
assert(p);
for (i=0; i<NODECARD+1; i++)
{
if (p->partition[i] == 0)
RTreeAddBranch(&BranchBuf[i], n, NULL);
else if (p->partition[i] == 1)
RTreeAddBranch(&BranchBuf[i], q, NULL);
else
assert(FALSE);
}
}
/*-----------------------------------------------------------------------------
| Split a node.
| Divides the nodes branches and the extra one between two nodes.
| Old node is one of the new ones, and one really new one is created.
-----------------------------------------------------------------------------*/
void RTreeSplitNode(struct Node *n, struct Branch *b, struct Node **nn)
{
register struct PartitionVars *p;
register int level;
RectReal area;
assert(n);
assert(b);
/* load all the branches into a buffer, initialize old node */
level = n->level;
RTreeGetBranches(n, b);
/* find partition */
p = &Partitions[0];
/* Note: can't use MINFILL(n) below since n was cleared by GetBranches() */
RTreeMethodZero(p, level>0 ? MinNodeFill : MinLeafFill);
/* record how good the split was for statistics */
area = p->area[0] + p->area[1];
/* put branches from buffer in 2 nodes according to chosen partition */
*nn = RTreeNewNode();
(*nn)->level = n->level = level;
RTreeLoadNodes(n, *nn, p);
assert(n->count + (*nn)->count == NODECARD+1);
}
/*-----------------------------------------------------------------------------
| Print out data for a partition from PartitionVars struct.
-----------------------------------------------------------------------------*/
static void RTreePrintPVars(struct PartitionVars *p)
{
int i;
assert(p);
printf("\npartition:\n");
for (i=0; i<NODECARD+1; i++)
{
printf("%3d\t", i);
}
printf("\n");
for (i=0; i<NODECARD+1; i++)
{
if (p->taken[i])
printf(" t\t");
else
printf("\t");
}
printf("\n");
for (i=0; i<NODECARD+1; i++)
{
printf("%3d\t", p->partition[i]);
}
printf("\n");
printf("count[0] = %d area = %f\n", p->count[0], p->area[0]);
printf("count[1] = %d area = %f\n", p->count[1], p->area[1]);
printf("total area = %f effectiveness = %3.2f\n",
p->area[0] + p->area[1],
RTreeRectSphericalVolume(&CoverSplit)/(p->area[0]+p->area[1]));
printf("cover[0]:\n");
RTreePrintRect(&p->cover[0], 0);
printf("cover[1]:\n");
RTreePrintRect(&p->cover[1], 0);
}
| [
"[email protected]"
]
| [
[
[
1,
383
]
]
]
|
bea80023195cdfacd9dff420aef1957c7ef49513 | be2e23022d2eadb59a3ac3932180a1d9c9dee9c2 | /AccountServer/LoginThread.cpp | f1d0288c92d95e0bddf91bfc199098a0b068b768 | []
| no_license | cronoszeu/revresyksgpr | 78fa60d375718ef789042c452cca1c77c8fa098e | 5a8f637e78f7d9e3e52acdd7abee63404de27e78 | refs/heads/master | 2020-04-16T17:33:10.793895 | 2010-06-16T12:52:45 | 2010-06-16T12:52:45 | 35,539,807 | 0 | 2 | null | null | null | null | GB18030 | C++ | false | false | 10,054 | cpp | // 登录线程类
// 仙剑修,2001.11.20
#include "AllHeads.h"
#include "LoginThread.h"
#undef LOCKTHREAD // 登录线程不需要互斥★
#define LOCKTHREAD
CLoginThread::CLoginThread(u_short nPort)
: CThreadBase(), m_cListenSocket(nPort)
{
LOCKTHREAD;
m_pBanIPs = new CBanIP[MAXBANIPS];
}
CLoginThread::~CLoginThread()
{
LOCKTHREAD;
delete m_pBanIPs;
}
// 该线程类没有外部消息进入,没有共享冲突
void CLoginThread::OnInit()
{
LOCKTHREAD;
try{
m_cListenSocket.Open();
LOGMSG("登录线程正常启动");
}catch(...) { LOGCATCH("登录线程初始化异常退出"); }
}
bool CLoginThread::OnProcess()
{
LOCKTHREAD;
try{
time_t tStart = clock();
long nUsed = 0;
if(g_bEnableLogin) // 允许登录了:)
{
// select
fd_set readmask;
FD_ZERO(&readmask);
if(!m_cListenSocket.IsOpen())
m_cListenSocket.Rebuild();
if(m_cListenSocket.IsOpen())
FD_SET(m_cListenSocket.Socket(), &readmask);
for(int i = 0; i < MAXCONNECTS; i++)
{
if(m_aServerSocket[i].IsOpen())
FD_SET(m_aServerSocket[i].Socket(), &readmask);
}
struct timeval timeout = {0,0};
int ret = select(FD_SETSIZE, &readmask, (fd_set *) 0, (fd_set *) 0, &timeout);
// 检查是否接收到新连接
if(ret == -1) // error
{
// m_cListenSocket.Close();
LOGERROR("登录线程 select 错误[%d]", WSAGetLastError());
// PrintText("登录线程出错,SOCKET被关闭。%d 秒后将会自动重建", REBUILDLISTENDELAYSEC);
}
else if(ret > 0 && FD_ISSET(m_cListenSocket.Socket(), &readmask))
{
FD_CLR(m_cListenSocket.Socket(), &readmask);
ret--;
u_long nClientIP;
SOCKET sockNew = m_cListenSocket.Accept(nClientIP);
if(sockNew != INVALID_SOCKET)
{
InterlockedIncrement(&s_nLoginAccept);
// 取对方IP。查BAN表
bool bBan = false;
// sockaddr_in inAddr;
// memset(&inAddr, 0, sizeof(inAddr));
// int nLen = sizeof(inAddr);
// if(getpeername(sockNew, (sockaddr *)&inAddr, &nLen) == 0) // 可以直接由ACCEPT返回
{
// uint32 nClientIP = inAddr.sin_addr.S_un.S_addr;
for(int i = 0; i < MAXBANIPS; i++)
{
if(m_pBanIPs[i].ClientIP() == nClientIP && m_pBanIPs[i].IsBan())
{
bBan = true; // 不让该IP登录
break;
}
}
}
// 添加在线表
if(bBan)
{
// 关闭SOCKET
// 修改SOCKET属性成立即关闭型
struct linger ling;
ling.l_onoff = 1;
ling.l_linger = 0;
setsockopt(sockNew, SOL_SOCKET, SO_LINGER, (char *)&ling, sizeof(ling));
closesocket(sockNew); // ★主动关闭SOCKET,必须设置成立即关闭
InterlockedDecrement(&s_nSocketCount);
}
else
{
// 找空位置
bool bSuccess = false;
int i;
for(i = 0; i < MAXCONNECTS; i++)
{
if(!m_aServerSocket[i].IsOpen())
{
bSuccess = true;
break; // 成功
}
}
// 添加连接
if(bSuccess)
{
m_aServerSocket[i].Open(sockNew, nClientIP);
m_aServerSocket[i].GetPeerIP(); // 立即取IP
}
else
{
/*
LOGWARNING("已接收到一个新连接,但连接表已满。请修改MAXCONNECTS,并重新编译程序。");
// 修改SOCKET属性成立即关闭型
struct linger ling;
ling.l_onoff = 1;
ling.l_linger = 0;
setsockopt(sockNew, SOL_SOCKET, SO_LINGER, (char *)&ling, sizeof(ling));
closesocket(sockNew);
InterlockedDecrement(&s_nSocketCount);
//*/
//*else
// 抢占旧有的连接,以对抗“大量连接攻击”。可优化为找出攻击者,加入BAN表。??
srand((unsigned int) clock());
int nPos = rand() % MAXCONNECTS;
char bufTemp[IPSTRSIZE];
ASSERT(m_aServerSocket[nPos].IsOpen());
SafeCopy(bufTemp, m_aServerSocket[nPos].GetPeerIP(), IPSTRSIZE);
if(FD_ISSET(m_aServerSocket[nPos].Socket(), &readmask))
{
FD_CLR(m_aServerSocket[nPos].Socket(), &readmask);
ret--;
}
m_aServerSocket[nPos].Close(true);
// 由新SOCKET使用
m_aServerSocket[nPos].Open(sockNew, nClientIP);
LOGWARNING("连接表已满,MAXCONNECTS参数太小。[%s]抢占了[%s]的连接表。",
m_aServerSocket[nPos].GetPeerIP(), bufTemp);
//*/
}
}
}
} // 新连接
// 接收到登录消息包。需要优化??
for(int i = 0; i < MAXCONNECTS; i++)
{
if(ret <= 0)
break; // 没连接有数据了
if(m_aServerSocket[i].IsOpen() && FD_ISSET(m_aServerSocket[i].Socket(), &readmask))
{
FD_CLR(m_aServerSocket[i].Socket(), &readmask);
ret--;
char bufMsg[_MAX_MSGSIZE];
int nMsgLen = 0;
if(m_aServerSocket[i].Recv(bufMsg, nMsgLen))
{
if(nMsgLen)
{
ProcessMsg(i, bufMsg, nMsgLen);
}
}
}
}
nUsed = clock() - tStart;
InterlockedExchangeAdd(&s_nAllTimeSum, nUsed);
InterlockedIncrement(&s_nLoginCount);
InterlockedExchangeAdd(&s_nAvgServerTime, nUsed);
if(nUsed > InterlockedExchangeAdd(&s_nMaxServerTime, 0))
InterlockedExchange(&s_nMaxServerTime, nUsed);
} // if(g_bEnableLogin)
long nRemain = LOGINLOOPDELAY - nUsed;
if(nRemain < 0 || nRemain > LOGINLOOPDELAY)
nRemain = 0; //? 切换到计点线程。计费线程优先
Sleep(nRemain);
return true;
}catch(...) {
LOGCATCH("登录线程主循环异常,仍坚持运行中。");
PrintText("登录线程主循环出错,仍坚持运行中...");
return true;
}
}
void CLoginThread::OnDestroy()
{
LOCKTHREAD;
try{
m_cListenSocket.Close();
for(int i = 0; i < MAXCONNECTS; i++)
{
// if(m_aServerSocket[i].IsOpen())
m_aServerSocket[i].Close();
}
LOGMSG("登录线程正常关闭");
}catch(...) { LOGCATCH("登录线程关闭时异常退出"); }
}
// 内部函数/////////
bool CLoginThread::ProcessMsg(int nIndex, char * pBuf, int nLen)
{
Msg* pMsg = (Msg*)pBuf;
if(nLen <= 2*sizeof(uint16)|| nLen > _MAX_MSGSIZE)
return false;
if(pMsg->GetSize()!=nLen)
return false;
return m_aServerSocket[nIndex].processMsg(pMsg);
}
// 私有函数///////////////////////
bool AppendPassword(OBJID idAccount, LPCTSTR szAccount, LPCTSTR szPassword)
{
bool bUpdate = false;
::WaitForSingleObject(g_xDatabase, INFINITE); //+++++++++++++++++++++++++
if(g_cDatabase.Create(szAccount, szPassword)) // 有帐号
{ // VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
g_cDatabase.Destroy();
// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
g_pOnlineTable->SetPassword(idAccount, szPassword);
bUpdate = true;
}
::ReleaseMutex(g_xDatabase); //------------------------------------------
return bUpdate;
}
///////////////////////
bool GetFeeType(LPCTSTR szAccount, LPCTSTR szPassword, int& nFeeType, int& nPoint) // return nType
{
nFeeType = c_typeNone;
::WaitForSingleObject(g_xDatabase, INFINITE); //+++++++++++++++++++++++++
if(g_cDatabase.Create(szAccount, szPassword)) // 有帐号
{ // VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
nFeeType = g_cDatabase.GetType();
nPoint = g_cDatabase.GetPoint();
g_cDatabase.Destroy();
// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
}
::ReleaseMutex(g_xDatabase); //------------------------------------------
return (nFeeType != c_typeNone);
}
///////////////////////
bool GetLicence(LPCTSTR szBarAccount, LPCTSTR szBarPassword,
OBJID& idFeeAccount, int& nPoint, DWORD& nPointTime, // 返回值
int& nLicenceType, int& nLicence, char* szNetBarIP, char* szIPMask) // 返回值
{
idFeeAccount = ID_NONE;
::WaitForSingleObject(g_xDatabase, INFINITE); //+++++++++++++++++++++++++
if(g_cDatabase.Create(szBarAccount, szBarPassword)) // 有帐号
{ // VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
idFeeAccount = g_cDatabase.GetID();
nPoint = g_cDatabase.GetPoint();
nPointTime = g_cDatabase.GetPointTime();
nLicenceType = g_cDatabase.GetType();
nLicence = g_cDatabase.GetLicence();
SafeCopy(szNetBarIP, g_cDatabase.GetNetBarIP(), MAX_NAMESIZE);
SafeCopy(szIPMask, g_cDatabase.GetIPMask(), MAX_NAMESIZE);
g_cDatabase.Destroy();
// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
}
::ReleaseMutex(g_xDatabase); //------------------------------------------
return (idFeeAccount != ID_NONE);
}
void CLoginThread::addBan(DWORD nClientIP, LPCTSTR szClientIP, LPCTSTR szAccount)
{
// 增加BAN表
bool bFoundBan = false;
int nFreeSlot = -1;
int nBanCount = 0;
// 找个空位置
for(int i = 0; i < MAXBANIPS; i++)
{
if(m_pBanIPs[i].ClientIP() == 0)
{
if(nFreeSlot == -1)
nFreeSlot = i;
}
else
{
nBanCount++;
}
if(m_pBanIPs[i].ClientIP() == nClientIP) // 已记录
{
bFoundBan = true;
m_pBanIPs[i].IncError(); //? 不立即踢,超过再踢
if(m_pBanIPs[i].IsBan())
{
LOGERROR("某客户端已非法登录[%d]次,可能有人攻击帐号服务器。IP地址[%s]", BANERRORS, szClientIP);
LOGACCOUNT("某玩家[%s]登录到帐号服务器连续出错[%d]次。IP地址[%s]被禁止[%d]秒钟",
szAccount, BANERRORS, szClientIP, BANSECS);
PrintText("IP地址“%s”连续出错“%d”次, “%d”秒内将无法登录",
szClientIP, BANERRORS, BANSECS);
}
}
}
if(!bFoundBan)
{
// 添加新BAN
if(nFreeSlot != -1)
{
m_pBanIPs[nFreeSlot].Create(nClientIP);
if(nBanCount*100/MAXBANIPS > 78) // 快满了
LOGWARNING("添加BAN表[%d/%d],IP为[%s]", nBanCount+1, MAXBANIPS, szClientIP);
}
else
{
LOGERROR("BAN 表太小,有个IP[%s]没填进去。请适当增大 MAXBANIPS 参数", szClientIP);
}
}
} | [
"rpgsky.com@cc92e6ba-efcf-11de-bf31-4dec8810c1c1"
]
| [
[
[
1,
331
]
]
]
|
3e9593b23f715a726c2d9c24884d095702aff49e | f9774f8f3c727a0e03c170089096d0118198145e | /传奇mod/Mir2ExCode/Mir2/Common/DLinkedList.h | 34b45762b415f76dce5a341deadd09aa874af509 | []
| no_license | sdfwds4/fjljfatchina | 62a3bcf8085f41d632fdf83ab1fc485abd98c445 | 0503d4aa1907cb9cf47d5d0b5c606df07217c8f6 | refs/heads/master | 2021-01-10T04:10:34.432964 | 2010-03-07T09:43:28 | 2010-03-07T09:43:28 | 48,106,882 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,967 | h | /******************************************************************************************************************
DLinkedList.h: interface for the CDLList class.
*******************************************************************************************************************/
#if !defined(AFX_DLINKEDLIST_H__FA0909F7_8D66_4986_83D4_12A536AEACE2__INCLUDED_)
#define AFX_DLINKEDLIST_H__FA0909F7_8D66_4986_83D4_12A536AEACE2__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
using namespace std;
template<class T>
class CDLList
{
private:
typedef struct tagNODE
{
T typeData;
tagNODE* pNextNode;
tagNODE* pPrevNode;
tagNODE(T data, tagNODE* pNext=NULL, tagNODE* pPrev=NULL)
{
typeData = data;
pNextNode = pNext;
pPrevNode = pPrev;
}
}NODE, *LPNODE;
LPNODE m_stHead;
LPNODE m_pstCurrNode;
LPNODE m_stTail;
INT m_nCurrentPos;
INT m_nCounter;
public:
CDLList(CDLList<T>& DLList);
// Constructor
CDLList()
{
m_stHead = NULL;
m_stTail = NULL;
m_pstCurrNode = NULL;
m_nCounter = 0;
m_nCurrentPos = 0;
};
// Destructor
virtual ~CDLList()
{
ClearAllNodes();
};
VOID AddNode(T data)
{
LPNODE pstTempNode = new NODE(data);
if ( m_stTail != NULL )
{
m_stTail->pNextNode = pstTempNode;
pstTempNode->pNextNode = pstTempNode;
pstTempNode->pPrevNode = m_stTail;
m_stTail = m_stTail->pNextNode;
}
else
{
m_stHead = pstTempNode;
m_stHead->pPrevNode = m_stHead;
m_stHead->pNextNode = m_stHead;
m_stTail = m_stHead;
m_pstCurrNode = m_stHead;
}
m_nCounter++;
};
BOOL DeleteCurrentNode(VOID)
{
LPNODE pstTempNode;
if ( m_pstCurrNode != NULL )
{
m_nCounter--;
m_pstCurrNode->pPrevNode->pNextNode = m_pstCurrNode->pNextNode;
m_pstCurrNode->pNextNode->pPrevNode = m_pstCurrNode->pPrevNode;
pstTempNode = m_pstCurrNode;
m_pstCurrNode = m_pstCurrNode->pNextNode;
if ( pstTempNode == m_pstCurrNode ) // Current = Tail ?
{
m_stTail = m_stTail->pPrevNode;
m_pstCurrNode = m_pstCurrNode->pPrevNode;
m_pstCurrNode->pNextNode = m_pstCurrNode;
m_nCurrentPos--;
if ( m_pstCurrNode == pstTempNode ) // Current = Head = Tail ?
{
m_stHead = NULL;
m_stTail = NULL;
m_pstCurrNode = NULL;
m_nCurrentPos = 0;
}
}
else if(pstTempNode == m_stHead) // Current = Head ?
{
m_stHead = pstTempNode->pNextNode;
m_pstCurrNode = pstTempNode->pNextNode;
m_pstCurrNode->pPrevNode = m_pstCurrNode;
if ( pstTempNode == m_stHead ) // Current = Head = Tail ?
{
m_stHead = NULL;
m_stTail = NULL;
m_pstCurrNode = NULL;
m_nCurrentPos = 0;
}
}
delete pstTempNode;
return TRUE;
}
else
{
return FALSE;
}
};
INT ListLength(VOID)
{
return m_nCounter;
};
INT MoveNextNode(VOID)
{
LPNODE pstTempNode;
if ( m_pstCurrNode && m_pstCurrNode->pNextNode )
{
pstTempNode = m_pstCurrNode;
m_pstCurrNode = pstTempNode->pNextNode;
m_nCurrentPos = (m_nCurrentPos<m_nCounter) ? m_nCurrentPos+1: m_nCounter;
}
return m_nCurrentPos;
};
INT MovePreviousNode(VOID)
{
LPNODE pstTempNode;
pstTempNode = m_pstCurrNode;
m_pstCurrNode = pstTempNode->pPrevNode;
m_nCurrentPos = (m_nCurrentPos>1) ? m_nCurrentPos-1: 1;
return m_nCurrentPos;
};
INT MoveNode(INT nMovement)
{
if ( nMovement > 0 )
{
for ( INT nLoops = 0; nLoops < nMovement; nLoops++ )
MoveNextNode();
}
else
{
nMovement = (-nMovement);
for ( INT nLoops = 0; nLoops < nMovement; nLoops++)
MovePreviousNode();
}
return m_nCurrentPos;
};
VOID MoveCurrentToTop(VOID)
{
m_pstCurrNode = m_stHead;
m_nCurrentPos = 0;
};
VOID MoveCurrentToTail(VOID)
{
m_pstCurrNode = m_stTail;
m_nCurrentPos = m_nCounter-1;
};
VOID ClearAllNodes(VOID)
{
LPNODE pstTempNode;
if ( m_nCounter > 0 )
{
for ( INT nLoops = 0; nLoops < m_nCounter; nLoops++ )
{
pstTempNode = m_stHead;
m_stHead = m_stHead->pNextNode;
delete pstTempNode;
}
}
m_nCounter = 0;
m_stHead = NULL;
m_stTail = NULL;
m_pstCurrNode = NULL;
m_nCurrentPos =0;
};
T* GetCurrentData(VOID)
{
return &(m_pstCurrNode->typeData);
};
INT GetCounter(VOID)
{
return m_nCounter;
};
INT GetCurrPosition(VOID)
{
return m_nCurrentPos;
};
BOOL IsCurrentTail(VOID)
{
if ( m_pstCurrNode == m_stTail )
return TRUE;
else
return FALSE;
};
BOOL IsCurrentHead(VOID)
{
if (m_pstCurrNode == m_stHead )
return TRUE;
else
return FALSE;
}
BOOL CheckEmpty()
{
if ( m_stHead == NULL )
return TRUE;
else
return FALSE;
}
};
#endif // !defined(AFX_DLINKEDLIST_H__FA0909F7_8D66_4986_83D4_12A536AEACE2__INCLUDED_)
| [
"fjljfat@4a88d1ba-22b1-11df-8001-4f4b503b426e"
]
| [
[
[
1,
246
]
]
]
|
22ca62843e779d4b5724dc438846c833b2d021e5 | 6ee200c9dba87a5d622c2bd525b50680e92b8dab | /Walkyrie Dx9/Valkyrie/Moteur/ObjetDeCollision.cpp | 798346e62f2e8dc8b8f1417b6ea0d17954234815 | []
| no_license | Ishoa/bizon | 4dbcbbe94d1b380f213115251e1caac5e3139f4d | d7820563ab6831d19e973a9ded259d9649e20e27 | refs/heads/master | 2016-09-05T11:44:00.831438 | 2010-03-10T23:14:22 | 2010-03-10T23:14:22 | 32,632,823 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 6,880 | cpp | #include "ObjetDeCollision.h"
CObjetDeCollision::CObjetDeCollision()
{
m_pPolygonList = NULL;
m_pPolygonListLowDetail = NULL;
}
CObjetDeCollision::~CObjetDeCollision()
{
// On libère les ressources utilisées par la liste de polygones.
if ( m_pPolygonList != NULL )
{
delete m_pPolygonList;
m_pPolygonList = NULL;
}
if ( m_pPolygonListLowDetail != NULL )
{
delete m_pPolygonListLowDetail;
m_pPolygonListLowDetail = NULL;
}
}
void CObjetDeCollision::Release()
{
if(m_pPolygonList != NULL)
{
m_pPolygonList->ReleaseList();
}
if(m_pPolygonListLowDetail != NULL)
{
m_pPolygonListLowDetail->ReleaseList();
}
}
// Obtient les données des polygones de l'objet.
CPolygonList* CObjetDeCollision::GetPolygonList()
{
return m_pPolygonList;
}
// Obtient les données des polygones de l'objet.
CPolygonList* CObjetDeCollision::GetPolygonListLowDetail()
{
return m_pPolygonListLowDetail;
}
// Obtient la boîte de collisions de l'objet.
CBoundingBox CObjetDeCollision::GetBoundingBox()
{
if ( m_pPolygonList == NULL )
{
return CBoundingBox();
}
return m_pPolygonList->GetBoundingBox();
}
// Obtient la sphere de collisions de l'objet.
CBoundingSphere CObjetDeCollision::GetBoundingSphere()
{
if ( m_pPolygonList == NULL )
{
return CBoundingSphere();
}
return m_pPolygonList->GetBoundingSphere();
}
// Cette fonction teste la validité de la prochaine position.
D3DXVECTOR3 CObjetDeCollision::CheckNextPosition( D3DXVECTOR3 CurrentPosition, D3DXVECTOR3 NextPosition,float fAvatarHeight, CCalculsCollisions::eCollisionType p_CollisionType)
{
// Teste si le moteur de collision est activé.
if ( p_CollisionType == CCalculsCollisions::NO_COLLISION )
{
// Si le moteur de collision est ignoré, on retourne simplement la
// prochaine position.
return NextPosition;
}
else
{
// Sinon, il faut tester s'il y a eu une collision.
bool Collision = false;
bool MultipleCollisions = false;
D3DXPLANE SlidingPlane;
D3DXPLANE CollisionPlane;
// On teste tous les murs du terrain de jeu. Dans un programme lourd,
// il faudrait réduire au maximum le nombre de polygones à tester, en
// utilisant par exemple un arbre BSP (Binary Space Partitionning).
// Ici, il s'agit d'une démo, donc le code doit rester simple, et le
// faible nombre de polygones à tester (22 au total) permet d'ignorer
// ce test. Remarquez tout de même que le sol et le plafond ne sont pas
// testés, puisqu'il est impossible d'entrer en collision avec eux.
// On obtient le pointeur sur la liste de polygones de l'objet.
CPolygonContainer* CurrentPolygon =
m_pPolygonList->GetFirst();
// On recherche une collision dans toute la liste de polygones.
while ( CurrentPolygon != NULL )
{
// On obtient le polygone courant, et on lui applique une
// transformation pour le placer dans le bon système d'axes.
// Une meilleure méthode serait de convertir uniquement la
// position à tester dans le système d'axes du polygone, en
// appliquant l'inverse de la matrice du polygone sur la
// position, afin d'économiser quelques calculs. Mais parce-
// qu'on devra utiliser le plan du polygone pour le Sliding,
// plus tard, il vaut mieux pour notre cas convertir les
// coordonnées du polygone, et obtenir directement le bon plan.
CPolygon TestPolygon =
CurrentPolygon->GetPolygon()->ApplyMatrix(GetWorldMatrix());
// On teste ensuite si l'avatar est en collision avec le
// polygone. Au passage, on récupère le plan de collision,
// si celui-ci existe. Remarquez que la position à tester est
// inversée, afin de travailler avec le bon système d'axes.
if ( CCalculsCollisions::
Check( NextPosition,
fAvatarHeight,
TestPolygon,
&SlidingPlane ) == true )
{
// Si une collision a déjà eu lieu, et si le plan trouvé
// n'est pas identique au plan de la collision précédente,
// ni à l'inverse du plan de la collision précédente,
// alors on indique que le joueur est en collision avec
// plusieurs murs.
if ( ( SlidingPlane.a != CollisionPlane.a ||
SlidingPlane.b != CollisionPlane.b ||
SlidingPlane.c != CollisionPlane.c ||
SlidingPlane.d != CollisionPlane.d ) &&
( SlidingPlane.a != -CollisionPlane.a ||
SlidingPlane.b != -CollisionPlane.b ||
SlidingPlane.c != -CollisionPlane.c ||
SlidingPlane.d != -CollisionPlane.d ) &&
Collision == true )
{
MultipleCollisions = true;
}
// On copie le plan de collision.
CollisionPlane = SlidingPlane;
Console<<"COllision"<<endl;
// Puis, on indique qu'une collision a eu lieu.
Collision = true;
}
// On passe au polygone suivant, pour parcourir toute la liste.
CurrentPolygon = CurrentPolygon->GetNext();
}
// On teste l'état du moteur de collision.
if ( p_CollisionType == CCalculsCollisions::COLLISION_ONLY )
{
// Si le moteur doit tester uniquement les collisions, on teste
// les valeurs retournées par la fonction de collision.
if ( Collision == false )
{
// Si aucune collision n'a été détectée, alors la prochaine
// position est valide. Dans ce cas, on la retoune simplement.
return NextPosition;
}
// Si une collision a été trouvée, la nouvelle position n'est
// pas valide. Dans ce cas, on reste à la position courante.
return CurrentPosition;
}
else
{
// Si le moteur doit tester les collisions et gérer le sliding,
// on teste les valeurs retournées par la fonction de collision.
if ( Collision == false )
{
// Si aucune collision n'a été détectée, alors la prochaine
// position est valide. Dans ce cas, on la retourne simplement.
return NextPosition;
}
else if ( Collision == true && MultipleCollisions == false )
{
// Si une seule collision a été détectée, on corrige la
// position du joueur en fonction du plan du mur touché.
// Remarquez que la position est inversée, pour qu'elle
// corresponde au système d'axes du plan, et que la réponse est
// à nouveau inversée, pour la reconvertir aux systèmes d'axes
// de la caméra.
return ( CCalculsCollisions::GetSlidingPoint( CollisionPlane,
NextPosition,
fAvatarHeight ) );
}
// Si plus d'une collision a été trouvée, la nouvelle position
// n'est pas valide. Dans ce cas, on reste à la position courante.
return CurrentPosition;
}
}
// Ce point du code n'est jamais atteint, mais il vaut mieux le traiter
// quand même, pour éviter des erreurs de compilation.
return D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
} | [
"Colas.Vincent@ab19582e-f48f-11de-8f43-4547254af6c6"
]
| [
[
[
1,
209
]
]
]
|
b6d9612873aa2ca274f597e6912236dbcfaa410b | db654455154ec84525a338995c3548feb3222fba | /mesh/TetrahedMesh.cpp | 0be58ed6dc2c50497419d7dd4fba2eb1d7080ec5 | []
| no_license | eong2012/fem-deformable-bodies | 7a8af0a6d1e527f5269929bad28e00b40257498d | 9c8d53217b5d75a1f3c7a35572733c7ec9d8b90b | refs/heads/master | 2021-01-10T12:38:19.826468 | 2010-12-22T15:30:44 | 2010-12-22T15:30:44 | 36,107,178 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 28,101 | cpp | #include "TetrahedMesh.h"
#include <ctime>
#include <cstdlib>
using namespace std;
TetrahedMesh::TetrahedMesh()
{
mTetraheds = new vector<Tetrahed>();
mHalfEdges = new vector<HalfEdge>();
mFaces = new vector<Face>();
mVertices = new vector<Vertex>();
mVertexIndexOrder = new vector<unsigned int>();
this->currentNode = 0;
srand(time(0));
}
TetrahedMesh::~TetrahedMesh(){
delete mTetraheds;
delete mHalfEdges;
delete mFaces;
delete mVertices;
delete mVertexIndexOrder;
}
void TetrahedMesh::AddTetrahedron(vector<arma::Mat<double> > vertices ) {
buildTetrahedonMesh(vertices, mTetraheds, mFaces, mHalfEdges, mVertices, false);
}
void TetrahedMesh::buildTetrahedonMesh(vector<arma::Mat<double> > vertices, vector<Tetrahed> *mtetrahedsTemp, vector<Face> *mFacesTemp, vector<HalfEdge> *mEdgesTemp, vector<Vertex> *mVerticesTemp, bool subdivide)
{
//set the vertex index
unsigned int vertexIndex1, vertexIndex2, vertexIndex3, vertexIndex4;
setTetraGeometry(vertices,vertexIndex1, vertexIndex2, vertexIndex3, vertexIndex4, mVerticesTemp);
mVertexIndexOrder->push_back(vertexIndex1);
mVertexIndexOrder->push_back(vertexIndex2);
mVertexIndexOrder->push_back(vertexIndex3);
mVertexIndexOrder->push_back(vertexIndex4);
//Add each tetrahedron face, send in vertex indices counter-clockwise
unsigned int faceIndex1, faceIndex2,faceIndex3,faceIndex4;
AddFace(vertexIndex1, vertexIndex4, vertexIndex3,faceIndex1, mFacesTemp, mEdgesTemp, mVerticesTemp);
AddFace(vertexIndex1, vertexIndex3, vertexIndex2,faceIndex2, mFacesTemp, mEdgesTemp, mVerticesTemp);
AddFace(vertexIndex2, vertexIndex3, vertexIndex4,faceIndex3, mFacesTemp, mEdgesTemp, mVerticesTemp);
AddFace(vertexIndex1, vertexIndex2, vertexIndex4,faceIndex4, mFacesTemp, mEdgesTemp, mVerticesTemp);
//Add a tetrahed which contains pointers to all spanning faces
Tetrahed* temp = new Tetrahed();
temp->setFaceInd1(faceIndex1);
temp->setFaceInd2(faceIndex2);
temp->setFaceInd3(faceIndex3);
temp->setFaceInd4(faceIndex4);
mtetrahedsTemp->push_back((*temp));
int sis = mtetrahedsTemp->size();
mFacesTemp->at(faceIndex1).setTetrahedInd(mtetrahedsTemp->size()-1);
mFacesTemp->at(faceIndex2).setTetrahedInd(mtetrahedsTemp->size()-1);
mFacesTemp->at(faceIndex3).setTetrahedInd(mtetrahedsTemp->size()-1);
mFacesTemp->at(faceIndex4).setTetrahedInd(mtetrahedsTemp->size()-1);
delete temp;
if (subdivide == false){
mTetraheds = mtetrahedsTemp;
mHalfEdges = mEdgesTemp;
mVertices = mVerticesTemp;
mFaces = mFacesTemp;
}
}
void TetrahedMesh::setTetraGeometry(vector<arma::Mat<double> > vertices, unsigned int &index1,unsigned int &index2,unsigned int &index3,unsigned int &index4, vector<Vertex> *mVertices)
{
// unsigned int index1,index2,index3,index4;
bool success = true;
success &= AddVertex(vertices[0],index1, mVertices);
success &= AddVertex(vertices[1],index2, mVertices);
success &= AddVertex(vertices[2],index3, mVertices);
success &= AddVertex(vertices[3],index4, mVertices);
}
void TetrahedMesh::AddFace(unsigned int vertexIndex1,unsigned int vertexIndex2, unsigned int vertexIndex3,unsigned int &faceIndex, vector<Face> *mFacesTemp, vector<HalfEdge> *mEdgesTemp, vector<Vertex> *mVerticesTemp)
{
//add halfedges
unsigned int edgeIndex1,edgeIndex2,edgeIndex3,edgeIndex4,edgeIndex5,edgeIndex6;
AddHalfEdgePair(vertexIndex1,vertexIndex2,edgeIndex1,edgeIndex2, mEdgesTemp,mVerticesTemp);
AddHalfEdgePair(vertexIndex2,vertexIndex3,edgeIndex3,edgeIndex4, mEdgesTemp,mVerticesTemp);
AddHalfEdgePair(vertexIndex3,vertexIndex1,edgeIndex5,edgeIndex6, mEdgesTemp,mVerticesTemp);
// Connect inner ring
mEdgesTemp->at(edgeIndex1).setNextInd(edgeIndex3);
mEdgesTemp->at(edgeIndex1).setPrevInd(edgeIndex5);
mEdgesTemp->at(edgeIndex3).setNextInd(edgeIndex5);
mEdgesTemp->at(edgeIndex3).setPrevInd(edgeIndex1);
mEdgesTemp->at(edgeIndex5).setNextInd(edgeIndex1);
mEdgesTemp->at(edgeIndex5).setPrevInd(edgeIndex3);
// Finally, create the face, don't forget to set the normal
Face *face = new Face();
vector<Face>::iterator iter;
iter = mFacesTemp->begin();
int count = 0;
while(iter != mFacesTemp->end()){
HalfEdge* edge = &mEdgesTemp->at(iter->getEdgeInd());
Vertex & v1 = mVerticesTemp->at(edge->getVertexInd());
edge = &mEdgesTemp->at(edge->getNextInd());
Vertex & v2 = mVerticesTemp->at(edge->getVertexInd());
edge = &mEdgesTemp->at(edge->getNextInd());
Vertex & v3 = mVerticesTemp->at(edge->getVertexInd());
if (vecEquals(mVerticesTemp->at(vertexIndex1).getPosition(), v1.getPosition()) || vecEquals(mVerticesTemp->at(vertexIndex1).getPosition(), v2.getPosition()) || vecEquals(mVerticesTemp->at(vertexIndex1).getPosition(), v3.getPosition())){
if(vecEquals(mVerticesTemp->at(vertexIndex2).getPosition(),v1.getPosition()) || vecEquals(mVerticesTemp->at(vertexIndex2).getPosition(), v2.getPosition()) || vecEquals(mVerticesTemp->at(vertexIndex2).getPosition(),v3.getPosition())){
if(vecEquals(mVerticesTemp->at(vertexIndex3).getPosition(), v1.getPosition()) || vecEquals(mVerticesTemp->at(vertexIndex3).getPosition(),v2.getPosition()) || vecEquals(mVerticesTemp->at(vertexIndex3).getPosition(), v3.getPosition())){
face->setOppositeFaceInd(count);
iter->setOppositeFaceInd(mFacesTemp->size());
//cout << "Count: " << count << endl;
break;
}
}
}
count++;
iter += 1;
}
// Connect the face to an edge
face->setEdgeInd(edgeIndex1);
mFacesTemp->push_back((*face));
delete face;
// Compute and assign a normal
mFacesTemp->back().setNormal(FaceNormal(mFacesTemp->size() - 1, mFacesTemp, mEdgesTemp, mVerticesTemp));
// All half-edges share the same left face (previously added)
mEdgesTemp->at(edgeIndex1).setFaceInd(mFacesTemp->size() - 1);
mEdgesTemp->at(edgeIndex2).setFaceInd(mFacesTemp->size() - 1);
mEdgesTemp->at(edgeIndex3).setFaceInd(mFacesTemp->size() - 1);
//also send back faceIndex
faceIndex = mFacesTemp->size() - 1;
}
void TetrahedMesh::AddHalfEdgePair(unsigned int vertexIndex1,unsigned int vertexIndex2,unsigned int &edgeIndex1,unsigned int &edgeIndex2, vector<HalfEdge> *mEdgesTemp, vector<Vertex> *mVerticesTemp)
{
//Set index
edgeIndex1 = mEdgesTemp->size();
edgeIndex2 = edgeIndex1+1;
// Create edges and set pair index
HalfEdge *halfEdge1, *halfEdge2;
halfEdge1 = new HalfEdge();
halfEdge2 = new HalfEdge();
halfEdge1->setPairInd(edgeIndex2);
halfEdge2->setPairInd(edgeIndex1);
// Connect the edges to the verts
halfEdge1->setVertexInd(vertexIndex1);
halfEdge2->setVertexInd(vertexIndex2);
// Connect the verts to the edges
mVerticesTemp->at(vertexIndex1).setEdgeInd(edgeIndex1);
mVerticesTemp->at(vertexIndex2).setEdgeInd(edgeIndex2);
// Store the edges in mEdges
mEdgesTemp->push_back(*halfEdge1);
mEdgesTemp->push_back(*halfEdge2);
delete halfEdge1;
delete halfEdge2;
// Store the first edge in the map as an OrderedPair
// OrderedPair op(v1, v2);
}
bool TetrahedMesh::AddVertex(arma::Mat<double> vertexPos, unsigned int &index, vector<Vertex> *mVerticesTemp)
{
vector<Vertex>::iterator iter;
iter = mVerticesTemp->begin();
int count = 0;
while(iter != mVerticesTemp->end()){
if (vecEquals(iter->getPosition(), vertexPos)) {
index = count;
return true;
}
count++;
iter += 1;
}
Vertex vert;
vert.setPosition(vertexPos);
mVerticesTemp->push_back(vert); // add it to the vertex list
index = mVerticesTemp->size()-1;
return true;
}
arma::Mat<double> TetrahedMesh::FaceNormal(unsigned int faceIndex, vector<Face> *mFacesTemp, vector<HalfEdge> *mEdgesTemp, vector<Vertex> *mVerticesTemp)
{
unsigned int edgeInd1 = mFacesTemp->at(faceIndex).getEdgeInd();
unsigned int vertInd1 = mEdgesTemp->at(edgeInd1).getVertexInd();
const arma::Mat<double> &p1 = mVerticesTemp->at(vertInd1).getPosition();
unsigned int edgeInd2 = mEdgesTemp->at(edgeInd1).getNextInd();
unsigned int vertInd2 = mEdgesTemp->at(edgeInd2).getVertexInd();
const arma::Mat<double> &p2 = mVerticesTemp->at(vertInd2).getPosition();
unsigned int edgeInd3 = mEdgesTemp->at(edgeInd2).getNextInd();
unsigned int vertInd3 = mEdgesTemp->at(edgeInd3).getVertexInd();
const arma::Mat<double> &p3 = mVerticesTemp->at(vertInd3).getPosition();
const arma::Mat<double> e1 = p2-p1;
const arma::Mat<double> e2 = p3-p1;
arma::Mat<double> tmp;
tmp = cross(e1, e2);
tmp = tmp / norm(tmp,1);
return tmp;
}
void TetrahedMesh::Render(int mode)
{
// Draw geometry
const int numTriangles = mFaces->size();
for (int i = 0; i < numTriangles; i++){
Face & face = mFaces->at(i);
face.setNormal(FaceNormal(i,mFaces, mHalfEdges, mVertices));
HalfEdge* edge = &mHalfEdges->at(face.getEdgeInd());
Vertex & v1 = mVertices->at(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
Vertex & v2 = mVertices->at(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
Vertex & v3 = mVertices->at(edge->getVertexInd());
if(mode == 2){
if (face.getOppositeFaceInd() == -1) {
glColor3f(1.0f, 1.0f, 1.0f);
glNormal3f(face.getNormal()[0], face.getNormal()[1], face.getNormal()[2]);
glBegin(GL_TRIANGLES);
glVertex3f(v1.getPosition()[0], v1.getPosition()[1], v1.getPosition()[2]);
glVertex3f(v2.getPosition()[0], v2.getPosition()[1], v2.getPosition()[2]);
glVertex3f(v3.getPosition()[0], v3.getPosition()[1], v3.getPosition()[2]);
glEnd();
}
}
if(mode == 1){
if (face.getOppositeFaceInd() != -1) {
glColor3f(1.0f, 1.0f, 1.0f);
glNormal3f(face.getNormal()[0], face.getNormal()[1], face.getNormal()[2]);
glBegin(GL_TRIANGLES);
glVertex3f(v1.getPosition()[0], v1.getPosition()[1], v1.getPosition()[2]);
glVertex3f(v2.getPosition()[0], v2.getPosition()[1], v2.getPosition()[2]);
glVertex3f(v3.getPosition()[0], v3.getPosition()[1], v3.getPosition()[2]);
glEnd();
}
}
if(mode == 0){
glColor3f(1.0f, 1.0f, 1.0f);
glNormal3f(face.getNormal()[0], face.getNormal()[1], face.getNormal()[2]);
glBegin(GL_TRIANGLES);
glVertex3f(v1.getPosition()[0], v1.getPosition()[1], v1.getPosition()[2]);
glVertex3f(v2.getPosition()[0], v2.getPosition()[1], v2.getPosition()[2]);
glVertex3f(v3.getPosition()[0], v3.getPosition()[1], v3.getPosition()[2]);
glEnd();
}
}
}
void TetrahedMesh::RenderNormals(int mode) {
const int numTriangles = mFaces->size();
for (int i = 0; i < numTriangles; i++){
Face & face = mFaces->at(i);
HalfEdge* edge = &mHalfEdges->at(face.getEdgeInd());
Vertex & v1 = mVertices->at(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
Vertex & v2 = mVertices->at(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
Vertex & v3 = mVertices->at(edge->getVertexInd());
arma::Mat<double> vCenter, normal;
normal = face.getNormal();
float scale= 80;
vCenter = (v1.getPosition()+v2.getPosition()+v3.getPosition())/3.0;
if (mode == 0) {
if (face.getOppositeFaceInd() != -1) {
glColor3f(1.0f, 0.0f, 1.0f);
glBegin(GL_LINES);
glVertex3f(vCenter[0], vCenter[1], vCenter[2]);
glVertex3f(vCenter[0]+normal[0]/scale, vCenter[1]+normal[1]/scale, vCenter[2]+normal[2]/scale);
glEnd();
}
}
if (mode == 1) {
if (face.getOppositeFaceInd() == -1) {
glColor3f(1.0f, 0.0f, 1.0f);
glBegin(GL_LINES);
glVertex3f(vCenter[0], vCenter[1], vCenter[2]);
glVertex3f(vCenter[0]+normal[0]/scale, vCenter[1]+normal[1]/scale, vCenter[2]+normal[2]/scale);
glEnd();
}
}
if (mode == 2) {
glColor3f(1.0f, 0.0f, 1.0f);
glBegin(GL_LINES);
glVertex3f(vCenter[0], vCenter[1], vCenter[2]);
glVertex3f(vCenter[0]+normal[0]/scale, vCenter[1]+normal[1]/scale, vCenter[2]+normal[2]/scale);
glEnd();
}
}
}
void TetrahedMesh::RenderEdges(int mode) {
const int numTriangles = mFaces->size();
for (int i = 0; i < numTriangles; i++){
Face & face = mFaces->at(i);
HalfEdge* edge = &mHalfEdges->at(face.getEdgeInd());
Vertex & v1 = mVertices->at(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
Vertex & v2 = mVertices->at(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
Vertex & v3 = mVertices->at(edge->getVertexInd());
if (mode == 0) {
if (face.getOppositeFaceInd() != -1) {
glColor3f(0.2f, 0.0f, 1.0f);
glBegin(GL_LINES);
glVertex3f(v1.getPosition()[0], v1.getPosition()[1], v1.getPosition()[2]);
glVertex3f(v2.getPosition()[0], v2.getPosition()[1], v2.getPosition()[2]);
glVertex3f(v2.getPosition()[0], v2.getPosition()[1], v2.getPosition()[2]);
glVertex3f(v3.getPosition()[0], v3.getPosition()[1], v3.getPosition()[2]);
glVertex3f(v3.getPosition()[0], v3.getPosition()[1], v3.getPosition()[2]);
glVertex3f(v1.getPosition()[0], v1.getPosition()[1], v1.getPosition()[2]);
glEnd();
}
}
if (mode == 1) {
if (face.getOppositeFaceInd() == -1) {
glColor3f(0.2f, 0.0f, 1.0f);
glBegin(GL_LINES);
glVertex3f(v1.getPosition()[0], v1.getPosition()[1], v1.getPosition()[2]);
glVertex3f(v2.getPosition()[0], v2.getPosition()[1], v2.getPosition()[2]);
glVertex3f(v2.getPosition()[0], v2.getPosition()[1], v2.getPosition()[2]);
glVertex3f(v3.getPosition()[0], v3.getPosition()[1], v3.getPosition()[2]);
glVertex3f(v3.getPosition()[0], v3.getPosition()[1], v3.getPosition()[2]);
glVertex3f(v1.getPosition()[0], v1.getPosition()[1], v1.getPosition()[2]);
glEnd();
}
}
if (mode == 2) {
glColor3f(0.2f, 0.0f, 1.0f);
glBegin(GL_LINES);
glVertex3f(v1.getPosition()[0], v1.getPosition()[1], v1.getPosition()[2]);
glVertex3f(v2.getPosition()[0], v2.getPosition()[1], v2.getPosition()[2]);
glVertex3f(v2.getPosition()[0], v2.getPosition()[1], v2.getPosition()[2]);
glVertex3f(v3.getPosition()[0], v3.getPosition()[1], v3.getPosition()[2]);
glVertex3f(v3.getPosition()[0], v3.getPosition()[1], v3.getPosition()[2]);
glVertex3f(v1.getPosition()[0], v1.getPosition()[1], v1.getPosition()[2]);
glEnd();
}
}
}
//Get the vertex array for use to create a texture
float* TetrahedMesh::GetVertexArray()
{
float *vertexArray = new float[4*mVertices->size()];
for(unsigned int i = 0; i < mVertices->size(); i++)
{
vertexArray[i*4] = mVertices->at(i).getPosition()[0];
vertexArray[i*4+1] = mVertices->at(i).getPosition()[1];
vertexArray[i*4+2] = mVertices->at(i).getPosition()[2];
vertexArray[i*4+3] = 1.0f;
}
return vertexArray;
}
int TetrahedMesh::GetVertexArraySize()
{
return 4*mVertices->size();
}
vector<arma::Mat<double> > TetrahedMesh::getVertexPosition(unsigned int tetraIndex){
vector<arma::Mat<double> > ret;
unsigned int vertexIndex[4];
for(int i=0; i<4;i++){
arma::Mat<double> tempVertexPos(4,1);
vertexIndex[i] = mVertexIndexOrder->at(tetraIndex*4+i);
tempVertexPos(0) = mVertices->at(vertexIndex[i]).getPosition()[0];
tempVertexPos(1) = mVertices->at(vertexIndex[i]).getPosition()[1];
tempVertexPos(2) = mVertices->at(vertexIndex[i]).getPosition()[2];
tempVertexPos(3) = vertexIndex[i];
ret.push_back(tempVertexPos);
}
return ret;
/* Tetrahed tempTetra;
tempTetra = mTetraheds->at(tetraIndex);
vector<unsigned int> faceIndices = tempTetra.getFaceInd();
set<unsigned int> vertexIndices;
vector<arma::Mat<double> > ret;
//vector< arma::Mat<double> > ret;
for(int i=0; i<4;i++){
Face & face = mFaces->at(faceIndices[i]);
HalfEdge* edge = &mHalfEdges->at(face.getEdgeInd());
vertexIndices.insert(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
vertexIndices.insert(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
vertexIndices.insert(edge->getVertexInd());
}
set<unsigned int>::iterator iter = vertexIndices.begin();
while(iter!=vertexIndices.end())
{
arma::Mat<double> temp(4,1);
temp(0) = mVertices->at(*iter).getPosition()[0];
temp(1) = mVertices->at(*iter).getPosition()[1];
temp(2) = mVertices->at(*iter).getPosition()[2];
temp(3) = (*iter);
ret.push_back(temp);
//cout << *iter << endl;
iter++;
}
*/
}
int TetrahedMesh::getNrOfTetrahedra(){
return mTetraheds->size();
}
void TetrahedMesh::updatePosition(unsigned int tetraIndex, vector<arma::Mat<double> > vertexPos)
{
Tetrahed tempTetra;
tempTetra = mTetraheds->at(tetraIndex);
vector<unsigned int> faceIndices = tempTetra.getFaceInd();
set<unsigned int> vertexIndices;
for(int i=0; i<4;i++){
Face & face = mFaces->at(faceIndices[i]);
HalfEdge* edge = &mHalfEdges->at(face.getEdgeInd());
vertexIndices.insert(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
vertexIndices.insert(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
vertexIndices.insert(edge->getVertexInd());
}
set<unsigned int>::iterator iter = vertexIndices.begin();
int count = 0;
while(iter!=vertexIndices.end())
{
mVertices->at(*iter).setPosition(vertexPos[count]);
iter++;
count++;
}
}
void TetrahedMesh::printVertices(int ind)
{
cout << mVertices->at(ind).getPosition() << endl;
}
bool TetrahedMesh::vecEquals(arma::Mat<double> A, arma::Mat<double> B){
arma::umat C = (A == B);
for(unsigned int i= 0; i<C.n_elem;i++){
if(C(i)== 0) return false;
}
return true;
}
void TetrahedMesh::subdivide() {
vector<HalfEdge> *newMHalfEdges = new vector<HalfEdge>();
vector<Face> *newMFaces = new vector<Face>();
vector<Tetrahed> *newMTetraheds = new vector<Tetrahed>();
vector<Vertex> *newMVertices = new vector<Vertex>();
for(unsigned int i = 0; i < mTetraheds->size(); i++) {
arma::Mat<double> v5;
v5 = arma::zeros(3,1);
vector<arma::Mat<double> > verticesList;
vector<arma::Mat<double> > verticesT = getVertexPosition(i);
for (unsigned int j= 0; j < verticesT.size(); j++) {
v5 += verticesT[j].rows(0,2);
arma::Mat<double> temp;
temp << verticesT[j](0) << verticesT[j](1) << verticesT[j](2);
verticesList.push_back(temp);
}
v5 = v5/verticesT.size();
verticesT.clear();
arma::Mat<double> v5p;
v5p << v5(0) << v5(1) << v5(2);
vector<arma::Mat<double> > verticesList2;
//TETRAHED 1
if(i == 1 || i == 2) {
verticesList2.push_back(verticesList.at(2));
verticesList2.push_back(verticesList.at(1));
verticesList2.push_back(verticesList.at(0));
verticesList2.push_back(v5p);
} else {
verticesList2.push_back(verticesList.at(0));
verticesList2.push_back(verticesList.at(1));
verticesList2.push_back(verticesList.at(2));
verticesList2.push_back(v5p);
}
this->buildTetrahedonMesh(verticesList2,newMTetraheds,newMFaces,newMHalfEdges,newMVertices, true);
verticesList2.clear();
//TETRAHED 2
if(i == 1 || i == 2) {
verticesList2.push_back(verticesList.at(2));
verticesList2.push_back(v5p);
verticesList2.push_back(verticesList.at(3));
verticesList2.push_back(verticesList.at(1));
} else {
verticesList2.push_back(verticesList.at(1));
verticesList2.push_back(v5p);
verticesList2.push_back(verticesList.at(3));
verticesList2.push_back(verticesList.at(2));
}
this->buildTetrahedonMesh(verticesList2,newMTetraheds,newMFaces,newMHalfEdges,newMVertices, true);
verticesList2.clear();
//TETRAHED 3
if(i == 1 || i == 2) {
verticesList2.push_back(v5p);
verticesList2.push_back(verticesList.at(3));
verticesList2.push_back(verticesList.at(0));
verticesList2.push_back(verticesList.at(2));
} else {
verticesList2.push_back(verticesList.at(0));
verticesList2.push_back(verticesList.at(3));
verticesList2.push_back(v5p);
verticesList2.push_back(verticesList.at(2));
}
this->buildTetrahedonMesh(verticesList2,newMTetraheds,newMFaces,newMHalfEdges,newMVertices, true);
verticesList2.clear();
//TETRAHED 4
if(i == 1 || i == 2) {
verticesList2.push_back(verticesList.at(1));
verticesList2.push_back(verticesList.at(3));
verticesList2.push_back(verticesList.at(0));
verticesList2.push_back(v5p);
}
else {
verticesList2.push_back(verticesList.at(0));
verticesList2.push_back(verticesList.at(3));
verticesList2.push_back(verticesList.at(1));
verticesList2.push_back(v5p);
}
this->buildTetrahedonMesh(verticesList2,newMTetraheds,newMFaces,newMHalfEdges,newMVertices, true);
verticesList2.clear();
verticesList.clear();
cout << mTetraheds->size() << endl;
}
delete mFaces;
delete mHalfEdges;
delete mTetraheds;
delete mVertices;
this->mFaces = newMFaces;
this->mHalfEdges = newMHalfEdges;
this->mTetraheds = newMTetraheds;
this->mVertices = newMVertices;
}
arma::Mat<double> TetrahedMesh::pickNode() {
arma::Mat<double> temp = this->mVertices->at(currentNode).getPosition();
return temp;
}
void TetrahedMesh::pickNextNode() {
if (this->currentNode < mVertices->size()-1){
this->currentNode += 1;
} else {
this->currentNode = 0;
}
}
void TetrahedMesh::pickNextFourNode() {
pickedNodes.clear();
vector<unsigned int > list;
unsigned int currentNode = 0;
arma::Mat<double> temp;
arma::Mat<double> temp2;
temp = mVertices->at(0).getPosition();
for(int i = 0; i<mVertices->size();i++){
temp2 = mVertices->at(i).getPosition();
if(temp(0) > temp2(0)){
currentNode = i;
temp = mVertices->at(i).getPosition();
}
}
pickedNodes.push_back(currentNode);
arma::Mat<double> temp3;
arma::Mat<double> temp4 = mVertices->at(currentNode).getPosition();
for(int i = 0; i<mVertices->size();i++){
temp3 = mVertices->at(i).getPosition();
if (temp3(0) == temp4(0) && vecEquals(temp3, temp4) == false) {
pickedNodes.push_back(i);
if (pickedNodes.size() > 3) {
break;
}
}
}
}
unsigned int TetrahedMesh::getCurrentNode() {
return this->currentNode;
}
void TetrahedMesh::crackStructure(unsigned int ind, arma::Mat<double> eigVec) {
Tetrahed tempTetra = mTetraheds->at(ind);
vector<unsigned int> faceIndices = tempTetra.getFaceInd();
vector<unsigned int> vertexIndices;
for(int i=0; i<4;i++){
Face & face = mFaces->at(faceIndices[i]);
HalfEdge* edge = &mHalfEdges->at(face.getEdgeInd());
vertexIndices.push_back(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
vertexIndices.push_back(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
vertexIndices.push_back(edge->getVertexInd());
}
int size = vertexIndices.size();
unsigned int rIndex = rand() % size;
unsigned int vIndex = vertexIndices.at(rIndex);
arma::Mat<double> v(3,1);
v= mVertices->at(vIndex).getPosition();
vector<unsigned int> adjecentList = getAdjecentTetraheds(ind, v);
if (adjecentList.size() > 0) {
determineLocationOfCrack(ind,adjecentList,v,eigVec,vIndex);
}
}
vector<unsigned int> TetrahedMesh::getAdjecentTetraheds(unsigned int ind, arma::Mat<double> v) {
vector<unsigned int> tetraIndices;
Tetrahed tempTetra = mTetraheds->at(ind);
vector<unsigned int> faceIndices = tempTetra.getFaceInd();
int count = 0;
for(int i=0; i<4;i++){
//get face
Face & face = mFaces->at(faceIndices[i]);
//get all vertices of that face
HalfEdge* edge = &mHalfEdges->at(face.getEdgeInd());
Vertex & v1 = mVertices->at(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
Vertex & v2 = mVertices->at(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
Vertex & v3 = mVertices->at(edge->getVertexInd());
int index = face.getOppositeFaceInd();
if (index != -1 && (vecEquals(v, v1.getPosition()) || vecEquals(v, v2.getPosition()) || vecEquals(v, v3.getPosition()))){
getAdjecent(mFaces->at(index).getTetrahedInd(), ind, &tetraIndices, v, count);
break;
}
}
return tetraIndices;
}
void TetrahedMesh::getAdjecent(unsigned int currentind, unsigned int baseind, vector<unsigned int> *tetraIndices, arma::Mat<double> v, int count){
count += 1;
Tetrahed tempTetra = mTetraheds->at(currentind);
vector<unsigned int> faceIndices = tempTetra.getFaceInd();
for(int i=0; i<4;i++){
bool check = false;
//get face
Face & face = mFaces->at(faceIndices[i]);
//get all vertices of that face
HalfEdge* edge = &mHalfEdges->at(face.getEdgeInd());
Vertex & v1 = mVertices->at(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
Vertex & v2 = mVertices->at(edge->getVertexInd());
edge = &mHalfEdges->at(edge->getNextInd());
Vertex & v3 = mVertices->at(edge->getVertexInd());
int index = face.getOppositeFaceInd();
if (index != -1 && (vecEquals(v, v1.getPosition()) || vecEquals(v, v2.getPosition()) || vecEquals(v, v3.getPosition()))){
currentind = mFaces->at(index).getTetrahedInd();
if(currentind != baseind) {
for (int j = 0; j < tetraIndices->size(); j++) {
if (tetraIndices->at(j) == currentind) {
check = true;
break;
}
}
if (check == false) {
tetraIndices->push_back(currentind);
getAdjecent(currentind, baseind, tetraIndices, v,count);
}
}
}
}
}
arma::Mat<double> TetrahedMesh::tetCenterOfMass(unsigned int tInd) {
vector<arma::Mat<double> > vertexList = getVertexPosition(tInd);
arma::Mat<double> center;
center = arma::zeros(3,1);
for(int i = 0; i <vertexList.size(); i++) {
center += vertexList.at(i).rows(0,2);
}
center = center/vertexList.size();
return center;
}
arma::Mat<double> TetrahedMesh::determineLocationOfCrack(unsigned int tInd, vector<unsigned int> adjecentList, arma::Mat<double> v, arma::Mat<double> eigVec,unsigned int vIndex) {
double D = arma::dot(trans(v),eigVec);
vector<unsigned int> Xpos;
vector<unsigned int> Xneg;
for(int i = 0; i < adjecentList.size();i++) {
arma::Mat<double> cMass = tetCenterOfMass(adjecentList.at(i));
double distanceFromPlane = arma::dot(cMass,eigVec)-D;
if (distanceFromPlane > 0.0) {
Xpos.push_back(adjecentList.at(i));
} else if (distanceFromPlane < 0.0) {
Xneg.push_back(adjecentList.at(i));
}
}
//deconnect(Xpos, v);
deconnect(Xneg, v, vIndex);
arma::Mat<double> mm;
return mm;
}
void TetrahedMesh::deconnect(vector<unsigned int> adjecentList, arma::Mat<double> v, unsigned int vIndex) {
unsigned int vInd;
Vertex temp;
temp.setPosition(v);
mVertices->push_back(temp);
vInd = mVertices->size()-1;
for (int j = 0; j < adjecentList.size(); j++) {
vector<unsigned int> faceIndices = mTetraheds->at(adjecentList.at(j)).getFaceInd();
for (int i = 0; i< faceIndices.size();i++) {
Face & face = mFaces->at(faceIndices[i]);
HalfEdge* edge = &mHalfEdges->at(face.getEdgeInd());
Vertex & v1 = mVertices->at(edge->getVertexInd());
if(vecEquals(v1.getPosition(),v)) {
//mFaces->at(faceIndices[i]).setOppositeFaceInd(-1);
edge->setVertexInd(vInd);
break;
}
edge = &mHalfEdges->at(edge->getNextInd());
Vertex & v2 = mVertices->at(edge->getVertexInd());
if(vecEquals(v2.getPosition(),v)) {
//mFaces->at(faceIndices[i]).setOppositeFaceInd(-1);
edge->setVertexInd(vInd);
break;
}
edge = &mHalfEdges->at(edge->getNextInd());
Vertex & v3 = mVertices->at(edge->getVertexInd());
if(vecEquals(v3.getPosition(),v)) {
edge->setVertexInd(vInd);
break;
}
}
}
}
| [
"[email protected]@cc8a84ad-3c34-5482-6608-053f25543658",
"elisabeth.lindquist@cc8a84ad-3c34-5482-6608-053f25543658",
"jpetersson86@cc8a84ad-3c34-5482-6608-053f25543658"
]
| [
[
[
1,
9
],
[
12,
13
],
[
15,
26
],
[
28,
28
],
[
30,
31
],
[
33,
35
],
[
42,
44
],
[
46,
48
],
[
52,
58
],
[
60,
60
],
[
63,
63
],
[
65,
81
],
[
83,
116
],
[
118,
120
],
[
122,
129
],
[
138,
141
],
[
144,
146
],
[
150,
150
],
[
152,
156
],
[
158,
198
],
[
201,
204
],
[
206,
209
],
[
211,
211
],
[
215,
215
],
[
217,
219
],
[
221,
229
],
[
232,
233
],
[
235,
237
],
[
239,
241
],
[
243,
244
],
[
251,
254
],
[
256,
256
],
[
258,
259
],
[
261,
266
],
[
268,
271
],
[
273,
275
],
[
277,
277
],
[
279,
289
],
[
291,
291
],
[
293,
301
],
[
303,
303
],
[
305,
305
],
[
307,
311
],
[
313,
313
],
[
315,
322
],
[
324,
324
],
[
326,
328
],
[
330,
338
],
[
341,
343
],
[
345,
350
],
[
352,
362
],
[
364,
369
],
[
371,
374
],
[
376,
376
],
[
378,
380
],
[
382,
384
],
[
386,
386
],
[
388,
391
],
[
393,
401
],
[
403,
405
],
[
407,
421
],
[
423,
435
],
[
437,
437
],
[
439,
446
],
[
448,
450
],
[
459,
459
],
[
463,
465
],
[
473,
474
],
[
477,
477
],
[
496,
496
],
[
501,
501
],
[
506,
506
],
[
508,
508
],
[
512,
512
],
[
515,
515
],
[
523,
529
],
[
537,
537
],
[
543,
543
],
[
550,
550
],
[
552,
552
],
[
556,
556
],
[
559,
559
],
[
567,
567
],
[
576,
579
],
[
591,
598
],
[
601,
603
],
[
605,
605
],
[
609,
609
],
[
612,
613
],
[
615,
616
],
[
621,
621
],
[
623,
636
],
[
638,
652
],
[
654,
660
],
[
662,
662
],
[
664,
671
],
[
674,
675
],
[
677,
680
],
[
684,
692
],
[
694,
694
],
[
696,
696
],
[
698,
707
],
[
709,
713
],
[
715,
721
],
[
723,
725
],
[
727,
801
],
[
803,
806
],
[
808,
808
],
[
810,
810
],
[
816,
820
],
[
822,
826
],
[
828,
847
],
[
849,
852
],
[
854,
859
],
[
861,
861
],
[
863,
884
],
[
887,
895
],
[
897,
897
],
[
899,
899
],
[
902,
912
],
[
915,
917
],
[
919,
919
],
[
921,
935
],
[
937,
937
],
[
939,
944
],
[
946,
980
],
[
982,
991
],
[
993,
1003
],
[
1005,
1015
]
],
[
[
10,
11
],
[
14,
14
],
[
27,
27
],
[
29,
29
],
[
32,
32
],
[
36,
41
],
[
49,
51
],
[
59,
59
],
[
61,
62
],
[
64,
64
],
[
82,
82
],
[
121,
121
],
[
131,
136
],
[
147,
147
],
[
151,
151
],
[
157,
157
],
[
199,
200
],
[
205,
205
],
[
213,
213
],
[
230,
231
],
[
234,
234
],
[
238,
238
],
[
242,
242
],
[
245,
250
],
[
267,
267
],
[
340,
340
],
[
457,
457
],
[
461,
461
],
[
475,
476
],
[
478,
482
],
[
484,
487
],
[
490,
495
],
[
497,
500
],
[
502,
505
],
[
507,
507
],
[
509,
511
],
[
513,
514
],
[
516,
522
],
[
530,
536
],
[
538,
542
],
[
544,
549
],
[
551,
551
],
[
553,
555
],
[
557,
558
],
[
560,
566
],
[
568,
575
],
[
580,
590
],
[
599,
600
],
[
604,
604
],
[
606,
608
],
[
610,
611
],
[
614,
614
],
[
617,
620
],
[
622,
622
],
[
637,
637
],
[
653,
653
],
[
661,
661
],
[
663,
663
],
[
672,
673
],
[
676,
676
],
[
681,
683
],
[
693,
693
],
[
695,
695
],
[
697,
697
],
[
708,
708
],
[
714,
714
],
[
722,
722
],
[
726,
726
],
[
802,
802
],
[
807,
807
],
[
809,
809
],
[
811,
815
],
[
821,
821
],
[
827,
827
],
[
848,
848
],
[
853,
853
],
[
860,
860
],
[
862,
862
],
[
885,
886
],
[
896,
896
],
[
898,
898
],
[
900,
901
],
[
913,
914
],
[
918,
918
],
[
920,
920
],
[
936,
936
],
[
938,
938
],
[
945,
945
],
[
981,
981
],
[
992,
992
],
[
1004,
1004
]
],
[
[
45,
45
],
[
117,
117
],
[
130,
130
],
[
137,
137
],
[
142,
143
],
[
148,
149
],
[
210,
210
],
[
212,
212
],
[
214,
214
],
[
216,
216
],
[
220,
220
],
[
255,
255
],
[
257,
257
],
[
260,
260
],
[
272,
272
],
[
276,
276
],
[
278,
278
],
[
290,
290
],
[
292,
292
],
[
302,
302
],
[
304,
304
],
[
306,
306
],
[
312,
312
],
[
314,
314
],
[
323,
323
],
[
325,
325
],
[
329,
329
],
[
339,
339
],
[
344,
344
],
[
351,
351
],
[
363,
363
],
[
370,
370
],
[
375,
375
],
[
377,
377
],
[
381,
381
],
[
385,
385
],
[
387,
387
],
[
392,
392
],
[
402,
402
],
[
406,
406
],
[
422,
422
],
[
436,
436
],
[
438,
438
],
[
447,
447
],
[
451,
456
],
[
458,
458
],
[
460,
460
],
[
462,
462
],
[
466,
472
],
[
483,
483
],
[
488,
489
]
]
]
|
ab3b8bd87fe62161b158758aabc4894b065f17bd | 7acbb1c1941bd6edae0a4217eb5d3513929324c0 | /GLibrary-CPP/sources/GHttp.h | d75ec32185351cd25bfeda897b0c3fe0c72d2786 | []
| no_license | hungconcon/geofreylibrary | a5bfc96e0602298b5a7b53d4afe7395a993498f1 | 3abf3e1c31a245a79fa26b4bcf2e6e86fa258e4d | refs/heads/master | 2021-01-10T10:11:51.535513 | 2009-11-30T15:29:34 | 2009-11-30T15:29:34 | 46,771,895 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 873 | h |
#ifndef __GHTTP_H__
# define __GHTTP_H__
#include "GString.h"
#include "GThread.h"
#include "GMutex.h"
#include "GExport.h"
#include "GSocketTcpClient.h"
#include "GCryptography.h"
class GEXPORTED GHttp
{
public:
GHttp(const GString &, unsigned int port = 80);
~GHttp(void);
void SetUser(const GString &Login, const GString &Password);
void SetProxy(const GString &Server, unsigned int Port);
void SetProxy(const GString &Server, unsigned int Port, const GString &Login, const GString &Password);
GString Get(const GString &);
void Post(const GString &, const GString &);
private:
GString _host;
GString _user;
GString _pass;
unsigned int _port;
GString _proxyHost;
unsigned int _proxyPort;
GString _proxyUser;
GString _proxyPass;
GSocketTcpClient _socket;
};
#endif
| [
"mvoirgard@34e8d5ee-a372-11de-889f-a79cef5dd62c",
"[email protected]"
]
| [
[
[
1,
7
],
[
9,
11
],
[
13,
17
],
[
22,
32
],
[
34,
37
]
],
[
[
8,
8
],
[
12,
12
],
[
18,
21
],
[
33,
33
]
]
]
|
590c7a17b2d0cc7bd16e5dfb6063b06fecec7d39 | 3da0b0276bc8c3d7d1bcdbabfb0e763a38d3a24c | /zju.finished/2422.cpp | 2360ba80df5009f3cac131b9350a6fa7e42a814d | []
| no_license | usherfu/zoj | 4af6de9798bcb0ffa9dbb7f773b903f630e06617 | 8bb41d209b54292d6f596c5be55babd781610a52 | refs/heads/master | 2021-05-28T11:21:55.965737 | 2009-12-15T07:58:33 | 2009-12-15T07:58:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,150 | cpp | #include<iostream>
using namespace std;
enum {
SIZ = 50004,
};
struct Node{
int x, y;
};
int num;
Node tree[SIZ];
int l[SIZ];
int r[SIZ];
int s[SIZ], top;
int val;
// [l, r]
void fun(){
int i;
top = 0; s[top] = 0;
for(i=1;i<=num;i++){
while(tree[s[top]].y >= tree[i].y){
top --;
}
l[i] = s[top] + 1;
s[++top] = i;
}
top = 0; s[top] = num + 1;
for(i=num;i>=1;i--){
while(tree[s[top]].y >= tree[i].y){
top --;
}
r[i] = s[top] - 1;
s[++top] = i;
}
int t;
val = 0;
for(i=1;i<=num;i++){
t = tree[r[i]].x - tree[l[i]-1].x;
t *= tree[i].y;
if(t > val)
val = t;
}
}
int readIn(){
scanf("%d", &num);
tree[0].y = tree[num+1].y = -1;
tree[0].x = tree[num+1].x = 0;
for(int i=1; i<=num; i++){
scanf("%d%d",&tree[i].x, &tree[i].y);
tree[i].x += tree[i-1].x;
}
return num;
}
int main(){
while(readIn() > 0){
fun();
printf("%d\n", val);
}
return 0;
}
| [
"[email protected]"
]
| [
[
[
1,
64
]
]
]
|
413d44a7a1fb812a7ae19353b24ff1ca75221d7e | 04480fe64bb0d0535711f534ac1d343f41fa297d | /arquiteturaQuaseFinal/Arquitetura/parser.cpp | bcd5a7eae4185e4fb44f17b4951176fdaa1d6d2a | []
| no_license | prosanes/arquitetura-pli | e37a69cd6b5e0c9dc6e8ae605cda5f1f21f328b4 | 05fc902d4cce4c009a1714e893bb04e02e7f94a9 | refs/heads/master | 2020-04-27T17:08:41.913097 | 2010-12-13T18:55:08 | 2010-12-13T18:55:08 | 32,121,762 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 49,159 | cpp | #include "parser.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
#define INI_PROG 0x0000
#define MAX_LABELS 2048
Parser::Parser (Memoria *memory, char* input)
{
posAtual = INI_PROG;
entrada = fopen (input, "r");
if (!entrada)
{
printf ("Nao foi possivel carregar o arquivo de entrada.\n");
}
mem = memory;
nop["add"] = 2;
nop["sub"] = 2;
nop["mov"] = 2;
nop["cmp"] = 2;
nop["and"] = 2;
nop["or"] = 2;
nop["not"] = 1;
nop["clr"] = 1;
nop["neg"] = 1;
nop["sh"] = 2;
nop["br"] = 2;
nop["jmp"] = 1;
nop["halt"] = 0;
nop["brz"] = 1;
nop["brn"] = 1;
nop["bre"] = 1;
nop["brl"] = 1;
nop["brg"] = 1;
nop["brc"] = 1;
nop["inc"] = 1;
nop["dec"] = 1;
nop["shl"] = 1;
nop["shr"] = 1;
codigo[command("add", "#const", "r0")] = 1;
codigo[command("add", "#const", "r1")] = 2;
codigo[command("add", "#const", "r2")] = 3;
codigo[command("add", "#const", "r3")] = 4;
codigo[command("add", "#const", "r4")] = 5;
codigo[command("add", "#const", "(r0)")] = 6;
codigo[command("add", "#const", "(r1)")] = 7;
codigo[command("add", "#const", "(r2)")] = 8;
codigo[command("add", "#const", "(r3)")] = 9;
codigo[command("add", "#const", "(r4)")] = 10;
codigo[command("add", "r0", "r0")] = 11;
codigo[command("add", "r0", "r1")] = 12;
codigo[command("add", "r0", "r2")] = 13;
codigo[command("add", "r0", "r3")] = 14;
codigo[command("add", "r0", "r4")] = 15;
codigo[command("add", "r1", "r0")] = 16;
codigo[command("add", "r1", "r1")] = 17;
codigo[command("add", "r1", "r2")] = 18;
codigo[command("add", "r1", "r3")] = 19;
codigo[command("add", "r1", "r4")] = 20;
codigo[command("add", "r2", "r0")] = 21;
codigo[command("add", "r2", "r1")] = 22;
codigo[command("add", "r2", "r2")] = 23;
codigo[command("add", "r2", "r3")] = 24;
codigo[command("add", "r2", "r4")] = 25;
codigo[command("add", "r3", "r0")] = 26;
codigo[command("add", "r3", "r1")] = 27;
codigo[command("add", "r3", "r2")] = 28;
codigo[command("add", "r3", "r3")] = 29;
codigo[command("add", "r3", "r4")] = 30;
codigo[command("add", "r4", "r0")] = 31;
codigo[command("add", "r4", "r1")] = 32;
codigo[command("add", "r4", "r2")] = 33;
codigo[command("add", "r4", "r3")] = 34;
codigo[command("add", "r4", "r4")] = 35;
codigo[command("add", "r0", "(r0)")] = 36;
codigo[command("add", "r0", "(r1)")] = 37;
codigo[command("add", "r0", "(r2)")] = 38;
codigo[command("add", "r0", "(r3)")] = 39;
codigo[command("add", "r0", "(r4)")] = 40;
codigo[command("add", "r1", "(r0)")] = 41;
codigo[command("add", "r1", "(r1)")] = 42;
codigo[command("add", "r1", "(r2)")] = 43;
codigo[command("add", "r1", "(r3)")] = 44;
codigo[command("add", "r1", "(r4)")] = 45;
codigo[command("add", "r2", "(r0)")] = 46;
codigo[command("add", "r2", "(r1)")] = 47;
codigo[command("add", "r2", "(r2)")] = 48;
codigo[command("add", "r2", "(r3)")] = 49;
codigo[command("add", "r2", "(r4)")] = 50;
codigo[command("add", "r3", "(r0)")] = 51;
codigo[command("add", "r3", "(r1)")] = 52;
codigo[command("add", "r3", "(r2)")] = 53;
codigo[command("add", "r3", "(r3)")] = 54;
codigo[command("add", "r3", "(r4)")] = 55;
codigo[command("add", "r4", "(r0)")] = 56;
codigo[command("add", "r4", "(r1)")] = 57;
codigo[command("add", "r4", "(r2)")] = 58;
codigo[command("add", "r4", "(r3)")] = 59;
codigo[command("add", "r4", "(r4)")] = 60;
codigo[command("add", "(r0)", "r0")] = 61;
codigo[command("add", "(r0)", "r1")] = 62;
codigo[command("add", "(r0)", "r2")] = 63;
codigo[command("add", "(r0)", "r3")] = 64;
codigo[command("add", "(r0)", "r4")] = 65;
codigo[command("add", "(r1)", "r0")] = 66;
codigo[command("add", "(r1)", "r1")] = 67;
codigo[command("add", "(r1)", "r2")] = 68;
codigo[command("add", "(r1)", "r3")] = 69;
codigo[command("add", "(r1)", "r4")] = 70;
codigo[command("add", "(r2)", "r0")] = 71;
codigo[command("add", "(r2)", "r1")] = 72;
codigo[command("add", "(r2)", "r2")] = 73;
codigo[command("add", "(r2)", "r3")] = 74;
codigo[command("add", "(r2)", "r4")] = 75;
codigo[command("add", "(r3)", "r0")] = 76;
codigo[command("add", "(r3)", "r1")] = 77;
codigo[command("add", "(r3)", "r2")] = 78;
codigo[command("add", "(r3)", "r3")] = 79;
codigo[command("add", "(r3)", "r4")] = 80;
codigo[command("add", "(r4)", "r0")] = 81;
codigo[command("add", "(r4)", "r1")] = 82;
codigo[command("add", "(r4)", "r2")] = 83;
codigo[command("add", "(r4)", "r3")] = 84;
codigo[command("add", "(r4)", "r4")] = 85;
codigo[command("add", "(r0)", "(r0)")] = 86;
codigo[command("add", "(r0)", "(r1)")] = 87;
codigo[command("add", "(r0)", "(r2)")] = 88;
codigo[command("add", "(r0)", "(r3)")] = 89;
codigo[command("add", "(r0)", "(r4)")] = 90;
codigo[command("add", "(r1)", "(r0)")] = 91;
codigo[command("add", "(r1)", "(r1)")] = 92;
codigo[command("add", "(r1)", "(r2)")] = 93;
codigo[command("add", "(r1)", "(r3)")] = 94;
codigo[command("add", "(r1)", "(r4)")] = 95;
codigo[command("add", "(r2)", "(r0)")] = 96;
codigo[command("add", "(r2)", "(r1)")] = 97;
codigo[command("add", "(r2)", "(r2)")] = 98;
codigo[command("add", "(r2)", "(r3)")] = 99;
codigo[command("add", "(r2)", "(r4)")] = 100;
codigo[command("add", "(r3)", "(r0)")] = 101;
codigo[command("add", "(r3)", "(r1)")] = 102;
codigo[command("add", "(r3)", "(r2)")] = 103;
codigo[command("add", "(r3)", "(r3)")] = 104;
codigo[command("add", "(r3)", "(r4)")] = 105;
codigo[command("add", "(r4)", "(r0)")] = 106;
codigo[command("add", "(r4)", "(r1)")] = 107;
codigo[command("add", "(r4)", "(r2)")] = 108;
codigo[command("add", "(r4)", "(r3)")] = 109;
codigo[command("add", "(r4)", "(r4)")] = 110;
codigo[command("sub", "#const", "r0")] = 111;
codigo[command("sub", "#const", "r1")] = 112;
codigo[command("sub", "#const", "r2")] = 113;
codigo[command("sub", "#const", "r3")] = 114;
codigo[command("sub", "#const", "r4")] = 115;
codigo[command("sub", "#const", "(r0)")] = 116;
codigo[command("sub", "#const", "(r1)")] = 117;
codigo[command("sub", "#const", "(r2)")] = 118;
codigo[command("sub", "#const", "(r3)")] = 119;
codigo[command("sub", "#const", "(r4)")] = 120;
codigo[command("sub", "r0", "r0")] = 121;
codigo[command("sub", "r0", "r1")] = 122;
codigo[command("sub", "r0", "r2")] = 123;
codigo[command("sub", "r0", "r3")] = 124;
codigo[command("sub", "r0", "r4")] = 125;
codigo[command("sub", "r1", "r0")] = 126;
codigo[command("sub", "r1", "r1")] = 127;
codigo[command("sub", "r1", "r2")] = 128;
codigo[command("sub", "r1", "r3")] = 129;
codigo[command("sub", "r1", "r4")] = 130;
codigo[command("sub", "r2", "r0")] = 131;
codigo[command("sub", "r2", "r1")] = 132;
codigo[command("sub", "r2", "r2")] = 133;
codigo[command("sub", "r2", "r3")] = 134;
codigo[command("sub", "r2", "r4")] = 135;
codigo[command("sub", "r3", "r0")] = 136;
codigo[command("sub", "r3", "r1")] = 137;
codigo[command("sub", "r3", "r2")] = 138;
codigo[command("sub", "r3", "r3")] = 139;
codigo[command("sub", "r3", "r4")] = 140;
codigo[command("sub", "r4", "r0")] = 141;
codigo[command("sub", "r4", "r1")] = 142;
codigo[command("sub", "r4", "r2")] = 143;
codigo[command("sub", "r4", "r3")] = 144;
codigo[command("sub", "r4", "r4")] = 145;
codigo[command("sub", "r0", "(r0)")] = 146;
codigo[command("sub", "r0", "(r1)")] = 147;
codigo[command("sub", "r0", "(r2)")] = 148;
codigo[command("sub", "r0", "(r3)")] = 149;
codigo[command("sub", "r0", "(r4)")] = 150;
codigo[command("sub", "r1", "(r0)")] = 151;
codigo[command("sub", "r1", "(r1)")] = 152;
codigo[command("sub", "r1", "(r2)")] = 153;
codigo[command("sub", "r1", "(r3)")] = 154;
codigo[command("sub", "r1", "(r4)")] = 155;
codigo[command("sub", "r2", "(r0)")] = 156;
codigo[command("sub", "r2", "(r1)")] = 157;
codigo[command("sub", "r2", "(r2)")] = 158;
codigo[command("sub", "r2", "(r3)")] = 159;
codigo[command("sub", "r2", "(r4)")] = 160;
codigo[command("sub", "r3", "(r0)")] = 161;
codigo[command("sub", "r3", "(r1)")] = 162;
codigo[command("sub", "r3", "(r2)")] = 163;
codigo[command("sub", "r3", "(r3)")] = 164;
codigo[command("sub", "r3", "(r4)")] = 165;
codigo[command("sub", "r4", "(r0)")] = 166;
codigo[command("sub", "r4", "(r1)")] = 167;
codigo[command("sub", "r4", "(r2)")] = 168;
codigo[command("sub", "r4", "(r3)")] = 169;
codigo[command("sub", "r4", "(r4)")] = 170;
codigo[command("sub", "(r0)", "r0")] = 171;
codigo[command("sub", "(r0)", "r1")] = 172;
codigo[command("sub", "(r0)", "r2")] = 173;
codigo[command("sub", "(r0)", "r3")] = 174;
codigo[command("sub", "(r0)", "r4")] = 175;
codigo[command("sub", "(r1)", "r0")] = 176;
codigo[command("sub", "(r1)", "r1")] = 177;
codigo[command("sub", "(r1)", "r2")] = 178;
codigo[command("sub", "(r1)", "r3")] = 179;
codigo[command("sub", "(r1)", "r4")] = 180;
codigo[command("sub", "(r2)", "r0")] = 181;
codigo[command("sub", "(r2)", "r1")] = 182;
codigo[command("sub", "(r2)", "r2")] = 183;
codigo[command("sub", "(r2)", "r3")] = 184;
codigo[command("sub", "(r2)", "r4")] = 185;
codigo[command("sub", "(r3)", "r0")] = 186;
codigo[command("sub", "(r3)", "r1")] = 187;
codigo[command("sub", "(r3)", "r2")] = 188;
codigo[command("sub", "(r3)", "r3")] = 189;
codigo[command("sub", "(r3)", "r4")] = 190;
codigo[command("sub", "(r4)", "r0")] = 191;
codigo[command("sub", "(r4)", "r1")] = 192;
codigo[command("sub", "(r4)", "r2")] = 193;
codigo[command("sub", "(r4)", "r3")] = 194;
codigo[command("sub", "(r4)", "r4")] = 195;
codigo[command("sub", "(r0)", "(r0)")] = 196;
codigo[command("sub", "(r0)", "(r1)")] = 197;
codigo[command("sub", "(r0)", "(r2)")] = 198;
codigo[command("sub", "(r0)", "(r3)")] = 199;
codigo[command("sub", "(r0)", "(r4)")] = 200;
codigo[command("sub", "(r1)", "(r0)")] = 201;
codigo[command("sub", "(r1)", "(r1)")] = 202;
codigo[command("sub", "(r1)", "(r2)")] = 203;
codigo[command("sub", "(r1)", "(r3)")] = 204;
codigo[command("sub", "(r1)", "(r4)")] = 205;
codigo[command("sub", "(r2)", "(r0)")] = 206;
codigo[command("sub", "(r2)", "(r1)")] = 207;
codigo[command("sub", "(r2)", "(r2)")] = 208;
codigo[command("sub", "(r2)", "(r3)")] = 209;
codigo[command("sub", "(r2)", "(r4)")] = 210;
codigo[command("sub", "(r3)", "(r0)")] = 211;
codigo[command("sub", "(r3)", "(r1)")] = 212;
codigo[command("sub", "(r3)", "(r2)")] = 213;
codigo[command("sub", "(r3)", "(r3)")] = 214;
codigo[command("sub", "(r3)", "(r4)")] = 215;
codigo[command("sub", "(r4)", "(r0)")] = 216;
codigo[command("sub", "(r4)", "(r1)")] = 217;
codigo[command("sub", "(r4)", "(r2)")] = 218;
codigo[command("sub", "(r4)", "(r3)")] = 219;
codigo[command("sub", "(r4)", "(r4)")] = 220;
codigo[command("mov", "#const", "r0")] = 221;
codigo[command("mov", "#const", "r1")] = 222;
codigo[command("mov", "#const", "r2")] = 223;
codigo[command("mov", "#const", "r3")] = 224;
codigo[command("mov", "#const", "r4")] = 225;
codigo[command("mov", "#const", "(r0)")] = 226;
codigo[command("mov", "#const", "(r1)")] = 227;
codigo[command("mov", "#const", "(r2)")] = 228;
codigo[command("mov", "#const", "(r3)")] = 229;
codigo[command("mov", "#const", "(r4)")] = 230;
codigo[command("mov", "r0", "r0")] = 231;
codigo[command("mov", "r0", "r1")] = 232;
codigo[command("mov", "r0", "r2")] = 233;
codigo[command("mov", "r0", "r3")] = 234;
codigo[command("mov", "r0", "r4")] = 235;
codigo[command("mov", "r1", "r0")] = 236;
codigo[command("mov", "r1", "r1")] = 237;
codigo[command("mov", "r1", "r2")] = 238;
codigo[command("mov", "r1", "r3")] = 239;
codigo[command("mov", "r1", "r4")] = 240;
codigo[command("mov", "r2", "r0")] = 241;
codigo[command("mov", "r2", "r1")] = 242;
codigo[command("mov", "r2", "r2")] = 243;
codigo[command("mov", "r2", "r3")] = 244;
codigo[command("mov", "r2", "r4")] = 245;
codigo[command("mov", "r3", "r0")] = 246;
codigo[command("mov", "r3", "r1")] = 247;
codigo[command("mov", "r3", "r2")] = 248;
codigo[command("mov", "r3", "r3")] = 249;
codigo[command("mov", "r3", "r4")] = 250;
codigo[command("mov", "r4", "r0")] = 251;
codigo[command("mov", "r4", "r1")] = 252;
codigo[command("mov", "r4", "r2")] = 253;
codigo[command("mov", "r4", "r3")] = 254;
codigo[command("mov", "r4", "r4")] = 255;
codigo[command("mov", "r0", "(r0)")] = 256;
codigo[command("mov", "r0", "(r1)")] = 257;
codigo[command("mov", "r0", "(r2)")] = 258;
codigo[command("mov", "r0", "(r3)")] = 259;
codigo[command("mov", "r0", "(r4)")] = 260;
codigo[command("mov", "r1", "(r0)")] = 261;
codigo[command("mov", "r1", "(r1)")] = 262;
codigo[command("mov", "r1", "(r2)")] = 263;
codigo[command("mov", "r1", "(r3)")] = 264;
codigo[command("mov", "r1", "(r4)")] = 265;
codigo[command("mov", "r2", "(r0)")] = 266;
codigo[command("mov", "r2", "(r1)")] = 267;
codigo[command("mov", "r2", "(r2)")] = 268;
codigo[command("mov", "r2", "(r3)")] = 269;
codigo[command("mov", "r2", "(r4)")] = 270;
codigo[command("mov", "r3", "(r0)")] = 271;
codigo[command("mov", "r3", "(r1)")] = 272;
codigo[command("mov", "r3", "(r2)")] = 273;
codigo[command("mov", "r3", "(r3)")] = 274;
codigo[command("mov", "r3", "(r4)")] = 275;
codigo[command("mov", "r4", "(r0)")] = 276;
codigo[command("mov", "r4", "(r1)")] = 277;
codigo[command("mov", "r4", "(r2)")] = 278;
codigo[command("mov", "r4", "(r3)")] = 279;
codigo[command("mov", "r4", "(r4)")] = 280;
codigo[command("mov", "(r0)", "r0")] = 281;
codigo[command("mov", "(r0)", "r1")] = 282;
codigo[command("mov", "(r0)", "r2")] = 283;
codigo[command("mov", "(r0)", "r3")] = 284;
codigo[command("mov", "(r0)", "r4")] = 285;
codigo[command("mov", "(r1)", "r0")] = 286;
codigo[command("mov", "(r1)", "r1")] = 287;
codigo[command("mov", "(r1)", "r2")] = 288;
codigo[command("mov", "(r1)", "r3")] = 289;
codigo[command("mov", "(r1)", "r4")] = 290;
codigo[command("mov", "(r2)", "r0")] = 291;
codigo[command("mov", "(r2)", "r1")] = 292;
codigo[command("mov", "(r2)", "r2")] = 293;
codigo[command("mov", "(r2)", "r3")] = 294;
codigo[command("mov", "(r2)", "r4")] = 295;
codigo[command("mov", "(r3)", "r0")] = 296;
codigo[command("mov", "(r3)", "r1")] = 297;
codigo[command("mov", "(r3)", "r2")] = 298;
codigo[command("mov", "(r3)", "r3")] = 299;
codigo[command("mov", "(r3)", "r4")] = 300;
codigo[command("mov", "(r4)", "r0")] = 301;
codigo[command("mov", "(r4)", "r1")] = 302;
codigo[command("mov", "(r4)", "r2")] = 303;
codigo[command("mov", "(r4)", "r3")] = 304;
codigo[command("mov", "(r4)", "r4")] = 305;
codigo[command("mov", "(r0)", "(r0)")] = 306;
codigo[command("mov", "(r0)", "(r1)")] = 307;
codigo[command("mov", "(r0)", "(r2)")] = 308;
codigo[command("mov", "(r0)", "(r3)")] = 309;
codigo[command("mov", "(r0)", "(r4)")] = 310;
codigo[command("mov", "(r1)", "(r0)")] = 311;
codigo[command("mov", "(r1)", "(r1)")] = 312;
codigo[command("mov", "(r1)", "(r2)")] = 313;
codigo[command("mov", "(r1)", "(r3)")] = 314;
codigo[command("mov", "(r1)", "(r4)")] = 315;
codigo[command("mov", "(r2)", "(r0)")] = 316;
codigo[command("mov", "(r2)", "(r1)")] = 317;
codigo[command("mov", "(r2)", "(r2)")] = 318;
codigo[command("mov", "(r2)", "(r3)")] = 319;
codigo[command("mov", "(r2)", "(r4)")] = 320;
codigo[command("mov", "(r3)", "(r0)")] = 321;
codigo[command("mov", "(r3)", "(r1)")] = 322;
codigo[command("mov", "(r3)", "(r2)")] = 323;
codigo[command("mov", "(r3)", "(r3)")] = 324;
codigo[command("mov", "(r3)", "(r4)")] = 325;
codigo[command("mov", "(r4)", "(r0)")] = 326;
codigo[command("mov", "(r4)", "(r1)")] = 327;
codigo[command("mov", "(r4)", "(r2)")] = 328;
codigo[command("mov", "(r4)", "(r3)")] = 329;
codigo[command("mov", "(r4)", "(r4)")] = 330;
codigo[command("cmp", "#const", "r0")] = 331;
codigo[command("cmp", "#const", "r1")] = 332;
codigo[command("cmp", "#const", "r2")] = 333;
codigo[command("cmp", "#const", "r3")] = 334;
codigo[command("cmp", "#const", "r4")] = 335;
codigo[command("cmp", "#const", "(r0)")] = 336;
codigo[command("cmp", "#const", "(r1)")] = 337;
codigo[command("cmp", "#const", "(r2)")] = 338;
codigo[command("cmp", "#const", "(r3)")] = 339;
codigo[command("cmp", "#const", "(r4)")] = 340;
codigo[command("cmp", "r0", "r0")] = 341;
codigo[command("cmp", "r0", "r1")] = 342;
codigo[command("cmp", "r0", "r2")] = 343;
codigo[command("cmp", "r0", "r3")] = 344;
codigo[command("cmp", "r0", "r4")] = 345;
codigo[command("cmp", "r1", "r0")] = 346;
codigo[command("cmp", "r1", "r1")] = 347;
codigo[command("cmp", "r1", "r2")] = 348;
codigo[command("cmp", "r1", "r3")] = 349;
codigo[command("cmp", "r1", "r4")] = 350;
codigo[command("cmp", "r2", "r0")] = 351;
codigo[command("cmp", "r2", "r1")] = 352;
codigo[command("cmp", "r2", "r2")] = 353;
codigo[command("cmp", "r2", "r3")] = 354;
codigo[command("cmp", "r2", "r4")] = 355;
codigo[command("cmp", "r3", "r0")] = 356;
codigo[command("cmp", "r3", "r1")] = 357;
codigo[command("cmp", "r3", "r2")] = 358;
codigo[command("cmp", "r3", "r3")] = 359;
codigo[command("cmp", "r3", "r4")] = 360;
codigo[command("cmp", "r4", "r0")] = 361;
codigo[command("cmp", "r4", "r1")] = 362;
codigo[command("cmp", "r4", "r2")] = 363;
codigo[command("cmp", "r4", "r3")] = 364;
codigo[command("cmp", "r4", "r4")] = 365;
codigo[command("cmp", "r0", "(r0)")] = 366;
codigo[command("cmp", "r0", "(r1)")] = 367;
codigo[command("cmp", "r0", "(r2)")] = 368;
codigo[command("cmp", "r0", "(r3)")] = 369;
codigo[command("cmp", "r0", "(r4)")] = 370;
codigo[command("cmp", "r1", "(r0)")] = 371;
codigo[command("cmp", "r1", "(r1)")] = 372;
codigo[command("cmp", "r1", "(r2)")] = 373;
codigo[command("cmp", "r1", "(r3)")] = 374;
codigo[command("cmp", "r1", "(r4)")] = 375;
codigo[command("cmp", "r2", "(r0)")] = 376;
codigo[command("cmp", "r2", "(r1)")] = 377;
codigo[command("cmp", "r2", "(r2)")] = 378;
codigo[command("cmp", "r2", "(r3)")] = 379;
codigo[command("cmp", "r2", "(r4)")] = 380;
codigo[command("cmp", "r3", "(r0)")] = 381;
codigo[command("cmp", "r3", "(r1)")] = 382;
codigo[command("cmp", "r3", "(r2)")] = 383;
codigo[command("cmp", "r3", "(r3)")] = 384;
codigo[command("cmp", "r3", "(r4)")] = 385;
codigo[command("cmp", "r4", "(r0)")] = 386;
codigo[command("cmp", "r4", "(r1)")] = 387;
codigo[command("cmp", "r4", "(r2)")] = 388;
codigo[command("cmp", "r4", "(r3)")] = 389;
codigo[command("cmp", "r4", "(r4)")] = 390;
codigo[command("cmp", "(r0)", "r0")] = 391;
codigo[command("cmp", "(r0)", "r1")] = 392;
codigo[command("cmp", "(r0)", "r2")] = 393;
codigo[command("cmp", "(r0)", "r3")] = 394;
codigo[command("cmp", "(r0)", "r4")] = 395;
codigo[command("cmp", "(r1)", "r0")] = 396;
codigo[command("cmp", "(r1)", "r1")] = 397;
codigo[command("cmp", "(r1)", "r2")] = 398;
codigo[command("cmp", "(r1)", "r3")] = 399;
codigo[command("cmp", "(r1)", "r4")] = 400;
codigo[command("cmp", "(r2)", "r0")] = 401;
codigo[command("cmp", "(r2)", "r1")] = 402;
codigo[command("cmp", "(r2)", "r2")] = 403;
codigo[command("cmp", "(r2)", "r3")] = 404;
codigo[command("cmp", "(r2)", "r4")] = 405;
codigo[command("cmp", "(r3)", "r0")] = 406;
codigo[command("cmp", "(r3)", "r1")] = 407;
codigo[command("cmp", "(r3)", "r2")] = 408;
codigo[command("cmp", "(r3)", "r3")] = 409;
codigo[command("cmp", "(r3)", "r4")] = 410;
codigo[command("cmp", "(r4)", "r0")] = 411;
codigo[command("cmp", "(r4)", "r1")] = 412;
codigo[command("cmp", "(r4)", "r2")] = 413;
codigo[command("cmp", "(r4)", "r3")] = 414;
codigo[command("cmp", "(r4)", "r4")] = 415;
codigo[command("cmp", "(r0)", "(r0)")] = 416;
codigo[command("cmp", "(r0)", "(r1)")] = 417;
codigo[command("cmp", "(r0)", "(r2)")] = 418;
codigo[command("cmp", "(r0)", "(r3)")] = 419;
codigo[command("cmp", "(r0)", "(r4)")] = 420;
codigo[command("cmp", "(r1)", "(r0)")] = 421;
codigo[command("cmp", "(r1)", "(r1)")] = 422;
codigo[command("cmp", "(r1)", "(r2)")] = 423;
codigo[command("cmp", "(r1)", "(r3)")] = 424;
codigo[command("cmp", "(r1)", "(r4)")] = 425;
codigo[command("cmp", "(r2)", "(r0)")] = 426;
codigo[command("cmp", "(r2)", "(r1)")] = 427;
codigo[command("cmp", "(r2)", "(r2)")] = 428;
codigo[command("cmp", "(r2)", "(r3)")] = 429;
codigo[command("cmp", "(r2)", "(r4)")] = 430;
codigo[command("cmp", "(r3)", "(r0)")] = 431;
codigo[command("cmp", "(r3)", "(r1)")] = 432;
codigo[command("cmp", "(r3)", "(r2)")] = 433;
codigo[command("cmp", "(r3)", "(r3)")] = 434;
codigo[command("cmp", "(r3)", "(r4)")] = 435;
codigo[command("cmp", "(r4)", "(r0)")] = 436;
codigo[command("cmp", "(r4)", "(r1)")] = 437;
codigo[command("cmp", "(r4)", "(r2)")] = 438;
codigo[command("cmp", "(r4)", "(r3)")] = 439;
codigo[command("cmp", "(r4)", "(r4)")] = 440;
codigo[command("and", "#const", "r0")] = 441;
codigo[command("and", "#const", "r1")] = 442;
codigo[command("and", "#const", "r2")] = 443;
codigo[command("and", "#const", "r3")] = 444;
codigo[command("and", "#const", "r4")] = 445;
codigo[command("and", "#const", "(r0)")] = 446;
codigo[command("and", "#const", "(r1)")] = 447;
codigo[command("and", "#const", "(r2)")] = 448;
codigo[command("and", "#const", "(r3)")] = 449;
codigo[command("and", "#const", "(r4)")] = 450;
codigo[command("and", "r0", "r0")] = 451;
codigo[command("and", "r0", "r1")] = 452;
codigo[command("and", "r0", "r2")] = 453;
codigo[command("and", "r0", "r3")] = 454;
codigo[command("and", "r0", "r4")] = 455;
codigo[command("and", "r1", "r0")] = 456;
codigo[command("and", "r1", "r1")] = 457;
codigo[command("and", "r1", "r2")] = 458;
codigo[command("and", "r1", "r3")] = 459;
codigo[command("and", "r1", "r4")] = 460;
codigo[command("and", "r2", "r0")] = 461;
codigo[command("and", "r2", "r1")] = 462;
codigo[command("and", "r2", "r2")] = 463;
codigo[command("and", "r2", "r3")] = 464;
codigo[command("and", "r2", "r4")] = 465;
codigo[command("and", "r3", "r0")] = 466;
codigo[command("and", "r3", "r1")] = 467;
codigo[command("and", "r3", "r2")] = 468;
codigo[command("and", "r3", "r3")] = 469;
codigo[command("and", "r3", "r4")] = 470;
codigo[command("and", "r4", "r0")] = 471;
codigo[command("and", "r4", "r1")] = 472;
codigo[command("and", "r4", "r2")] = 473;
codigo[command("and", "r4", "r3")] = 474;
codigo[command("and", "r4", "r4")] = 475;
codigo[command("and", "r0", "(r0)")] = 476;
codigo[command("and", "r0", "(r1)")] = 477;
codigo[command("and", "r0", "(r2)")] = 478;
codigo[command("and", "r0", "(r3)")] = 479;
codigo[command("and", "r0", "(r4)")] = 480;
codigo[command("and", "r1", "(r0)")] = 481;
codigo[command("and", "r1", "(r1)")] = 482;
codigo[command("and", "r1", "(r2)")] = 483;
codigo[command("and", "r1", "(r3)")] = 484;
codigo[command("and", "r1", "(r4)")] = 485;
codigo[command("and", "r2", "(r0)")] = 486;
codigo[command("and", "r2", "(r1)")] = 487;
codigo[command("and", "r2", "(r2)")] = 488;
codigo[command("and", "r2", "(r3)")] = 489;
codigo[command("and", "r2", "(r4)")] = 490;
codigo[command("and", "r3", "(r0)")] = 491;
codigo[command("and", "r3", "(r1)")] = 492;
codigo[command("and", "r3", "(r2)")] = 493;
codigo[command("and", "r3", "(r3)")] = 494;
codigo[command("and", "r3", "(r4)")] = 495;
codigo[command("and", "r4", "(r0)")] = 496;
codigo[command("and", "r4", "(r1)")] = 497;
codigo[command("and", "r4", "(r2)")] = 498;
codigo[command("and", "r4", "(r3)")] = 499;
codigo[command("and", "r4", "(r4)")] = 500;
codigo[command("and", "(r0)", "r0")] = 501;
codigo[command("and", "(r0)", "r1")] = 502;
codigo[command("and", "(r0)", "r2")] = 503;
codigo[command("and", "(r0)", "r3")] = 504;
codigo[command("and", "(r0)", "r4")] = 505;
codigo[command("and", "(r1)", "r0")] = 506;
codigo[command("and", "(r1)", "r1")] = 507;
codigo[command("and", "(r1)", "r2")] = 508;
codigo[command("and", "(r1)", "r3")] = 509;
codigo[command("and", "(r1)", "r4")] = 510;
codigo[command("and", "(r2)", "r0")] = 511;
codigo[command("and", "(r2)", "r1")] = 512;
codigo[command("and", "(r2)", "r2")] = 513;
codigo[command("and", "(r2)", "r3")] = 514;
codigo[command("and", "(r2)", "r4")] = 515;
codigo[command("and", "(r3)", "r0")] = 516;
codigo[command("and", "(r3)", "r1")] = 517;
codigo[command("and", "(r3)", "r2")] = 518;
codigo[command("and", "(r3)", "r3")] = 519;
codigo[command("and", "(r3)", "r4")] = 520;
codigo[command("and", "(r4)", "r0")] = 521;
codigo[command("and", "(r4)", "r1")] = 522;
codigo[command("and", "(r4)", "r2")] = 523;
codigo[command("and", "(r4)", "r3")] = 524;
codigo[command("and", "(r4)", "r4")] = 525;
codigo[command("and", "(r0)", "(r0)")] = 526;
codigo[command("and", "(r0)", "(r1)")] = 527;
codigo[command("and", "(r0)", "(r2)")] = 528;
codigo[command("and", "(r0)", "(r3)")] = 529;
codigo[command("and", "(r0)", "(r4)")] = 530;
codigo[command("and", "(r1)", "(r0)")] = 531;
codigo[command("and", "(r1)", "(r1)")] = 532;
codigo[command("and", "(r1)", "(r2)")] = 533;
codigo[command("and", "(r1)", "(r3)")] = 534;
codigo[command("and", "(r1)", "(r4)")] = 535;
codigo[command("and", "(r2)", "(r0)")] = 536;
codigo[command("and", "(r2)", "(r1)")] = 537;
codigo[command("and", "(r2)", "(r2)")] = 538;
codigo[command("and", "(r2)", "(r3)")] = 539;
codigo[command("and", "(r2)", "(r4)")] = 540;
codigo[command("and", "(r3)", "(r0)")] = 541;
codigo[command("and", "(r3)", "(r1)")] = 542;
codigo[command("and", "(r3)", "(r2)")] = 543;
codigo[command("and", "(r3)", "(r3)")] = 544;
codigo[command("and", "(r3)", "(r4)")] = 545;
codigo[command("and", "(r4)", "(r0)")] = 546;
codigo[command("and", "(r4)", "(r1)")] = 547;
codigo[command("and", "(r4)", "(r2)")] = 548;
codigo[command("and", "(r4)", "(r3)")] = 549;
codigo[command("and", "(r4)", "(r4)")] = 550;
codigo[command("or", "#const", "r0")] = 551;
codigo[command("or", "#const", "r1")] = 552;
codigo[command("or", "#const", "r2")] = 553;
codigo[command("or", "#const", "r3")] = 554;
codigo[command("or", "#const", "r4")] = 555;
codigo[command("or", "#const", "(r0)")] = 556;
codigo[command("or", "#const", "(r1)")] = 557;
codigo[command("or", "#const", "(r2)")] = 558;
codigo[command("or", "#const", "(r3)")] = 559;
codigo[command("or", "#const", "(r4)")] = 560;
codigo[command("or", "r0", "r0")] = 561;
codigo[command("or", "r0", "r1")] = 562;
codigo[command("or", "r0", "r2")] = 563;
codigo[command("or", "r0", "r3")] = 564;
codigo[command("or", "r0", "r4")] = 565;
codigo[command("or", "r1", "r0")] = 566;
codigo[command("or", "r1", "r1")] = 567;
codigo[command("or", "r1", "r2")] = 568;
codigo[command("or", "r1", "r3")] = 569;
codigo[command("or", "r1", "r4")] = 570;
codigo[command("or", "r2", "r0")] = 571;
codigo[command("or", "r2", "r1")] = 572;
codigo[command("or", "r2", "r2")] = 573;
codigo[command("or", "r2", "r3")] = 574;
codigo[command("or", "r2", "r4")] = 575;
codigo[command("or", "r3", "r0")] = 576;
codigo[command("or", "r3", "r1")] = 577;
codigo[command("or", "r3", "r2")] = 578;
codigo[command("or", "r3", "r3")] = 579;
codigo[command("or", "r3", "r4")] = 580;
codigo[command("or", "r4", "r0")] = 581;
codigo[command("or", "r4", "r1")] = 582;
codigo[command("or", "r4", "r2")] = 583;
codigo[command("or", "r4", "r3")] = 584;
codigo[command("or", "r4", "r4")] = 585;
codigo[command("or", "r0", "(r0)")] = 586;
codigo[command("or", "r0", "(r1)")] = 587;
codigo[command("or", "r0", "(r2)")] = 588;
codigo[command("or", "r0", "(r3)")] = 589;
codigo[command("or", "r0", "(r4)")] = 590;
codigo[command("or", "r1", "(r0)")] = 591;
codigo[command("or", "r1", "(r1)")] = 592;
codigo[command("or", "r1", "(r2)")] = 593;
codigo[command("or", "r1", "(r3)")] = 594;
codigo[command("or", "r1", "(r4)")] = 595;
codigo[command("or", "r2", "(r0)")] = 596;
codigo[command("or", "r2", "(r1)")] = 597;
codigo[command("or", "r2", "(r2)")] = 598;
codigo[command("or", "r2", "(r3)")] = 599;
codigo[command("or", "r2", "(r4)")] = 600;
codigo[command("or", "r3", "(r0)")] = 601;
codigo[command("or", "r3", "(r1)")] = 602;
codigo[command("or", "r3", "(r2)")] = 603;
codigo[command("or", "r3", "(r3)")] = 604;
codigo[command("or", "r3", "(r4)")] = 605;
codigo[command("or", "r4", "(r0)")] = 606;
codigo[command("or", "r4", "(r1)")] = 607;
codigo[command("or", "r4", "(r2)")] = 608;
codigo[command("or", "r4", "(r3)")] = 609;
codigo[command("or", "r4", "(r4)")] = 610;
codigo[command("or", "(r0)", "r0")] = 611;
codigo[command("or", "(r0)", "r1")] = 612;
codigo[command("or", "(r0)", "r2")] = 613;
codigo[command("or", "(r0)", "r3")] = 614;
codigo[command("or", "(r0)", "r4")] = 615;
codigo[command("or", "(r1)", "r0")] = 616;
codigo[command("or", "(r1)", "r1")] = 617;
codigo[command("or", "(r1)", "r2")] = 618;
codigo[command("or", "(r1)", "r3")] = 619;
codigo[command("or", "(r1)", "r4")] = 620;
codigo[command("or", "(r2)", "r0")] = 621;
codigo[command("or", "(r2)", "r1")] = 622;
codigo[command("or", "(r2)", "r2")] = 623;
codigo[command("or", "(r2)", "r3")] = 624;
codigo[command("or", "(r2)", "r4")] = 625;
codigo[command("or", "(r3)", "r0")] = 626;
codigo[command("or", "(r3)", "r1")] = 627;
codigo[command("or", "(r3)", "r2")] = 628;
codigo[command("or", "(r3)", "r3")] = 629;
codigo[command("or", "(r3)", "r4")] = 630;
codigo[command("or", "(r4)", "r0")] = 631;
codigo[command("or", "(r4)", "r1")] = 632;
codigo[command("or", "(r4)", "r2")] = 633;
codigo[command("or", "(r4)", "r3")] = 634;
codigo[command("or", "(r4)", "r4")] = 635;
codigo[command("or", "(r0)", "(r0)")] = 636;
codigo[command("or", "(r0)", "(r1)")] = 637;
codigo[command("or", "(r0)", "(r2)")] = 638;
codigo[command("or", "(r0)", "(r3)")] = 639;
codigo[command("or", "(r0)", "(r4)")] = 640;
codigo[command("or", "(r1)", "(r0)")] = 641;
codigo[command("or", "(r1)", "(r1)")] = 642;
codigo[command("or", "(r1)", "(r2)")] = 643;
codigo[command("or", "(r1)", "(r3)")] = 644;
codigo[command("or", "(r1)", "(r4)")] = 645;
codigo[command("or", "(r2)", "(r0)")] = 646;
codigo[command("or", "(r2)", "(r1)")] = 647;
codigo[command("or", "(r2)", "(r2)")] = 648;
codigo[command("or", "(r2)", "(r3)")] = 649;
codigo[command("or", "(r2)", "(r4)")] = 650;
codigo[command("or", "(r3)", "(r0)")] = 651;
codigo[command("or", "(r3)", "(r1)")] = 652;
codigo[command("or", "(r3)", "(r2)")] = 653;
codigo[command("or", "(r3)", "(r3)")] = 654;
codigo[command("or", "(r3)", "(r4)")] = 655;
codigo[command("or", "(r4)", "(r0)")] = 656;
codigo[command("or", "(r4)", "(r1)")] = 657;
codigo[command("or", "(r4)", "(r2)")] = 658;
codigo[command("or", "(r4)", "(r3)")] = 659;
codigo[command("or", "(r4)", "(r4)")] = 660;
codigo[command("not", "r0")] = 661;
codigo[command("not", "r1")] = 662;
codigo[command("not", "r2")] = 663;
codigo[command("not", "r3")] = 664;
codigo[command("not", "r4")] = 665;
codigo[command("not", "(r0)")] = 666;
codigo[command("not", "(r1)")] = 667;
codigo[command("not", "(r2)")] = 668;
codigo[command("not", "(r3)")] = 669;
codigo[command("not", "(r4)")] = 670;
codigo[command("clr", "r0")] = 671;
codigo[command("clr", "r1")] = 672;
codigo[command("clr", "r2")] = 673;
codigo[command("clr", "r3")] = 674;
codigo[command("clr", "r4")] = 675;
codigo[command("clr", "(r0)")] = 676;
codigo[command("clr", "(r1)")] = 677;
codigo[command("clr", "(r2)")] = 678;
codigo[command("clr", "(r3)")] = 679;
codigo[command("clr", "(r4)")] = 680;
codigo[command("neg", "r0")] = 681;
codigo[command("neg", "r1")] = 682;
codigo[command("neg", "r2")] = 683;
codigo[command("neg", "r3")] = 684;
codigo[command("neg", "r4")] = 685;
codigo[command("neg", "(r0)")] = 686;
codigo[command("neg", "(r1)")] = 687;
codigo[command("neg", "(r2)")] = 688;
codigo[command("neg", "(r3)")] = 689;
codigo[command("neg", "(r4)")] = 690;
codigo[command("sh", "l", "r0")] = 691;
codigo[command("sh", "l", "r1")] = 692;
codigo[command("sh", "l", "r2")] = 693;
codigo[command("sh", "l", "r3")] = 694;
codigo[command("sh", "l", "r4")] = 695;
codigo[command("sh", "l", "(r0)")] = 696;
codigo[command("sh", "l", "(r1)")] = 697;
codigo[command("sh", "l", "(r2)")] = 698;
codigo[command("sh", "l", "(r3)")] = 699;
codigo[command("sh", "l", "(r4)")] = 700;
codigo[command("sh", "r", "r0")] = 701;
codigo[command("sh", "r", "r1")] = 702;
codigo[command("sh", "r", "r2")] = 703;
codigo[command("sh", "r", "r3")] = 704;
codigo[command("sh", "r", "r4")] = 705;
codigo[command("sh", "r", "(r0)")] = 706;
codigo[command("sh", "r", "(r1)")] = 707;
codigo[command("sh", "r", "(r2)")] = 708;
codigo[command("sh", "r", "(r3)")] = 709;
codigo[command("sh", "r", "(r4)")] = 710;
codigo[command("shl", "r0")] = 691;
codigo[command("shl", "r1")] = 692;
codigo[command("shl", "r2")] = 693;
codigo[command("shl", "r3")] = 694;
codigo[command("shl", "r4")] = 695;
codigo[command("shl", "(r0)")] = 696;
codigo[command("shl", "(r1)")] = 697;
codigo[command("shl", "(r2)")] = 698;
codigo[command("shl", "(r3)")] = 699;
codigo[command("shl", "(r4)")] = 700;
codigo[command("shr", "r0")] = 701;
codigo[command("shr", "r1")] = 702;
codigo[command("shr", "r2")] = 703;
codigo[command("shr", "r3")] = 704;
codigo[command("shr", "r4")] = 705;
codigo[command("shr", "(r0)")] = 706;
codigo[command("shr", "(r1)")] = 707;
codigo[command("shr", "(r2)")] = 708;
codigo[command("shr", "(r3)")] = 709;
codigo[command("shr", "(r4)")] = 710;
codigo[command("br", "z", "#label")] = 711;
codigo[command("br", "n", "#label")] = 712;
codigo[command("br", "e", "#label")] = 713;
codigo[command("br", "l", "#label")] = 714;
codigo[command("br", "g", "#label")] = 715;
codigo[command("br", "c", "#label")] = 716;
codigo[command("brz", "#label")] = 711;
codigo[command("brn", "#label")] = 712;
codigo[command("bre", "#label")] = 713;
codigo[command("brl", "#label")] = 714;
codigo[command("brg", "#label")] = 715;
codigo[command("brc", "#label")] = 716;
codigo[command("jmp", "#label")] = 717;
codigo[command("halt")] = 718;
codigo[command("inc", "r0")] = 719;
codigo[command("inc", "r1")] = 720;
codigo[command("inc", "r2")] = 721;
codigo[command("inc", "r3")] = 722;
codigo[command("inc", "r4")] = 723;
codigo[command("dec", "r0")] = 724;
codigo[command("dec", "r1")] = 725;
codigo[command("dec", "r2")] = 726;
codigo[command("dec", "r3")] = 727;
codigo[command("dec", "r4")] = 728;
codigo[command("inc", "(r0)")] = 729;
codigo[command("inc", "(r1)")] = 730;
codigo[command("inc", "(r2)")] = 731;
codigo[command("inc", "(r3)")] = 732;
codigo[command("inc", "(r4)")] = 733;
codigo[command("dec", "(r0)")] = 734;
codigo[command("dec", "(r1)")] = 735;
codigo[command("dec", "(r2)")] = 736;
codigo[command("dec", "(r3)")] = 737;
codigo[command("dec", "(r4)")] = 738;
}
// Carrega os comandos do assembly na memória.
void Parser::parse (void)
{
// Vão receber as strings na entrada. São muito grandes porque eu sou neurótico.
char comando[2048];
char fonte[1024], destino[1024];
// Vão ser usadas para acessar os maps, fazer comparações entre outros. Substituem os char pointers.
string cmm, src, dst;
// Ajudarão com as labels.
map<string,int> label_to_come;
vector<int> pos[MAX_LABELS];
fscanf (entrada, " %s", comando);
while (!feof(entrada))
{
// Testa se o que foi lido é o começo de um comentário. Se for ignora tudo até o fim da linha.
if (comando[0] == '#')
{
while (getc(entrada) != '\n' && !feof(entrada));
fscanf (entrada, " %s", comando);
continue;
}
// Testa se o que foi lido é uma label. Se for coloca a label no map e tenta ler um comando.
if (comando[strlen(comando)-1] == ':')
{
comando[strlen(comando)-1] = '\0';
if (label.find(comando) != label.end())
{
for (int i = 0; i < (int) pos[label_to_come[comando]].size(); i++)
{
mem->acesso(true, pos[label_to_come[comando]][i], posAtual);
}
}
label[comando] = posAtual;
fscanf (entrada, " %s", comando);
continue;
}
cmm = comando;
for (int i = 0; i < (int) cmm.size(); i++) cmm[i] = tolower(cmm[i]); // Coloca o comando todo em lowercase.
// O if mais externo testa quantos operandos são esperados para a operação.
if (nop[cmm] == 2)
{
bool has_const = false; // Vai dizer se há um operando constante que deve ser colocado na memória.
int operando_constante; // Vai guardar o valor do operando constante a ser colocado na memória.
fscanf (entrada, " %s", fonte);
if (fonte[strlen(fonte) - 1] == ',')
{
fonte[strlen(fonte) - 1] = '\0';
fscanf (entrada, " %s", destino);
}
else
{
int i;
for (i = 0; fonte[i] != ','; i++);
fonte[i] = '\0';
sscanf (fonte + i + 1, " %s", destino);
}
src = fonte;
dst = destino;
// Testa se a fonte é uma constante. Se for seta o bool has_const e transforma src em #const para poder identificar a instrução.
if ((src[0] >= '0' && src[0] <= '9') || (src[0] == '-' && (src[1] >= '0' && src[1] <= '9')))
{
// Operando constante em hexadecimal ou em decimal.
if (src.find("0x") != string::npos)
{
sscanf (src.c_str(), "%x", &operando_constante);
}
else
{
sscanf (src.c_str(), "%d", &operando_constante);
}
src = "#const";
has_const = true;
}
// No caso da operação br é certo que há uma label como operando destino. Trata isso.
if (cmm == "br")
{
operando_constante = label[dst];
dst = "#label";
has_const = true;
}
for (int i = 0; i < (int) src.size(); i++) src[i] = tolower(src[i]); // Converte o operando fonte para lower case.
for (int i = 0; i < (int) dst.size(); i++) dst[i] = tolower(dst[i]); // Converte o operando destino para lower case.
mem->acesso(1, posAtual, codigo[command(cmm, src, dst)]); // Joga para a memória o código da operação.
// Se houver operando constante coloca na memória.
if (has_const)
{
posAtual++;
mem->acesso(1, posAtual, operando_constante);
}
}
else if (nop[cmm] == 1)
{
bool has_const = false; // Vai dizer se há um operando constante que deve ser colocado na memória.
int operando_constante; // Vai guardar o valor do operando constante a ser colocado na memória.
fscanf (entrada, " %s", fonte);
src = fonte;
// Trata labels no operando fonte.
if (cmm == "jmp" || cmm == "brz" || cmm == "brn" || cmm == "bre" || cmm == "brl" || cmm == "brg" || cmm == "brc")
{
if (label.find(src) == label.end() || (label.find(src) != label.end() && label[src] == -1))
{
label_to_come[src] = label_to_come.size();
label[src] = -1;
pos[label_to_come[src]].push_back(posAtual + 1);
}
operando_constante = label[src];
src = "#label";
has_const = true;
}
// Testa se a fonte é uma constante. Se for seta o bool has_const e transforma src em #const para poder identificar a instrução.
if ((src[0] >= '0' && src[0] <= '9') || (src[0] == '-' && (src[1] >= '0' && src[1] <= '9')))
{
// Operando constante em hexadecimal ou em decimal.
if (src.find("0x") != string::npos)
{
sscanf (src.c_str(), "%x", &operando_constante);
}
else
{
sscanf (src.c_str(), "%d", &operando_constante);
}
src = "#const";
has_const = true;
}
for (int i = 0; i < (int) src.size(); i++) src[i] = tolower(src[i]); // Converte o operando fonte para lower case.
mem->acesso(1, posAtual, codigo[command(cmm, src)]); // Joga para a memória o código da operação.
// Se houver operando constante coloca na memória.
if (has_const)
{
posAtual++;
mem->acesso(true, posAtual, operando_constante);
}
}
else
{
mem->acesso(true, posAtual, codigo[command(cmm)]); // Joga para a memória o código da operação.
}
posAtual++;
while (getc(entrada) != '\n' && !feof(entrada)); // Lê o que restar até o fim da linha.
fscanf (entrada, " %s", comando);
}
}
| [
"prosanes@d2cc51ec-644b-ba46-3315-dce07c01be90"
]
| [
[
[
1,
988
]
]
]
|
4d743f200e740cf3b8fed1947b92ab2e17148480 | b731c89fae7986809fae57045dca707948796c3a | /ocr/ocr/ConfigFile.cpp | db50091d2135c4be7d6bf1f9efdd0fa03e4e20ff | []
| no_license | hy1314200/ocr1 | 285a99251c8f03954afb6bee30521b6d9fb1c912 | 051b07224a4689c01315aea53050b0c936085f8c | refs/heads/master | 2016-09-07T23:57:04.680763 | 2008-06-07T21:51:08 | 2008-06-07T21:51:08 | 38,354,665 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,337 | cpp | #include "ConfigFile.h"
#include <fstream>
#include <sstream>
using namespace util;
ConfigFile *ConfigFile::parseConfig(const char *filePath) throw (string)
{
ifstream ifs(filePath);
if(!ifs){
stringstream ss;
ss << "ERROR: can not find config file \"" << filePath << "\"";
throw ss.str();
}
string temp, key, value;
string::size_type offset1, offset2, offset3;
int line = 0;
ConfigFile *config = new ConfigFile;
while(!ifs.eof()){
getline(ifs, temp);
++line; // begin with 1
if(temp.size() == 0){
continue;
}
offset1 = temp.find_first_not_of(" ");
if(offset1 == string::npos || temp[offset1] == '#'){
continue;
}
offset2 = temp.find_first_of("=");
if(offset1 == offset2){
stringstream ss;
ss << "ERROR: at line " << line << ": key should not be null";
throw ss.str();
}
if(offset2 == string::npos || temp.find_first_of("=", offset2+1) != string::npos){
stringstream ss;
ss << "ERROR: at line " << line << ": invalid format";
throw ss.str();
}
for(offset3 = offset2-1; offset3 >= offset1 && temp[offset3] == ' '; offset3--){ }
//offset3 = temp.find_last_not_of(" ", offset1, offset2 - offset1); // something wrong with unicode
key.assign(temp, offset1, offset3-offset1+1);
offset1 = temp.find_first_not_of(" ", offset2+1);
if(offset1 == string::npos){
stringstream ss;
ss << "ERROR: at line " << line << ": value should not be null";
throw ss.str();
}
for(offset2 = temp.size()-1; offset2 >= 0 && temp[offset2] == ' '; offset2--){ }
//offset2 = temp.find_last_not_of(" "); // something wrong with unicode
value.assign(temp, offset1, offset2-offset1+1);
if(config->put(key, value) == false){
stringstream ss;
ss << "ERROR: at line " << line << ": duplicated key \"" << key << "\"";
throw ss.str();
}
}
return config;
}
bool ConfigFile::put(string key, string value)
{
pair<map<string ,string>::iterator, bool> res;
res = m_config.insert(pair<string ,string>(key, value));
return res.second;
}
void ConfigFile::store(const char *filePath)
{
ofstream ofs(filePath);
for(map<string, string>::iterator itr = m_config.begin(); itr != m_config.end(); itr++){
ofs << itr->first << "=" << itr->second << endl;
}
} | [
"liuyi1985@8b243031-8947-0410-b39a-2b519deb81bd"
]
| [
[
[
1,
94
]
]
]
|
045998f7289f8f3d1acf549264a3d67c91d90ca3 | 01c236af2890d74ca5b7c25cec5e7b1686283c48 | /Src/TableInfoForm.h | 940438f9c53a441f11be891aa5e0f6b825d37dab | [
"MIT"
]
| permissive | muffinista/palm-pitch | 80c5900d4f623204d3b837172eefa09c4efbe5e3 | aa09c857b1ccc14672b3eb038a419bd13abc0925 | refs/heads/master | 2021-01-19T05:43:04.740676 | 2010-07-08T14:42:18 | 2010-07-08T14:42:18 | 763,958 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 884 | h | #ifndef TABLEINFOFORM_H_
#define TABLEINFOFORM_H_
class CTableInfoDialog : public CModalForm {
public:
// constructor
CTableInfoDialog() :
CModalForm(TableInfoForm)
{}
// Event handlers
Boolean OnOpenPost(EventPtr pEvent, Boolean& bHandled);
Boolean OnClose(EventType* pEvent, Boolean& bHandled);
Boolean OnOK(EventType* pEvent, Boolean& bHandled);
// Event map
BEGIN_EVENT_MAP(CModalForm)
EVENT_MAP_COMMAND_ENTRY(TableInfoOKButton, OnOK)
EVENT_MAP_ENTRY(frmCloseEvent, OnClose)
END_EVENT_MAP()
// Post-Event map
BEGIN_POST_EVENT_MAP(CModalForm)
POST_EVENT_MAP_ENTRY(frmOpenEvent, OnOpenPost)
END_POST_EVENT_MAP()
private:
CField ns_teamField;
CField ew_teamField;
CField scoreField;
CField dealerField;
CString ns_team;
CString ew_team;
char scorestr[10];
CString dealerstr;
};
#endif // ABOUTFORM_H_
| [
"[email protected]"
]
| [
[
[
1,
40
]
]
]
|
fa7376d6d1edeb7803e5384ef0446878efd73fe4 | 631072cb1b59533d921616b968e06590f0da64dc | /prevent/stdafx.cpp | 9ad3a5c494d061a18143656680b847ddb08bc8bb | []
| no_license | lloydpick/preVentrilo | 4065d8e4bc819a94716ff4b49b88b9e238437f5a | f212ba1cff67faa1f7c41b1a05fce36682f59b7c | refs/heads/master | 2021-01-15T12:25:57.822184 | 2010-09-06T17:03:20 | 2010-09-06T17:03:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 294 | cpp | // stdafx.cpp : source file that includes just the standard includes
// VentDLL.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| [
"[email protected]"
]
| [
[
[
1,
8
]
]
]
|
b91fe19fb8655c0afbd0730994038e522dc3c14e | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/branches/newton20/engine/ui/include/MainMenuEngineWindow.h | 8b923c4e08aa8a402dc914e2bba62fd8e150a90d | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
]
| permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389214 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,019 | h | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#ifndef __MainMenuEngineWindow_H__
#define __MainMenuEngineWindow_H__
#include "UiPrerequisites.h"
#include "AbstractWindow.h"
namespace rl {
class ContentModule;
class _RlUiExport MainMenuEngineWindow : public AbstractWindow
{
public:
MainMenuEngineWindow();
};
}
#endif
| [
"melven@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
34
]
]
]
|
6c7e2b59bd3f1892cea3af632c9946de94ed9ea9 | 94c1c7459eb5b2826e81ad2750019939f334afc8 | /source/hfiles/FileInOutData.h | 76809cc3be89a8f3c224e88088be9481ba397d04 | []
| no_license | wgwang/yinhustock | 1c57275b4bca093e344a430eeef59386e7439d15 | 382ed2c324a0a657ddef269ebfcd84634bd03c3a | refs/heads/master | 2021-01-15T17:07:15.833611 | 2010-11-27T07:06:40 | 2010-11-27T07:06:40 | 37,531,026 | 1 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 1,419 | h | // FileInOutData.h: interface for the FileInOutData class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_FILEINOUTDATA_H__54F8E6A1_7ECA_11D6_968D_B381BDAEB375__INCLUDED_)
#define AFX_FILEINOUTDATA_H__54F8E6A1_7ECA_11D6_968D_B381BDAEB375__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "IndicatorExtendData.h"
class AFX_EXT_CLASS FileInOutData
{
public:
static bool RemoveFiles(CString &sPath);
FileInOutData();
virtual ~FileInOutData();
static CArray<CString,CString&> m_stockSymbolArr;
static int m_stockSymbolTime;
void WriteSymbolFile(CString sFileName,CString& sArr,int time);
bool SetSymbolFile(CString sFileName);
bool ImportData(CString sFileName,CProgressCtrl* pCtrl);
bool ExportData(CStringArray& sFileName,int* pIndicatorExtendID,int nDays);
bool ExportData(CStringArray& sFileName,int* pIndicatorExtendID,CTime& tmBegin,CTime& tmEnd);
bool ExportRealMin5(CStringArray& sSymbol,float * fValue,int nIndicatorExtendID,int nRecord);
private:
static bool IsBrief(CString sFileName) ;
static InOutHeadData GetHead(CFile & fl);
static void SetHead(InOutHeadData& head,CFile & fl);
bool ExportData(CStringArray& sFileName,int* pIndicatorExtendID,int nDays,CTime* tmBegin,CTime* tmEnd);
};
#endif // !defined(AFX_FILEINOUTDATA_H__54F8E6A1_7ECA_11D6_968D_B381BDAEB375__INCLUDED_)
| [
"[email protected]"
]
| [
[
[
1,
37
]
]
]
|
49ab2ede03a3946a286999446ce10ab2449a3c2b | aa825896cc7c672140405ab51634d00d28fad09b | /zomgatron/Sprite.h | 12c98c0c173b9cbd4b573c0f04cc4198cef49bd3 | []
| no_license | kllrnohj/zomgatron | 856fa6693b924d629f166c82cdd4db7524f3255d | 099955f0ab84eb432ab87d351b8defd3123a8991 | refs/heads/master | 2021-01-10T08:26:13.826555 | 2009-01-27T17:21:45 | 2009-01-27T17:21:45 | 46,742,521 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 895 | h | #ifndef __SPRITE_H__
#define __SPRITE_H__
#include "DirectX.h"
#include "d3dx9.h"
#include <vector>
class Sprite{
protected:
bool draw;
void* image;
Quad* sourceRect;
Vector3 position;
public:
Sprite(char* file);
bool GetDraw() { return draw; }
void SetDraw(bool draw) { this->draw = draw; }
Quad* GetSourceRect() { return sourceRect; }
void SetSourceRect(Quad* sr) { sourceRect = sr; }
void SetSourceRect(int x, int y, int x2, int y2) { if(!sourceRect){sourceRect = new Quad();} sourceRect->left = x; sourceRect->top = y; sourceRect->right = x2; sourceRect->bottom = y2; }
Vector3 GetPosition() { return position; }
void SetPosition(Vector3 position) { this->position = position; }
void MoveUp(float val) { this->position.y -= val; }
void MoveRight(float val) { this->position.x += val; }
void* GetImage() { return image; }
};
#endif
| [
"Kivu.Rako@54144a58-e977-11dd-a550-c997509ed985"
]
| [
[
[
1,
35
]
]
]
|
f3398f5dda78d9be8522a17d74d460dc966b8b31 | 59ce53af7ad5a1f9b12a69aadbfc7abc4c4bfc02 | /publish/skinxmldialog.h | 2179fab98f61b41611a92557a95c455fabe06fcd | []
| no_license | fingomajom/skinengine | 444a89955046a6f2c7be49012ff501dc465f019e | 6bb26a46a7edac88b613ea9a124abeb8a1694868 | refs/heads/master | 2021-01-10T11:30:51.541442 | 2008-07-30T07:13:11 | 2008-07-30T07:13:11 | 47,892,418 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,685 | h | /********************************************************************
* CreatedOn: 2007-12-17 17:08
* FileName: skinxmldialog.h
* CreatedBy: lidengwang <[email protected]>
* $LastChangedDate$
* $LastChangedRevision$
* $LastChangedBy$
* $HeadURL: $
* Purpose:
*********************************************************************/
#pragma once
#include <skinxmlwin.h>
#include <atldlgs.h>
namespace KSGUI{
class skinxmldialog : public skinxmlwin
{
public:
static LPCTSTR GetChildWinKeyName() { return _T("ChildWindow"); }
public:
class enumchildwincallback
{
public:
virtual BOOL onchildwin( skinxmlwin& ) = 0;
};
public:
skinxmldialog(const SkinXmlElement& xmlElement = SkinXmlElement()) :
skinxmlwin(xmlElement)
{
}
const skinxmldialog& operator = (const SkinXmlElement& xmlElement)
{
m_xmlResElement = xmlElement;
return *this;
}
BOOL EnumChildWindows( enumchildwincallback * pcallback )
{
if (!m_xmlResElement.IsValid() || pcallback == NULL )
return FALSE;
SkinXmlElement childnode = m_xmlResElement.FirstChildElement( GetChildWinKeyName() );
if (!childnode.IsValid())
return FALSE;
SkinXmlElement childwinnode = childnode.FirstChildElement();
while ( childwinnode.IsValid() )
{
skinxmlwin win;
win.AttachXmlElement(childwinnode);
pcallback->onchildwin(win);
childwinnode = childwinnode.NextSiblingElement();
}
return TRUE;
}
};
} // amespac | [
"[email protected]"
]
| [
[
[
1,
75
]
]
]
|
342a25b33acfbdd79941605450af5904ee1d74e9 | 94c1c7459eb5b2826e81ad2750019939f334afc8 | /source/CTaiKlineExportExecel.cpp | 1f8e547a109f0c34a9a1ec656ce7bae7bbd13fc9 | []
| no_license | wgwang/yinhustock | 1c57275b4bca093e344a430eeef59386e7439d15 | 382ed2c324a0a657ddef269ebfcd84634bd03c3a | refs/heads/master | 2021-01-15T17:07:15.833611 | 2010-11-27T07:06:40 | 2010-11-27T07:06:40 | 37,531,026 | 1 | 3 | null | null | null | null | GB18030 | C++ | false | false | 2,934 | cpp | // CTaiKlineExportExecel.cpp : implementation file
//
#include "stdafx.h"
#include "CTaiShanApp.h"
#include "CTaiShanDoc.h"
#include "MainFrm.h"
#include "CTaiKlineExportExecel.h"
#include "CTaiShanKlineShowView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CTaiKlineExportExecel::CTaiKlineExportExecel(CWnd* pParent /*=NULL*/)
: CDialog(CTaiKlineExportExecel::IDD, pParent)
{
pView = (CTaiShanKlineShowView*)pParent ;
m_nFiguer = 0;
ASSERT(pView!=NULL);
//{{AFX_DATA_INIT(CTaiKlineExportExecel)
m_bShowExcel = FALSE;
//}}AFX_DATA_INIT
}
void CTaiKlineExportExecel::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTaiKlineExportExecel)
DDX_Control(pDX, IDOK, m_ok);
DDX_Control(pDX, IDCANCEL, m_cancel);
DDX_Check(pDX, IDC_CHECK1, m_bShowExcel);
DDX_Control(pDX, IDC_MSFLEXGRID1, m_gridDataOut);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTaiKlineExportExecel, CDialog)
//{{AFX_MSG_MAP(CTaiKlineExportExecel)
ON_BN_CLICKED(IDOK, OnExport)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CTaiKlineExportExecel::OnInitDialog()
{
CDialog::OnInitDialog();
pView->OutDataExcel (&(this->m_gridDataOut) ,m_nFiguer);
return TRUE;
}
void CTaiKlineExportExecel::OnExport()
{
UpdateData();
CLongString longStr;
int nPerLine=0,nOutLine=0;
nPerLine = this->m_gridDataOut .GetRows();
nOutLine = this->m_gridDataOut .GetCols();
int i,j;
for(j=0;j<nPerLine;j++)
{
for(i =0;i<nOutLine;i++)
{
CString s ;
s = m_gridDataOut.GetTextMatrix(j,i);
if(i==nOutLine-1)
s+="\r\n";
else
s+="\t";
longStr + s;
}
}
CString defaultname="outputData.xls";
CString sArray="*.xls||";
CFileDialog m_filedia(FALSE,0,defaultname,OFN_CREATEPROMPT|OFN_HIDEREADONLY|OFN_NOCHANGEDIR,sArray);
m_filedia.m_ofn .lpstrInitialDir = CMainFrame::m_taiShanDoc ->m_CurrentWorkDirectory;
CString filename="";
if(m_filedia.DoModal()==IDOK)
{
filename=m_filedia.GetPathName();
CFile file;
if(file.Open(filename,CFile::modeRead)!=0)
{
if(AfxMessageBox(filename+"文件已存在,要覆盖吗?",MB_YESNO|MB_ICONQUESTION)==IDNO)
{
file.Close();
return;
}
file.Close();
}
if(file.Open(filename,CFile::modeWrite|CFile::modeCreate))
{
int n = longStr.GetLength ()+1;
file.Write(longStr.m_pData ,n);
file.Close();
}
else
{
AfxMessageBox("文件正在使用,请首先关闭文件!");
return;
}
if(m_bShowExcel == TRUE)
{
ShellExecute(
NULL,
"open",
filename,
NULL,
NULL,
SW_SHOW);
}
}
}
BOOL CTaiKlineExportExecel::OnHelpInfo(HELPINFO* pHelpInfo)
{
DoHtmlHelp(this);return TRUE;
}
| [
"[email protected]"
]
| [
[
[
1,
148
]
]
]
|
44c24952c853b1a53e2dffc9c2034d8854c42156 | 155c4955c117f0a37bb9481cd1456b392d0e9a77 | /Tessa/TessaInstructions/LoadVirtualMethodInstruction.cpp | 3e7a41803f464c26835e778f0eef69e3a35d04fe | []
| no_license | zwetan/tessa | 605720899aa2eb4207632700abe7e2ca157d19e6 | 940404b580054c47f3ced7cf8995794901cf0aaa | refs/heads/master | 2021-01-19T19:54:00.236268 | 2011-08-31T00:18:24 | 2011-08-31T00:18:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,832 | cpp | #include "TessaInstructionHeader.h"
namespace TessaInstructions {
LoadVirtualMethodInstruction::LoadVirtualMethodInstruction(MMgc::GC* gc, TessaInstruction* receiverObject, int methodId, TessaVM::BasicBlock* insertAtEnd)
: TessaInstruction(insertAtEnd)
{
TessaAssert(receiverObject != NULL);
_receiverObject = receiverObject;
_methodId = methodId;
_loadedMethodEnv = new (gc) TessaValue(TypeFactory::getInstance()->pointerType());
_loadedMethodInfo = new (gc) TessaValue(TypeFactory::getInstance()->pointerType());
}
void LoadVirtualMethodInstruction::print() {
printf("%s LoadVirtualMethod %s[method %d] (Env %s, Info %s)\n", getPrintPrefix().c_str(), _receiverObject->getOperandString().c_str(), _methodId,
_loadedMethodEnv->toString().data(), _loadedMethodInfo->toString().data()
);
}
void LoadVirtualMethodInstruction::visit(TessaVisitorInterface* tessaVisitor) {
tessaVisitor->visit(this);
}
int LoadVirtualMethodInstruction::getMethodId() {
return _methodId;
}
TessaInstruction* LoadVirtualMethodInstruction::getReceiverObject() {
return _receiverObject;
}
LoadVirtualMethodInstruction* LoadVirtualMethodInstruction::clone(MMgc::GC* gc, MMgc::GCHashtable* originalToCloneMap, TessaVM::BasicBlock* insertCloneAtEnd) {
TessaInstruction* receiverObjectClone = (TessaInstruction*) originalToCloneMap->get(_receiverObject);
LoadVirtualMethodInstruction* clone = new (gc) LoadVirtualMethodInstruction(gc, receiverObjectClone, _methodId, insertCloneAtEnd);
/*
TessaValue* clonedLoadedMethodEnv = new (gc) TessaValue(TypeFactory::getInstance()->pointerType());
TessaValue* clonedLoadedMethodInfo = new (gc) TessaValue(TypeFactory::getInstance()->pointerType());
clone->_loadedMethodEnv = clonedLoadedMethodEnv;
clone->_loadedMethodInfo = clonedLoadedMethodInfo;
*/
/***
* Since the LoadVirtualMethodInstruction outputs more than one value
* we have to manually stuff the map with the cloned values as well.
*/
originalToCloneMap->put(getLoadedMethodInfo(), clone->_loadedMethodInfo);
originalToCloneMap->put(getLoadedMethodEnv(), clone->_loadedMethodEnv);
clone->setType(this->getType());
return clone;
}
TessaValue* LoadVirtualMethodInstruction::getLoadedMethodEnv() {
return _loadedMethodEnv;
}
TessaValue* LoadVirtualMethodInstruction::getLoadedMethodInfo() {
return _loadedMethodInfo;
}
bool LoadVirtualMethodInstruction::isLoadVirtualMethod() {
return true;
}
List<TessaValue*, LIST_GCObjects>* LoadVirtualMethodInstruction::getOperands(MMgc::GC* gc) {
List<TessaValue*, LIST_GCObjects>* operandList = new (gc) List<TessaValue*, LIST_GCObjects>(gc);
operandList->add(_loadedMethodInfo);
operandList->add(_loadedMethodEnv);
return operandList;
}
} | [
"[email protected]"
]
| [
[
[
1,
73
]
]
]
|
5e52438ea2ac30053ae6ac37d8c7ecd76b86cb3b | 7b7a3f9e0cac33661b19bdfcb99283f64a455a13 | /Engine/dll/Core/flx_node.h | c18d138c2bbe4aa7be4a8639f2dab099fd2364aa | []
| no_license | grimtraveller/fluxengine | 62bc0169d90bfe656d70e68615186bd60ab561b0 | 8c967eca99c2ce92ca4186a9ca00c2a9b70033cd | refs/heads/master | 2021-01-10T10:58:56.217357 | 2009-09-01T15:07:05 | 2009-09-01T15:07:05 | 55,775,414 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,111 | h | /*---------------------------------------------------------------------------
This source file is part of the FluxEngine.
Copyright (c) 2008 - 2009 Marvin K. (starvinmarvin)
This program is free software.
---------------------------------------------------------------------------*/
#ifndef NODE_H
#define NODE_H
#include "../Core/flx_core.h"
#include <string>
#include <vector>
enum NodeType {
TRANSFORM = 0,
SHAPE
};
struct AlphaObject;
class ENGINE_API Node {
public:
Node();
virtual ~Node();
bool isTransform();
bool isShape();
bool SetName(const std::string& node_name);
Node* FindNode(const std::string& node_name);
Node* FindNodeByID(unsigned int id);
unsigned int GetID();
void SetID(unsigned int id);
virtual void Update() = 0;
virtual void RenderOGL(bool bRenderSolid) = 0;
bool m_bVisible;
public:
static std::vector<AlphaObject*>* s_vAlphaObjects;
Node* m_pPrev;
Node* m_pNext;
Node* m_pOut;
Node* m_pIn;
protected:
NodeType m_Type;
public:
std::string m_node_name;
unsigned int m_iID;
};
#endif | [
"marvin.kicha@e13029a8-578f-11de-8abc-d1c337b90d21"
]
| [
[
[
1,
58
]
]
]
|
ae31cbebf651d1389faf0c581ee423a68a8693cc | c95a83e1a741b8c0eb810dd018d91060e5872dd8 | /Game/Shared/TO2/TO2VersionMgr.h | 5d4d7198a37e9adbe9dcbc20fa9abb7557a65994 | []
| no_license | rickyharis39/nolf2 | ba0b56e2abb076e60d97fc7a2a8ee7be4394266c | 0da0603dc961e73ac734ff365bfbfb8abb9b9b04 | refs/heads/master | 2021-01-01T17:21:00.678517 | 2011-07-23T12:11:19 | 2011-07-23T12:11:19 | 38,495,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 834 | h | // ----------------------------------------------------------------------- //
//
// MODULE : TO2VersionMgr.h
//
// PURPOSE : Definition of versioning manager
//
// CREATED : 11/16/2000
//
// (c) 2000 Monolith Productions, Inc. All Rights Reserved
//
// ----------------------------------------------------------------------- //
#ifndef _TO2VERSIONMGR_H_
#define _TO2VERSIONMGR_H_
#include "VersionMgr.h"
class CTO2VersionMgr : public CVersionMgr
{
public :
CTO2VersionMgr();
virtual ~CTO2VersionMgr() {}
virtual void Update();
virtual const char* GetVersion();
virtual const char* GetBuild();
virtual const uint32 GetSaveVersion();
virtual const char* GetNetGameName();
virtual const char* GetNetVersion();
virtual LTGUID const* GetBuildGuid();
};
#endif _TO2VERSIONMGR_H_ | [
"[email protected]"
]
| [
[
[
1,
35
]
]
]
|
36f44f8629ae4ed5ac24ec11926f33abe94d7cfd | 5218c2a5173e3137f341f99aa0495879b189042a | /Stokes/Maya/ObjectEmitter.hpp | 0b566afe40e9a493fbdd501e3bf4e791b51007fd | []
| no_license | bungnoid/stokes | cd00ba5d5aeb36da69fb38db69b1d2394853dada | 553abca00a626379ea7fb9f51c206d15ae32d2da | refs/heads/master | 2021-01-10T12:57:12.718405 | 2011-08-15T09:44:30 | 2011-08-15T09:44:30 | 51,467,263 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 552 | hpp | #ifndef STOKES_MAYA_OBJECTEMITTER_HPP
#define STOKES_MAYA_OBJECTEMITTER_HPP
#include <maya/MObject.h>
#include <Stokes/Core/NoisedEmitter.hpp>
#include <Stokes/Maya/API.hpp>
ENTER_NAMESPACE_STOKES_MAYA
class STOKES_MAYA_API ObjectEmitter : public NoisedEmitter
{
public:
ObjectEmitter(const MObject& object);
virtual ~ObjectEmitter();
virtual void CalculateWorldBound(Bound& bound) const = 0;
virtual void Fill(const FieldRef& field) = 0;
protected:
MObject mObject;
};
LEAVE_NAMESPACE_STOKES_MAYA
#endif
| [
"[email protected]"
]
| [
[
[
1,
30
]
]
]
|
f4cd3d580e86a355964f52c8bb33a9b3155c0c53 | 9fb229975cc6bd01eb38c3e96849d0c36985fa1e | /src/HG/shadow.h | 54e31a48358bcc0e25532624bf1ad59444d53c7f | []
| no_license | Danewalker/ahr | 3758bf3219f407ed813c2bbed5d1d86291b9237d | 2af9fd5a866c98ef1f95f4d1c3d9b192fee785a6 | refs/heads/master | 2016-09-13T08:03:43.040624 | 2010-07-21T15:44:41 | 2010-07-21T15:44:41 | 56,323,321 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,028 | h | #ifndef __SHADOW_H
#define __SHADOW_H
#include "vertex.h"
#include "face.h"
#include "mesh.h"
#include "TextureFBO.h"
#include "config.h"
// ----------------------------------------------
// class CShadow
//
// This class handle the 4 neons needed to illuminate a car
//
// ----------------------------------------------
class CCar;
#define SHADOW_TEXFBO_WIDTH 256
#define SHADOW_TEXFBO_HEIGHT 256
#define SHADOW_TEXFBO_DELTA 70 //should be equal to the max height of all cars
#ifdef IPHONE
#define POLYGON_OFFSET_FOR_SHADOW (-100.0f)
#else
#define POLYGON_OFFSET_FOR_SHADOW (-100000.0f)
#endif
namespace Lib3D
{
class TTexture;
class CLib3D;
// class TVertex;
#if USE_CAR_SHADOW == 1
class CShadow
{
public:
CShadow(const TTexture*, CGLMesh & carMesh);
~CShadow();
//separate shadowMatrix, from animMatrix
//inverseShadowMatrix needed to obtain the light direction in shadow space
void Draw( Lib3D::CLib3D& lib3d, const Vector4s * carPosition,Vector4s * sunPosition,
bool bRealShadow, CMatrix44 *inverseShadowMatrix, CMatrix44 *animMatrix);
void DrawCopterShadow( Lib3D::CLib3D& lib3d, const Vector4s * carPosition,Vector4s * sunPosition);
public:
//texture frame buffer object
static f32 s_texFBO_UV[];
static f32 s_texFBO_XYZ[];
static u16 s_texFBO_INDICES[];
#ifdef USE_PROJECT_SHADOW_INTO_TEXTURE
static TextureFBO* s_texFBO;
static void createShadowTexFBO();
static void destroyShadowTexFBO();
void projectShadowInTexture(int lightAngle, CMatrix44* animMatrix);
#endif //USE_PROJECT_SHADOW_INTO_TEXTURE
private:
// TVertex ** m_vertexes;
// TFace ** m_faces;
// CMesh & m_carMesh;
// TODO: remove m_carMesh, keep only m_shadowMesh
CGLMesh& m_carMesh;
CGLMesh* m_shadowMesh;
CCar *m_car;
void initializeShadowMesh();
void freeShadowMesh();
// TODO: remove
const TTexture* const m_pShadowTexture;
int m_nFaces;
int m_nVertex;
};
#endif // USE_CAR_SHADOW
}
#endif //__SHADOW_H
| [
"jakesoul@c957e3ca-5ece-11de-8832-3f4c773c73ae"
]
| [
[
[
1,
89
]
]
]
|
27aec40a6e76da3df3aa5b335522dc9faeafef0e | 9277f8b966db2bc75acaf12a75f620853be4ffa4 | /tensor/apex_op_plan.h | 5bd6fde57e0d8fec3bb261601f00e44c2e442d3e | []
| no_license | guochao1/apex-dbn | 3e6ad9de12564fc206ed08e563ecea1976edfff5 | d95a606a55ba80687e730b78bd4579f20d616eec | refs/heads/master | 2021-01-22T13:42:09.752260 | 2010-09-29T09:13:39 | 2010-09-29T09:13:39 | 40,700,204 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,893 | h | #ifndef _APEX_OP_PLAN_H_
#define _APEX_OP_PLAN_H_
// plans to extend more operators
namespace apex_op_plan{
#define APEX_TEMPLATE_MAP_PLAN(plan_name) \
struct plan_name{ \
const T *a; \
plan_name( const T *a ){ \
this->a = a; \
} \
}; \
#define APEX_TEMPLATE_ADD_SUPPORT_OP(T,plan_name,map_name) \
inline apex_op_plan::plan_name<T> map_name( const T & a ){ \
return apex_op_plan::plan_name<T>( &a ); \
} \
template<typename T>
APEX_TEMPLATE_MAP_PLAN( SigmoidPlan )
#define APEX_ADD_SUPPORT_SIGMOID_OP(T) APEX_TEMPLATE_ADD_SUPPORT_OP(T,SigmoidPlan,sigmoid)
template<typename T>
APEX_TEMPLATE_MAP_PLAN( SampleBinaryPlan )
#define APEX_ADD_SUPPORT_SAMPLE_BINARY_OP(T) APEX_TEMPLATE_ADD_SUPPORT_OP(T,SampleBinaryPlan,sample_binary)
template<typename T>
APEX_TEMPLATE_MAP_PLAN( ClonePlan )
#define APEX_ADD_SUPPORT_CLONE_OP(T) APEX_TEMPLATE_ADD_SUPPORT_OP(T,ClonePlan,clone)
template<typename T>
APEX_TEMPLATE_MAP_PLAN( AllocLikePlan )
#define APEX_ADD_SUPPORT_ALLOC_LIKE_OP(T) APEX_TEMPLATE_ADD_SUPPORT_OP(T,AllocLikePlan,alloc_like)
template<typename T>
APEX_TEMPLATE_MAP_PLAN( Sum2DPlan )
#define APEX_ADD_SUPPORT_SUM_2D_OP(T) APEX_TEMPLATE_ADD_SUPPORT_OP(T,Sum2DPlan,sum_2D)
};
namespace apex_op_plan{
#define APEX_TEMPLATE_MAP_PLAN_B(plan_name) \
struct plan_name{ \
const T *a; \
TV val; \
plan_name( const T *a, TV val ){ \
this->a = a; this->val = val; \
} \
}; \
#define APEX_TEMPLATE_ADD_SUPPORT_OP_B(T,TV,plan_name,map_name) \
inline apex_op_plan::plan_name<T,TV> map_name( const T & a, TV b ){ \
return apex_op_plan::plan_name<T,TV>( &a, b ); \
} \
template<typename T,typename TV>
APEX_TEMPLATE_MAP_PLAN_B( SampleGaussianPlan )
#define APEX_ADD_SUPPORT_SAMPLE_GAUSSIAN_OP(T,TV) APEX_TEMPLATE_ADD_SUPPORT_OP_B(T,TV,SampleGaussianPlan,sample_gaussian)
};
namespace apex_op_plan{
template<typename T>
struct AddPlan{
const T *a, *b;
AddPlan( const T *a, const T *b ) {
this->a = a;
this->b = b;
}
};
#define APEX_ADD_SUPPORT_ADD_OP(T) \
inline apex_op_plan::AddPlan<T> operator+( const T &a, const T &b ){ \
return apex_op_plan::AddPlan<T>( &a, &b ); \
} \
template<typename T>
struct SubPlan{
const T *a, *b;
SubPlan( const T *a, const T *b ) {
this->a = a;
this->b = b;
}
};
#define APEX_ADD_SUPPORT_SUB_OP(T) \
inline apex_op_plan::SubPlan<T> operator-( const T &a, const T &b ){ \
return apex_op_plan::SubPlan<T>( &a, &b ); \
} \
template<typename T>
struct MulPlan{
const T *a, *b;
MulPlan( const T *a, const T *b ) {
this->a = a;
this->b = b;
}
};
#define APEX_ADD_SUPPORT_MUL_OP(T) \
inline apex_op_plan::MulPlan<T> operator*( const T &a, const T &b ){ \
return apex_op_plan::MulPlan<T>( &a, &b ); \
} \
template<typename T,typename TV>
struct ScalePlan{
const T *a;
TV scale;
ScalePlan( const T *a, TV scale ) {
this->a = a;
this->scale = scale;
}
};
#define APEX_ADD_SUPPORT_SCALE_OP(T,TV) \
inline apex_op_plan::ScalePlan<T,TV> operator*( const T &a, TV scale ){ \
return apex_op_plan::ScalePlan<T,TV>( &a, scale ); \
} \
inline apex_op_plan::ScalePlan<T,TV> operator*( TV scale, const T &a ){ \
return apex_op_plan::ScalePlan<T,TV>( &a, scale ); \
} \
#define APEX_ADD_SUPPORT_SCALE_DOT_OP(TA,TB,TV) \
inline apex_op_plan::ScalePlan<apex_op_plan::DotPlan<TA,TB> ,TV> operator*( const apex_op_plan::DotPlan<TA,TB> &a, TV scale ){ \
return apex_op_plan::ScalePlan<apex_op_plan::DotPlan<TA,TB> ,TV>( &a, scale ); \
} \
inline apex_op_plan::ScalePlan<apex_op_plan::DotPlan<TA,TB> ,TV> operator*( TV scale, const apex_op_plan::DotPlan<TA,TB> &a ){ \
return apex_op_plan::ScalePlan<apex_op_plan::DotPlan<TA,TB> ,TV>( &a, scale ); \
} \
#define APEX_ADD_SUPPORT_SCALE_DOT_LT_OP(TA,TB,TV) \
inline apex_op_plan::ScalePlan<apex_op_plan::DotLTPlan<TA,TB> ,TV> operator*( const apex_op_plan::DotLTPlan<TA,TB> &a, TV scale ){ \
return apex_op_plan::ScalePlan<apex_op_plan::DotLTPlan<TA,TB> ,TV>( &a, scale ); \
} \
inline apex_op_plan::ScalePlan<apex_op_plan::DotLTPlan<TA,TB> ,TV> operator*( TV scale, const apex_op_plan::DotLTPlan<TA,TB> &a ){ \
return apex_op_plan::ScalePlan<apex_op_plan::DotLTPlan<TA,TB> ,TV>( &a, scale ); \
} \
template<typename TA,typename TB>
struct DotPlan{
const TA *a;
const TB *b;
DotPlan( const TA *a, const TB *b ) {
this->a = a;
this->b = b;
}
};
#define APEX_ADD_SUPPORT_DOT_OP(TA,TB) \
inline apex_op_plan::DotPlan<TA,TB> dot( const TA &a, const TB &b ){\
return apex_op_plan::DotPlan<TA,TB>( &a,&b ); \
} \
template<typename T>
struct TransposePlan{
const T *mat;
TransposePlan( const T *mat ){
this->mat = mat;
}
};
#define APEX_ADD_SUPPORT_TRANSPOSE_OP(TP) \
inline apex_op_plan::TransposePlan<TP> TP::T()const{ \
return apex_op_plan::TransposePlan<TP>( this ); \
} \
template<typename TA,typename TB>
struct DotLTPlan{
const TA *a;
const TB *b;
DotLTPlan( const TA *a, const TB *b ) {
this->a = a;
this->b = b;
}
};
#define APEX_ADD_SUPPORT_DOT_LT_OP(TA,TB) \
inline apex_op_plan::DotLTPlan<TA,TB> dot( const apex_op_plan::TransposePlan<TA> &a, const TB &b ){ \
return apex_op_plan::DotLTPlan<TA,TB>( a.mat, &b ); \
} \
template<typename TA,typename TB>
struct DotRTPlan{
const TA *a;
const TB *b;
DotRTPlan( const TA *a, const TB *b ) {
this->a = a;
this->b = b;
}
};
#define APEX_ADD_SUPPORT_DOT_RT_OP(TA,TB) \
inline apex_op_plan::DotRTPlan<TA,TB> dot( const TA &a, const apex_op_plan::TransposePlan<TB> &b ){ \
return apex_op_plan::DotRTPlan<TA,TB>( &a, b.mat ); \
} \
template<typename T,typename TV>
struct ScaleAddPlan{
const T *a,*b;
TV sa,sb;
ScaleAddPlan( const T *a, const T *b, TV sa, TV sb ) {
this->a = a;
this->b = b;
this->sa = sa;
this->sb = sb;
}
};
template<typename T,typename TV>
inline ScaleAddPlan<T,TV> operator+( const ScalePlan<T,TV> &aa, const ScalePlan<T,TV> &bb ){
return ScaleAddPlan<T,TV>( aa.a, bb.a, aa.scale, bb.scale );
}
};
#endif
| [
"workcrow@b861ab8a-2dba-11df-8e64-fd3be38ee323"
]
| [
[
[
1,
217
]
]
]
|
17f9f02e628c40e749d1aacad758ff07aa2d7cc0 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/os/ossrv/ssl/libcrypto/crypto_test/src/crypto_testBlocks.cpp | 1204f6639a332221e03f44fd54feabb2dcf08aca | []
| no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,562 | cpp | /*
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: ?Description
*
*/
// INCLUDE FILES
#include <e32svr.h>
#include <StifParser.h>
#include <Stiftestinterface.h>
#include "crypto_test.h"
#include "tcrypto_test.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
// EXTERNAL DATA STRUCTURES
//extern ?external_data;
// EXTERNAL FUNCTION PROTOTYPES
//extern ?external_function( ?arg_type,?arg_type );
// CONSTANTS
//const ?type ?constant_var = ?constant;
// MACROS
//#define ?macro ?macro_def
// LOCAL CONSTANTS AND MACROS
//const ?type ?constant_var = ?constant;
//#define ?macro_name ?macro_def
// MODULE DATA STRUCTURES
//enum ?declaration
//typedef ?declaration
// LOCAL FUNCTION PROTOTYPES
//?type ?function_name( ?arg_type, ?arg_type );
// FORWARD DECLARATIONS
//class ?FORWARD_CLASSNAME;
// ============================= LOCAL FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// ?function_name ?description.
// ?description
// Returns: ?value_1: ?description
// ?value_n: ?description_line1
// ?description_line2
// -----------------------------------------------------------------------------
//
/*
?type ?function_name(
?arg_type arg, // ?description
?arg_type arg) // ?description
{
?code // ?comment
// ?comment
?code
}
*/
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// Ccrypto_test::Delete
// Delete here all resources allocated and opened from test methods.
// Called from destructor.
// -----------------------------------------------------------------------------
//
void Ccrypto_test::Delete()
{
}
// -----------------------------------------------------------------------------
// Ccrypto_test::RunMethodL
// Run specified method. Contains also table of test mothods and their names.
// -----------------------------------------------------------------------------
//
TInt Ccrypto_test::RunMethodL(
CStifItemParser& aItem )
{
static TStifFunctionInfo const KFunctions[] =
{
// Copy this line for every implemented function.
// First string is the function name used in TestScripter script file.
// Second is the actual implementation member function.
ENTRY( "BNTest", Ccrypto_test::BnTest ),
ENTRY( "DESTest", Ccrypto_test::DesTest ),
ENTRY( "DHTest", Ccrypto_test::DhTest ),
ENTRY( "DSATest", Ccrypto_test::DsaTest ),
ENTRY( "ENGINETest", Ccrypto_test::EngineTest ),
ENTRY( "EVPTest", Ccrypto_test::EvpTest ),
ENTRY( "EXPTest", Ccrypto_test::ExpTest ),
ENTRY( "HMACTest", Ccrypto_test::HmacTest ),
ENTRY( "MD2Test", Ccrypto_test::Md2Test ),
ENTRY( "MD5Test", Ccrypto_test::Md5Test ),
ENTRY( "RANDTest", Ccrypto_test::RandTest ),
ENTRY( "RC2Test", Ccrypto_test::Rc2Test ),
ENTRY( "RC4Test", Ccrypto_test::Rc4Test ),
ENTRY( "RSATest", Ccrypto_test::RsaTest ),
ENTRY( "SHATest", Ccrypto_test::ShaTest ),
ENTRY( "SHA1Test", Ccrypto_test::Sha1Test ),
ENTRY( "SHA256Test", Ccrypto_test::Sha256Test ),
ENTRY( "SHA512Test", Ccrypto_test::Sha512Test ),
};
const TInt count = sizeof( KFunctions ) /
sizeof( TStifFunctionInfo );
return RunInternalL( KFunctions, count, aItem );
}
#ifdef __cplusplus
extern "C"
{
#endif
FILE *fp_stdout=NULL;
FILE *fp_stderr=NULL;
#ifdef __cplusplus
}
#endif
int cryptotest_init(char *mod)
{
char str[200];
int len=0;
if(!mod)
return 1;
len=strlen(LOG_STDOUT);
strcpy(str,LOG_STDOUT);
strcat(str,"_");
strcat(str,mod);
len+=strlen(mod);
str[len+1]='\0';
fp_stdout = fopen(str,"a+b");
if(!fp_stdout)
return 1;
fp_stderr=fp_stdout;
return 0;
}
void cryptotest_deinit(void)
{
fclose(fp_stdout);
fp_stderr=NULL;
fp_stdout=NULL;
}
char ** MakeArgs(CStifItemParser& aItem,int * argc)
{
char *ini_cmd[256];
char **cmd_line;
TInt len=0;
TPtrC string;
TBuf8<50> buf1;
char* argument;
int cnt=0;
int i;
//parse through the parameters of cfg to find the number and strings of cmd line
while(aItem.GetNextString(string)!=-1)
{
buf1.Copy(string);
argument=(char *)buf1.Ptr();
len=buf1.Length();
argument[len]='\0';
ini_cmd[cnt]=(char *)malloc(sizeof(char)*len+1);
if(ini_cmd[cnt]==NULL)
{
for(i=0;i<cnt;i++)
{
if(ini_cmd[i])
free(ini_cmd[i]);
}
return NULL;
}
strcpy(ini_cmd[cnt],(const char *)argument);
cnt++;
}
//allocate memory for the command line ragged array
cmd_line=(char **)malloc(cnt*sizeof(char *));
if(cmd_line==NULL)
{
for(i=0;i<cnt;i++)
{
if(ini_cmd[i])
free(ini_cmd[i]);
}
return NULL;
}
//initialize the array
for(i=0;i<cnt;i++) cmd_line[i]=ini_cmd[i];
//initialize argc
*argc=cnt;
return cmd_line;
}
//-----------------------------------------------------------------------------
//function function for destroying argv
//-----------------------------------------------------------------------------
void DeleteArgs(char ** cmd_line,int argc)
{
int i;
for(i=0;i<argc;i++) free(cmd_line[i]);
free(cmd_line);
}
// -----------------------------------------------------------------------------
// Ccrypto_test::ExampleL
// Example test method function.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TInt Ccrypto_test::BnTest( CStifItemParser&/* aItem*/ )
{
TInt ret=1;
if(!cryptotest_init("bn"))
{
ret = bn_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::DesTest( CStifItemParser&/* aItem*/ )
{
TInt ret=1;
if(!cryptotest_init("des"))
{
ret = des_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
return ret;
}
TInt Ccrypto_test::DhTest( CStifItemParser&/* aItem*/ )
{
TInt ret=1;
if(!cryptotest_init("dh"))
{
ret = dh_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::DsaTest( CStifItemParser&/* aItem*/ )
{
TInt ret=1;
if(!cryptotest_init("dsa"))
{
ret = dsa_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::EngineTest( CStifItemParser&/* aItem*/ )
{
TInt ret=1;
if(!cryptotest_init("eng"))
{
ret = engine_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::EvpTest( CStifItemParser& aItem )
{
TInt ret=1;
int argc=0;
char** argv=NULL;
argv = MakeArgs(aItem,&argc);
if(!argv)
{
return KErrNoMemory;
}
if(!cryptotest_init("evp"))
{
ret = evp_main(argc,argv);
cryptotest_deinit();
}
DeleteArgs(argv,argc);
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::ExpTest( CStifItemParser& /*aItem */)
{
TInt ret=1;
if(!cryptotest_init("exp"))
{
ret = exp_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::HmacTest( CStifItemParser& /*aItem */)
{
TInt ret=1;
if(!cryptotest_init("hmac"))
{
ret = hmac_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::Md2Test( CStifItemParser& /*aItem */)
{
TInt ret=1;
if(!cryptotest_init("md2"))
{
ret = md2_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::Md5Test( CStifItemParser& /*aItem */)
{
TInt ret=1;
if(!cryptotest_init("md5"))
{
ret = md5_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::RandTest( CStifItemParser& /*aItem */)
{
TInt ret=1;
if(!cryptotest_init("rand"))
{
ret = rand_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::Rc2Test( CStifItemParser& /*aItem */)
{
TInt ret=1;
if(!cryptotest_init("rc2"))
{
ret = rc2_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::Rc4Test( CStifItemParser& /*aItem */)
{
TInt ret=1;
if(!cryptotest_init("rc4"))
{
ret = rc4_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::RsaTest( CStifItemParser& /*aItem */)
{
TInt ret=1;
if(!cryptotest_init("rsa"))
{
ret = rsa_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::ShaTest( CStifItemParser& /*aItem */)
{
TInt ret=1;
if(!cryptotest_init("sha"))
{
ret = sha_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::Sha1Test( CStifItemParser& /*aItem */)
{
TInt ret=1;
if(!cryptotest_init("sha1"))
{
ret = sha1_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::Sha256Test( CStifItemParser& /*aItem */)
{
TInt ret=1;
if(!cryptotest_init("sha256"))
{
ret = sha256_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
TInt Ccrypto_test::Sha512Test( CStifItemParser& /*aItem */)
{
TInt ret=1;
if(!cryptotest_init("sha512"))
{
ret = sha512_main(0,NULL);
cryptotest_deinit();
}
if(ret==1&&errno==ENOMEM)
{
return KErrNoMemory;
}
return ret;
}
// -----------------------------------------------------------------------------
// Ccrypto_test::?member_function
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
/*
TInt Ccrypto_test::?member_function(
CItemParser& aItem )
{
?code
}
*/
// ========================== OTHER EXPORTED FUNCTIONS =========================
// None
// End of File
| [
"none@none"
]
| [
[
[
1,
617
]
]
]
|
25f8f50410831abfc381f905653cdb8e6c397fb3 | 4b0f51aeecddecf3f57a29ffa7a184ae48f1dc61 | /CleanProject/Src/CSwitch.cpp | d4e1c8399704257a770962c544d8a36426a2edb1 | []
| no_license | bahao247/apeengine2 | 56560dbf6d262364fbc0f9f96ba4231e5e4ed301 | f2617b2a42bdf2907c6d56e334c0d027fb62062d | refs/heads/master | 2021-01-10T14:04:02.319337 | 2009-08-26T08:23:33 | 2009-08-26T08:23:33 | 45,979,392 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 643 | cpp | #include "CSwitch.h"
namespace Nebula {
CSwitch::CSwitch()
{
mComponentID = "CSwitch";
}
CSwitch::CSwitch(const CSwitchDesc& desc)
{
mComponentID = "CSwitch";
mDesc = desc;
}
CSwitch::~CSwitch()
{
}
void CSwitch::update() {
}
void CSwitch::setup() {
}
void CSwitch::callLuaFunction(const std::string func ) {
luabind::object componentState = getOwnerObject()->getTemplateObject();
if(componentState) {
luabind::object CallBack = componentState[func];
if(CallBack)
luabind::call_function<void>(CallBack,this->getOwnerObject()); // this
}
}
} //end namespace
| [
"pablosn@06488772-1f9a-11de-8b5c-13accb87f508"
]
| [
[
[
1,
37
]
]
]
|
df932dbd4b7e49a6848e084925eace353151dc80 | 7e6387a7495e89ec42acc99ea6d8736a69d96d72 | /guiCode/guiStructuredMesh.cpp | f702aad1623c7c0d6272542d144b03426c204c91 | []
| no_license | erkg/virtualflowlab | 2a491d71fdf8e7db6dab243560fadbb8cd731943 | a540d4ecd076327f98cb7e3044422e7b4d33efbb | refs/heads/master | 2016-08-11T07:12:51.924920 | 2010-07-22T14:40:24 | 2010-07-22T14:40:24 | 55,049,199 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 32,504 | cpp | #include <math.h>
#include "guiStructuredMesh.h"
#include "guiPrimitive.h"
#include "guiTypedefs.h"
#include "guiProblem.h"
extern Problem *problem;
StructuredMesh::StructuredMesh (void)
{
primitives = new Primitive[MAX_PRIMITIVES];
nPrimitives = 0;
nBlocks = 0;
primitiveUnderMouse = -1;
minXused = minYused = -10.0; // A large number
maxXused = maxYused = 10.0; // A small number
isMeshGenerated = FALSE;
blocks = NULL;
}
StructuredMesh::~StructuredMesh (void)
{
delete[] primitives;
delete[] blocks;
}
void StructuredMesh::addLine(int i, float* &coor)
{
primitives[i].setType(LINE);
primitives[i].setNumberOfEnteredPoints(2);
primitives[i].allocateEnteredPointCoor();
primitives[i].setEnteredPointCoor(coor);
primitives[i].setNumberOfDefPoints(2);
primitives[i].allocateDefPointCoor();
primitives[i].setLineDefPointCoor();
primitives[i].setIsDeleted(FALSE);
updateMinMaxUsed(); // Update the min and max coordinates that will be shown on the screen.
}
void StructuredMesh::addArc(int i, float* &coor, bool center, bool cw)
{
primitives[i].setType(ARC);
primitives[i].setUsesCenter(center);
primitives[i].setIsCW(cw);
primitives[i].setNumberOfEnteredPoints(3);
primitives[i].allocateEnteredPointCoor();
primitives[i].setEnteredPointCoor(coor);
primitives[i].setNumberOfDefPoints(CIRCULAR_ARC_DEF_POINTS);
primitives[i].allocateDefPointCoor();
primitives[i].calculateArcDefPointCoor();
primitives[i].setIsDeleted(FALSE);
updateMinMaxUsed(); // Update the min and max coordinates that will be shown on the screen.
}
void StructuredMesh::addFunction(int i, string f, float* &coor)
{
primitives[i].setType(FUNCTION);
primitives[i].setFunction(f);
primitives[i].setNumberOfEnteredPoints(2);
primitives[i].allocateEnteredPointCoor();
primitives[i].setEnteredPointCoor(coor);
primitives[i].setNumberOfDefPoints(FUNCTION_DEF_POINTS);
primitives[i].allocateDefPointCoor();
primitives[i].calculateFunctionDefPointCoor();
primitives[i].setIsDeleted(FALSE);
updateMinMaxUsed(); // Update the min and max coordinates that will be shown on the screen.
}
int StructuredMesh::getFirstEmptyPrimitivePos()
{
for (int i = 0; i < MAX_PRIMITIVES; i++) {
if (primitives[i].getIsDeleted()) return i;
}
return MAX_PRIMITIVES; // Means we need to increase the length of the primitives array.
}
void StructuredMesh::updateMinMaxUsed()
{
float *dummyCoor;
minXused = 100000.0; // A large number
minYused = 100000.0;
maxXused = -100000.0; // A small number
maxYused = -100000.0;
// If there is no primitive drawn, than the following will be skipped and the above values will be used.
for (int i = 0; i < MAX_PRIMITIVES; i++) {
if (primitives[i].getIsDeleted()) continue;
dummyCoor = primitives[i].getDefPointCoor(); // Cuneyt: Is there a problem here ?
for (int j = 0; j < primitives[i].getNumberOfDefPoints(); j++) {
if (dummyCoor[2*j] > maxXused) maxXused = dummyCoor[2*j];
if (dummyCoor[2*j] < minXused) minXused = dummyCoor[2*j];
if (dummyCoor[2*j+1] > maxYused) maxYused = dummyCoor[2*j+1];
if (dummyCoor[2*j+1] < minYused) minYused = dummyCoor[2*j+1];
}
}
}
int StructuredMesh::isLineValid(float* &coor)
{
float *dummyCoor;
float x1, y1, x2, y2;
float xx1, yy1, xx2, yy2;
x1 = coor[0]; // These are shortcuts
y1 = coor[1];
x2 = coor[2];
y2 = coor[3];
if ((x1 == x2) && (y1 == y2))
return -1; // The LINE is not valid, because it has zero length.
for (int i = 0; i < MAX_PRIMITIVES; i++) { // Check if a line the same as this one already exists or not.
if (primitives[i].getIsDeleted()) continue;
if (primitives[i].getType() != LINE) continue;
dummyCoor = primitives[i].getEnteredPointCoor(); // Cuneyt: Is there a problem here ?
xx1 = dummyCoor[0];
xx2 = dummyCoor[2];
yy1 = dummyCoor[1];
yy2 = dummyCoor[3];
if ((x1 == xx1 && y1 == yy1 && x2 == xx2 && y2 == yy2) ||
(x1 == xx2 && y1 == yy2 && x2 == xx1 && y2 == yy1))
return -2; // The LINE is not valid, because the same LINE already exists.
}
return 1; // The LINE is valid
} // end of function isLineValid()
int StructuredMesh::isArcValid(float* &coor, bool center, bool cw)
{
float *dummyCoor;
float x1, x2, x3, y1, y2, y3;
float xx1, xx2, xx3, yy1, yy2, yy3;
x1 = coor[0]; // These are shortcuts;
y1 = coor[1];
x2 = coor[2];
y2 = coor[3];
x3 = coor[4];
y3 = coor[5];
if (center) {
float r1, r2;
r1 = (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3); // Square of the distance between the 1st end point and the center.
r2 = (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3); // Square of the distance between the 2nd end point and the center.
if (fabs(r1-r2)/(r1+r2) > 0.01) // Not a proper arc.
return -1;
} else {
// cuneyt: Bu kismin dolmasi gerek.
}
for (int i = 0; i < MAX_PRIMITIVES; i++) { // Check if an arc the same as this one already exists or not.
if (primitives[i].getIsDeleted()) continue;
if (primitives[i].getType() != ARC) continue;
dummyCoor = primitives[i].getEnteredPointCoor(); // Cuneyt: Is there a problem here ?
xx1 = dummyCoor[0]; // These are shortcuts
yy1 = dummyCoor[1];
xx2 = dummyCoor[2];
yy2 = dummyCoor[3];
xx3 = dummyCoor[4];
yy3 = dummyCoor[5];
if (center && primitives[i].getUsesCenter()) { // Both the arc we are currently drawing and arc "i" are defined with 2 points and center.
if (((x1 == xx1 && y1 == yy1 && x2 == xx2 && y2 == yy2 && x3 == xx3 && y3 == yy3) ||
(x1 == xx2 && y1 == yy2 && x2 == xx1 && y2 == yy1 && x3 == xx3 && y3 == yy3)) &&
(cw == primitives[i].getIsCW()))
return -2; // The ARC is not valid, because the same ARC already exists.
} else if (!center && !primitives[i].getUsesCenter() ) { // Both the arc we are currently drawing and arc "i" are defined with 3 points.
// Cuneyt: Fill this part
}
}
return 1; // The ARC is valid.
} // End of function isArcValid()
int StructuredMesh::isFunctionValid(string function, float* &coor)
{
float *dummyCoor;
float x1, y1, x2, y2;
float xx1, yy1, xx2, yy2;
FunctionParser fparser; // Function parser object
double funcVals[1];
x1 = coor[0]; // These are shortcuts
y1 = coor[1];
x2 = coor[2];
y2 = coor[3];
if ((x1 == x2) && (y1 == y2))
return -1; // The FUNCTION is not valid, because it has zero length.
// Check if entered end points lie on the function or not?
funcVals[0] = coor[0];
fparser.Parse(function, "x");
if (fabs(fparser.Eval(funcVals) - coor[1]) > 1e-5) return -2;
funcVals[0] = coor[2];
fparser.Parse(function, "x");
if (fabs(fparser.Eval(funcVals) - coor[3]) > 1e-5) return -3;
// Check if a FUNCTION the same as this one already exists or not.
for (int i = 0; i < MAX_PRIMITIVES; i++) {
if (primitives[i].getIsDeleted()) continue;
if (primitives[i].getType() != FUNCTION) continue;
dummyCoor = primitives[i].getEnteredPointCoor();
xx1 = dummyCoor[0];
xx2 = dummyCoor[2];
yy1 = dummyCoor[1];
yy2 = dummyCoor[3];
if ((x1 == xx1 && y1 == yy1 && x2 == xx2 && y2 == yy2) ||
(x1 == xx2 && y1 == yy2 && x2 == xx1 && y2 == yy1))
return -4; // The FUNCTION is not valid, because the same FUNCTION already exists.
}
return 1; // The FUNCTION is valid
} // End of function isFunctionVali()
bool StructuredMesh::isGeometryClosed()
{
int i, j, jj, k, usedByHowManyPrimitives;
int nEndPoints = 0, nEndPointMax;
float *endPointCoor; // x and y coordinates of the end points of a primitive.
float *dummyCoor; // Definition point coordinates of a primitive.
bool newPoint;
if (nPrimitives == 0) return FALSE;
nEndPointMax = 2 * nPrimitives;
endPointCoor = new float[2*nEndPointMax];
// First generate the array of end points
for (i = 0; i < MAX_PRIMITIVES; i++) {
if (primitives[i].getIsDeleted()) continue;
dummyCoor = primitives[i].getDefPointCoor(); // Cuneyt: Is there a problem here ?
for(j = 0; j < 2; j++) { // Loop for the two ends of the primitive
newPoint = TRUE;
if (j == 0) jj = 0; // First point of the primitive
if (j == 1) jj = primitives[i].getNumberOfDefPoints() - 1; // Last point of the primitive.
for (k = 0; k < nEndPoints; k++) {
if ( (dummyCoor[2*jj] == endPointCoor[2*k]) && (dummyCoor[2*jj+1] == endPointCoor[2*k+1]) ) {
newPoint = FALSE;
break;
}
}
if (newPoint) {
endPointCoor[2*nEndPoints] = dummyCoor[2*jj];
endPointCoor[2*nEndPoints+1] = dummyCoor[2*jj+1];
nEndPoints += 1;
}
}
}
// Than go through all these end points and check whether they are used only once or more than once.
for (k = 0; k < nEndPoints; k++) {
usedByHowManyPrimitives = 0;
for (i = 0; i < MAX_PRIMITIVES; i++) {
if (primitives[i].getIsDeleted()) continue;
dummyCoor = primitives[i].getDefPointCoor(); // Cuneyt: Is there a problem here ?
for(j = 0; j < 2; j++) { // Loop for the two ends of the primitive
newPoint = TRUE;
if (j == 0) jj = 0; // First point of the primitive
if (j == 1) jj = primitives[i].getNumberOfDefPoints() - 1; // Last point of the primitive.
if ( (dummyCoor[2*jj] == endPointCoor[2*k]) && (dummyCoor[2*jj+1] == endPointCoor[2*k+1]) )
usedByHowManyPrimitives += 1;
}
}
if (usedByHowManyPrimitives < 2) { // Indication of an open geometry
if (endPointCoor != NULL)
{
delete[] endPointCoor;
endPointCoor = NULL;
}
return FALSE;
}
}
if (endPointCoor != NULL)
{
delete[] endPointCoor;
endPointCoor = NULL;
}
return TRUE;
} // End of function isGeometryClosed()
void StructuredMesh::calculateNumberOfBlocks()
{
// Calculates the number of blocks used by the mesh.
int i, maxUsedBlockNumber = 0;
int* attachedBlock;
for (i = 0; i < MAX_PRIMITIVES; i++) {
if (primitives[i].getIsDeleted()) continue;
attachedBlock = primitives[i].getAttachedBlock();
if (attachedBlock[0] > maxUsedBlockNumber)
maxUsedBlockNumber = attachedBlock[0];
if (attachedBlock[1] > maxUsedBlockNumber)
maxUsedBlockNumber = attachedBlock[1];
}
nBlocks = maxUsedBlockNumber + 1;
} // End of function calculateNumberOfBlocks()
void StructuredMesh::calculateNumberOfPrimitivesOnFaces()
{
int i, p, block;
char face;
int* attachedBlock;
char* attachedFace;
for (p = 0; p < MAX_PRIMITIVES; p++) {
if (primitives[p].getIsDeleted()) continue;
attachedBlock = primitives[p].getAttachedBlock();
attachedFace = primitives[p].getAttachedFace();
for (i = 0; i < 2; i++) { // 2 is because a face can belong to 2 faces, at max.
block = attachedBlock[i];
face = attachedFace[i];
if (face == 'S')
blocks[block].faces[0].setnPrimitives( blocks[block].faces[0].getnPrimitives() + 1 );
if (face == 'E')
blocks[block].faces[1].setnPrimitives( blocks[block].faces[1].getnPrimitives() + 1 );
if (face == 'N')
blocks[block].faces[2].setnPrimitives( blocks[block].faces[2].getnPrimitives() + 1 );
if (face == 'W')
blocks[block].faces[3].setnPrimitives( blocks[block].faces[3].getnPrimitives() + 1 );
if (! primitives[p].getIsThereSecondBlock() ) break;
}
}
} // End of function calculateNumberOfPrimitivesOnFaces()
void StructuredMesh::allocateFaceData() // Cuneyt: This function can be moved under class Block.
{
for(int i=0; i<nBlocks; i++) {
blocks[i].faces[0].allocateData();
blocks[i].faces[1].allocateData();
blocks[i].faces[2].allocateData();
blocks[i].faces[3].allocateData();
}
}
void StructuredMesh::setFacePrimitives()
{
int i, j, p, block;
char face;
int* attachedBlock;
char* attachedFace;
int **counter; // Counts the number of primitives added to a face upto a certain instant.
counter = new int*[nBlocks];
for (i=0; i<nBlocks; i++)
counter[i] = new int[4]; // Each block has 4 faces.
for (i=0; i<nBlocks; i++)
for (j=0; j<4; j++)
counter[i][j] = 0;
for (p = 0; p < MAX_PRIMITIVES; p++) {
if (primitives[p].getIsDeleted()) continue;
attachedBlock = primitives[p].getAttachedBlock();
attachedFace = primitives[p].getAttachedFace();
for (i = 0; i < 2; i++) { // 2 is because a face can belong to 2 faces, at max.
block = attachedBlock[i];
face = attachedFace[i];
if (face == 'S') {
blocks[block].faces[0].appendPrimitive(counter[block][0], p);
counter[block][0] = counter[block][0] + 1;
}
if (face == 'E') {
blocks[block].faces[1].appendPrimitive(counter[block][1], p);
counter[block][1] = counter[block][1] + 1;
}
if (face == 'N') {
blocks[block].faces[2].appendPrimitive(counter[block][2], p);
counter[block][2] = counter[block][2] + 1;
}
if (face == 'W') {
blocks[block].faces[3].appendPrimitive(counter[block][3], p);
counter[block][3] = counter[block][3] + 1;
}
if (! primitives[p].getIsThereSecondBlock() ) break;
}
}
} // End of function setFacePrimitives()
void StructuredMesh::calculateNumberOfBoundaryPointsOnFaces()
{
int b, i, j, p, counter;
int *prims;
for (b = 0; b < nBlocks; b++) {
for (i = 0; i < 4; i++) {
prims = blocks[b].faces[i].getPrimitives();
counter = 0;
for (j = 0; j < blocks[b].faces[i].getnPrimitives(); j++) {
p = prims[j];
counter += primitives[p].getNumberOfPoints();
}
counter -= blocks[b].faces[i].getnPrimitives() - 1; // e.g. for a 3 primitive face, 2 points are counted twice.
blocks[b].faces[i].setnBoundaryPoints(counter);
}
}
}
bool StructuredMesh::isFacePrimitiveOrderingCorrect(void)
{
// Cuneyt: This function is very complicated. Even I can not follow it anymore.
// Not just a control but things like setOrderedList are alos done. but
// they need to be transfered to other functions.
int b, i, ii, j, jj, k, kk, p, r, rr;
int p1, p2, first, nPrimitivesOfThisBlock;
bool *isPrimitiveUsedInThisBlock;
int *primitivesOfThisBlock;
float x1, y1, x2, y2;
bool error = FALSE;
int *prims, *dummyList;
bool *dummyList2;
float *dummyCoor;
int *orderedPrimitives; // An ordered list of primitives starting from the first primitive of the South face, than East, North and finally West faces
bool *needReversing; // Some primitives may need reversing to form a closed loop for a block.
int nBlocks = getnBlocks(); // shortcut for number of total blocks
// First check if there are any faces with zero primitives.
for (i = 0; i < nBlocks; i++) {
for (j = 0; j < 4; j++) {
if (blocks[i].faces[j].getnPrimitives() == 0) {
return FALSE; // Cuneyt: A message such as "Block i, face j is not defined" can be provided.
}
}
}
for (b = 0; b < nBlocks; b++) {
isPrimitiveUsedInThisBlock = new bool[MAX_PRIMITIVES];
// Initialization
for (i = 0; i < MAX_PRIMITIVES; i++)
isPrimitiveUsedInThisBlock[i] = FALSE;
// Find the primitives used in this block
for (i = 0; i < 4; i++) {
for (j = 0; j < blocks[b].faces[i].getnPrimitives(); j++) {
prims = blocks[b].faces[i].getPrimitives();
k = prims[j];
isPrimitiveUsedInThisBlock[k] = TRUE;
}
}
// Find the number of primitives used in this block
nPrimitivesOfThisBlock = 0;
for (i = 0; i < MAX_PRIMITIVES; i++)
if (isPrimitiveUsedInThisBlock[i]) nPrimitivesOfThisBlock += 1;
primitivesOfThisBlock = new int[nPrimitivesOfThisBlock];
j = 0;
for (i = 0; i < MAX_PRIMITIVES; i++)
if ( isPrimitiveUsedInThisBlock[i] ) {
primitivesOfThisBlock[j] = i;
j++;
}
isPrimitiveUsedInThisBlock = NULL;
delete [] isPrimitiveUsedInThisBlock;
orderedPrimitives = new int[nPrimitivesOfThisBlock];
needReversing = new bool[nPrimitivesOfThisBlock];
// Initializations
for (i = 0; i < nPrimitivesOfThisBlock; i++) {
orderedPrimitives[i] = -1;
needReversing[i] = FALSE;
}
// Find the first primitive of the south face of this block
error = TRUE;
for (j = 0; j < blocks[b].faces[3].getnPrimitives(); j++) { // Primitives of the West face
prims = blocks[b].faces[3].getPrimitives();
p1 = prims[j];
for(k = 0; k < 2; k++) { // Loop for the two ends of the primitive
if (k == 0) kk = 0; // First point of the primitive.
if (k == 1) kk = primitives[p1].getNumberOfDefPoints() - 1; // Last point of the primitive.
dummyCoor = primitives[p1].getDefPointCoor();
x1 = dummyCoor[2*kk];
y1 = dummyCoor[2*kk+1];
for (p = 0; p < blocks[b].faces[0].getnPrimitives(); p++) { // Primitives of the South face
prims = blocks[b].faces[0].getPrimitives();
p2 = prims[p];
for(r = 0; r < 2; r++) { // Loop for the two ends of the primitive
if (r == 0) rr = 0; // First point of the primitive.
if (r == 1) rr = primitives[p2].getNumberOfDefPoints() - 1; // Last point of the primitive.
dummyCoor = primitives[p2].getDefPointCoor();
x2 = dummyCoor[2*rr];
y2 = dummyCoor[2*rr+1];
if (x1 == x2 && y1 == y2) { // Primitive p is the first primitive of the South face.
error = FALSE;
orderedPrimitives[0] = p2;
if (r == 1) needReversing[0] = TRUE;
goto ONE;
}
}
}
}
}
ONE: if (error) goto LAST; // error = TRUE means that West and South faces are not intersecting.
// Now starting from the first primitive, fill the orderedPrimitives[] and needReversing[] arrays.
for (i = 0; i < nPrimitivesOfThisBlock - 1; i++) {
p1 = orderedPrimitives[i];
error = TRUE;
// x1, y1 is the end point of p1.
dummyCoor = primitives[p1].getDefPointCoor();
if (needReversing[i]) {
x1 = dummyCoor[0];
y1 = dummyCoor[1];
} else {
x1 = dummyCoor[2*(primitives[p1].getNumberOfDefPoints()-1)];
y1 = dummyCoor[2*(primitives[p1].getNumberOfDefPoints()-1)+1];
}
// Now find another primitive with a starting or end point same as x1, y1
for (jj = 0; jj < nPrimitivesOfThisBlock; jj++) {
j = primitivesOfThisBlock[jj];
if (j == p1 ) continue;
for(k = 0; k < 2; k++) { // Loop for the two ends of primitive j
if (k == 0) kk = 0; // First point of the primitive.
if (k == 1) kk = primitives[j].getNumberOfDefPoints() - 1; // Last point of the primitive.
dummyCoor = primitives[j].getDefPointCoor();
x2 = dummyCoor[2*kk];
y2 = dummyCoor[2*kk+1];
if (x1 == x2 && y1 == y2) { // Primitives p1 and j have common points.
error = FALSE;
orderedPrimitives[i+1] = j;
if (k == 1) needReversing[i+1] = TRUE;
goto TWO;
}
}
}
TWO: if (error) goto LAST;
}
// Check if all the primitives of this block appear in the orderedList only once.
for (i = 0; i < nPrimitivesOfThisBlock; i++) {
j = primitivesOfThisBlock[i];
error = TRUE;
for (k = 0; k < nPrimitivesOfThisBlock; k++) {
if (j == orderedPrimitives[k]) {
error = FALSE;
break;
}
}
if (error) goto LAST;
}
// We can now copy the orderedPrimitives and needReversing arrays to the corresponding arrays of the faces.
for (j = 0; j < 4; j++) {
first = 0; // Ordered list number of the first primitive of this face.
for ( k = 0; k < j; k++)
first += blocks[b].faces[k].getnPrimitives();
for (k = 0; k < blocks[b].faces[j].getnPrimitives(); k++) {
kk = first + k;
blocks[b].faces[j].setOrderedList(k, orderedPrimitives[kk]);
blocks[b].faces[j].setNeedReversing(k, needReversing[kk]);
}
}
orderedPrimitives = NULL;
needReversing = NULL;
delete [] orderedPrimitives;
delete [] needReversing;
}
// Check if the faces meet at the corners or not?
error = FALSE;
for (b = 0; b < nBlocks; b++) {
for (i = 0; i < 4; i++) {
// Last primitive of this face
dummyList = blocks[b].faces[i].getOrderedList();
dummyList2 = blocks[b].faces[i].getNeedReversing();
k = dummyList[ blocks[b].faces[i].getnPrimitives() - 1 ];
dummyCoor = primitives[k].getDefPointCoor();
if (dummyList2[ blocks[b].faces[i].getnPrimitives() - 1 ]) {
x1 = dummyCoor[0];
y1 = dummyCoor[1];
} else {
x1 = dummyCoor[2*(primitives[k].getNumberOfDefPoints()-1)];
y1 = dummyCoor[2*(primitives[k].getNumberOfDefPoints()-1)+1];
}
// First primitive of the next face
if (i == 3) {
ii = 0; // Next face number
} else {
ii = i+1;
}
dummyList = blocks[b].faces[ii].getOrderedList();
dummyList2 = blocks[b].faces[ii].getNeedReversing();
kk = dummyList[0]; // Next primitive number
dummyCoor = primitives[kk].getDefPointCoor();
if (dummyList2[0]) {
x2 = dummyCoor[2*(primitives[kk].getNumberOfDefPoints()-1)];
y2 = dummyCoor[2*(primitives[kk].getNumberOfDefPoints()-1)+1];
} else {
x2 = dummyCoor[0];
y2 = dummyCoor[1];
}
if (x1 != x2 || y1 != y2) { // Problem at the corner
error = TRUE;
goto LAST;
}
}
}
LAST: orderedPrimitives = NULL;
needReversing = NULL;
primitivesOfThisBlock = NULL;
delete [] orderedPrimitives;
delete [] needReversing;
delete [] primitivesOfThisBlock;
// QString s;
if (error)
return FALSE;
else
return TRUE;
} // End of function isFacePrimitiveOrderingCorrect()
bool StructuredMesh::doSW_NEpointsMatch()
{
for (int b = 0; b < nBlocks; b++) {
if (blocks[b].faces[0].getnBoundaryPoints() != blocks[b].faces[2].getnBoundaryPoints() ||
blocks[b].faces[1].getnBoundaryPoints() != blocks[b].faces[3].getnBoundaryPoints())
return FALSE;
}
return TRUE;
}
void StructuredMesh::generateLinearTFIMesh()
{
int b, i, j, k, n, m, p;
int sMax, tMax;
float s, t;
float (*south)[2], (*east)[2], (*north)[2], (*west)[2]; // Face coordinates
float u, v, uv, (*dummy)[2];
int *dummyList;
bool *dummyList2;
float *dummyCoor;
/*
Linear TFI works like this (page 3-6 of Handbook of Grid Generation)
U_(s,t) = (1-s) * X_(0,t) + s * X_(1,t)
V_(s,t) = (1-t) * X_(s,0) + t * X_(s,1)
U_V_(s,t) = (1-s)(1-t) * X_(0,0) + (1-s)t * X_(0,1) + s(1-t) * X_(1,0) + st * X_(1,1)
X_(s,t) = U_(s,t) + V_(s,t) - U_V_(s,t)
Here
X_(0,t) is the coordinates of the West face
X_(1,t) is the coordinates of the East face
X_(s,0) is the coordinates of the South face
X_(s,1) is the coordinates of the North face
X_(0,0) is the coordinates of the West-South corner
X_(1,0) is the coordinates of the East-South corner
X_(0,1) is the coordinates of the West-North corner
X_(1,1) is the coordinates of the East-North corner
*/
for (b = 0; b < nBlocks; b++) {
// Allocate space for coordinates of the points of block b.
// Note: points are stored in a 1D row-first array.
sMax = blocks[b].faces[0].getnBoundaryPoints(); // Number of points in the s (ksi) direction
tMax = blocks[b].faces[1].getnBoundaryPoints(); // Number of points in the t (eta) direction
blocks[b].setnXpoints(sMax);
blocks[b].setnYpoints(tMax);
blocks[b].coordinates = NULL;
delete[] blocks[b].coordinates; // Cuneyt: Check this deallocaion
blocks[b].coordinates = new float[2*sMax*tMax];
// Allocate blocked cell array.
// Cuneyt: This is not the correct place for this.
blocks[b].isCellBlocked = new int[(sMax-1)*(tMax-1)];
for(i=0; i<(blocks[b].getnXpoints()-1)*(blocks[b].getnYpoints()-1); i++)
blocks[b].isCellBlocked[i] = 0; // Mark all the cells as not blocked.
// Allocate and setup face coordinates
south = new float[sMax][2]; // Cuneyt: change the size of these
north = new float[sMax][2];
east = new float[tMax][2];
west = new float[tMax][2];
for (i = 0; i < 4; i++) {
k = 0;
for (j = 0; j < blocks[b].faces[i].getnPrimitives(); j++) {
dummyList = blocks[b].faces[i].getOrderedList();
dummyList2 = blocks[b].faces[i].getNeedReversing();
p = dummyList[j];
dummyCoor = problem->mesh->primitives[p].getPointCoor();
if (dummyList2[j]) {
for (m = primitives[p].getNumberOfPoints() - 1; m >= 0; m--) {
if (j > 0 && m == primitives[p].getNumberOfPoints() - 1) continue; // Skip the first point of the second, third, etc primitive of a face.
for (n = 0; n < 2; n++) {
if (i == 0)
south[k][n] = dummyCoor[2*m+n];
else if (i == 1)
east[k][n] = dummyCoor[2*m+n];
else if (i == 2)
north[k][n] = dummyCoor[2*m+n];
else if (i == 3)
west[k][n] = dummyCoor[2*m+n];
}
k++;
}
} else {
for (m = 0; m < primitives[p].getNumberOfPoints(); m++) {
if (j > 0 && m == 0) continue; // Skip the first point of the second, third, etc primitive of a face.
for (n = 0; n < 2; n++) {
if (i == 0)
south[k][n] = dummyCoor[2*m+n];
else if (i == 1)
east[k][n] = dummyCoor[2*m+n];
else if (i == 2)
north[k][n] = dummyCoor[2*m+n];
else if (i == 3)
west[k][n] = dummyCoor[2*m+n];
}
k++;
}
}
}
}
// Reverse the north array.
dummy = new float[sMax][2];
for (i = 0; i < sMax; i++) {
dummy[i][0] = north[i][0];
dummy[i][1] = north[i][1];
}
for (i = 0; i < sMax; i++) {
north[sMax - i - 1][0] = dummy[i][0];
north[sMax - i - 1][1] = dummy[i][1];
}
// Reverse the west array.
dummy = NULL;
delete[] dummy; // Cuneyt: check this deallocation
dummy = new float[tMax][2];
for (i = 0; i < tMax; i++) {
dummy[i][0] = west[i][0];
dummy[i][1] = west[i][1];
}
for (i = 0; i < tMax; i++) {
west[tMax - i - 1][0] = dummy[i][0];
west[tMax - i - 1][1] = dummy[i][1];
}
dummy = NULL;
delete[] dummy;
for (i = 0; i < sMax; i++) {
s = float(i) / float(sMax - 1);
for (j = 0; j < tMax; j++) {
t = float(j) / float(tMax - 1);
k = i + j * sMax; // Will be used in blocks[b].coordinates[k][2]
for (n = 0; n < 2; n++) { // Space dimensions
u = (1-s) * west[j][n] + s * east[j][n];
v = (1-t) * south[i][n] + t * north[i][n];
uv= (1-s) * (1-t) * south[0][n] + (1-s) * t * north[0][n] + s * (1-t) * east[0][n] + s * t * north[sMax - 1][n];
blocks[b].coordinates[2*k+n] = u + v - uv;
}
}
}
south = NULL; delete[] south;
north = NULL; delete[] north;
east = NULL; delete[] east;
west = NULL; delete[] west;
} // End of block loop
} // End of function generateLinearTFIMesh()
void StructuredMesh::generateLaplaceMesh()
{
int b, i, j, ind, m, n, loop;
float g11, g12, g22, xtemp, ytemp;
// This version uses no control functions.
// Gauss Seidel iterative solution is used.
// First obtain an initial mesh with the linearTFIMesh
generateLinearTFIMesh();
for (b = 0; b < problem->mesh->getnBlocks(); b++) {
m = blocks[b].getnXpoints(); // Number of points in the s (ksi) direction
n = blocks[b].getnYpoints(); // Number of points in the t (eta) direction
for (loop=1; loop<=10; loop++)
{
for (j=1; j<n-1; j++)
{
for (i=1; i<m-1; i++)
{
ind = i+ m*j;
g11 = ((blocks[b].coordinates[2*(ind+1)] - blocks[b].coordinates[2*(ind-1)]) * (blocks[b].coordinates[2*(ind+1)] - blocks[b].coordinates[2*(ind-1)]) +
(blocks[b].coordinates[2*(ind+1)+1] - blocks[b].coordinates[2*(ind-1)+1]) * (blocks[b].coordinates[2*(ind+1)+1] - blocks[b].coordinates[2*(ind-1)+1]) ) / 4;
g22 = ((blocks[b].coordinates[2*(ind+m)] - blocks[b].coordinates[2*(ind-m)]) * (blocks[b].coordinates[2*(ind+m)] - blocks[b].coordinates[2*(ind-m)]) +
(blocks[b].coordinates[2*(ind+m)+1] - blocks[b].coordinates[2*(ind-m)+1]) * (blocks[b].coordinates[2*(ind+m)+1] - blocks[b].coordinates[2*(ind-m)+1]) ) / 4;
g12 = ((blocks[b].coordinates[2*(ind+1)] - blocks[b].coordinates[2*(ind-1)]) * (blocks[b].coordinates[2*(ind+m)] - blocks[b].coordinates[2*(ind-m)]) +
(blocks[b].coordinates[2*(ind+1)+1] - blocks[b].coordinates[2*(ind-1)+1]) * (blocks[b].coordinates[2*(ind+m)+1] - blocks[b].coordinates[2*(ind-m)+1]) ) / 4;
xtemp = 1/(2*(g11+g22))*(
g22*blocks[b].coordinates[2*(ind+1)] - 0.5*g12*blocks[b].coordinates[2*(ind+1+m)] + 0.5*g12*blocks[b].coordinates[2*(ind+1-m)] +
g11*blocks[b].coordinates[2*(ind+m)] + g11*blocks[b].coordinates[2*(ind-m)] +
g22*blocks[b].coordinates[2*(ind-1)] - 0.5*g12*blocks[b].coordinates[2*(ind-1-m)] + 0.5*g12*blocks[b].coordinates[2*(ind-1+m)] );
ytemp = 1/(2*(g11+g22))*(
g22*blocks[b].coordinates[2*(ind+1)+1] - 0.5*g12*blocks[b].coordinates[2*(ind+1+m)+1] + 0.5*g12*blocks[b].coordinates[2*(ind+1-m)+1] +
g11*blocks[b].coordinates[2*(ind+m)+1] + g11*blocks[b].coordinates[2*(ind-m)+1] +
g22*blocks[b].coordinates[2*(ind-1)+1] - 0.5*g12*blocks[b].coordinates[2*(ind-1-m)+1] + 0.5*g12*blocks[b].coordinates[2*(ind-1+m)+1] );
blocks[b].coordinates[2*ind] = xtemp;
blocks[b].coordinates[2*ind+1] = ytemp;
}
}
}
}
} // End of function generateLaplaceMesh()
| [
"cuneytsert@76eae623-603d-0410-ac33-4f885805322a"
]
| [
[
[
1,
979
]
]
]
|
8842301d79e5d1ba70575be2a90c96949025814c | 58b7b01fdb47eb6f05682f4f1fc26e69616a1c0b | /apps/myApps/meshClock/src/Layer.h | 66b2832cf172224396034dc6e1a38b6374ee82c2 | []
| no_license | brolin/openFrameworks | 8942e3152ad5e89645782a9ba6447ed8865263ee | d97c18b3b02dba8d5d39adc4d2541960449e024f | refs/heads/master | 2020-12-30T18:38:57.092170 | 2010-11-17T15:01:57 | 2010-11-17T15:01:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,110 | h | #ifndef LAYER_H_INCLUDED
#define LAYER_H_INCLUDED
#include "Vertex.h"
//port from my old processing code, looks messy ;)
//represents a single layer in mesh
class Layer
{
public:
Vertex *vertice;
Vertex *center;
float radius;
int numVertice;
Layer()
{
}
void init(int input)
{
vertice = new Vertex[input];
numVertice = input;
}
void compute(Vertex *_center, float r, float rx, float ry, float rz)
{
center = _center;
radius = r;
float seg = PI*2 / numVertice;
for(int i=0;i<numVertice;i++)
{
float _x = r * sin(ry + seg*i) + r * cos(rz*i);
float _z = r * cos(ry + seg*i) +r * cos(rx*i);
float _y = r * sin(rx*i) + r * sin(rz*i);
vertice[i].x = (_x + center->x);
vertice[i].y = (_y+ center->y);
vertice[i].z = (_z + center->z);
}
}
void render() //render single layer
{
glBegin(GL_TRIANGLE_FAN);
for(int i=0;i<numVertice;i++)
{
glVertex3f(vertice[i].x,vertice[i].y,vertice[i].z);
}
glEnd();
}
};
#endif // LAYER_H_INCLUDED
| [
"brolin@brolin-laptop.(none)"
]
| [
[
[
1,
54
]
]
]
|
cf9dfb604e0f31a460b6a82552a2b44129472092 | 85c93419769170bb411bb28e3ad4790bc5d98181 | /detectors/haardetector.cpp | db147218816c260a1bb47d73c6fc44f66b878c0b | []
| no_license | hirikesh/gorgoneye | 68d6a5774474cf541a7870fe35d0893ad54e99dd | fb81a4a059839bdf2d070dbda0ecde1ec7599f3a | refs/heads/master | 2021-01-10T10:00:43.506555 | 2010-11-04T23:09:31 | 2010-11-04T23:09:31 | 49,187,180 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,487 | cpp | #include <cv.h>
#include "haardetector.h"
#include "parameter.h"
using namespace cv;
HaarDetector::HaarDetector(Store *st, string td, double sf, int mn, bool fg, Size ms) :
BaseDetector(st, "Haar"),
scaleFactor(sf),
minNeighbours(mn),
flags(fg),
minSize(ms),
cClassifier(td)
{
// Create Parameters that will be used
_params.push_back(new RangeParam<double>("Scale Factor", Param::RANGE_DBL, &scaleFactor, 1.05, 2, 0.05));
_params.push_back(new RangeParam<int>("Min. Neighbours", Param::RANGE, &minNeighbours, 1, 7, 1));
_params.push_back(new RangeParam<int>("Min. Search Width", Param::RANGE, &minSize.width, 8, 200, 20));
_params.push_back(new RangeParam<int>("Min. Search Height", Param::RANGE, &minSize.height, 8, 200, 20));
_params.push_back(new ModeParam("Enable Canny Pruning", &flags, false));
}
bool HaarDetector::locate(const Mat& srcImg, const Mat& srcMsk, Rect& srcRoi)
{
vector<Rect> rois;
cClassifier.detectMultiScale(srcImg,
rois,
scaleFactor,
minNeighbours,
flags,
minSize);
if(rois.size()) {
srcRoi = rois[0];
for(unsigned int i = 1; i < rois.size(); i++)
if(rois[i].area() > srcRoi.area()) srcRoi = rois[i];
return true;
} else {
return false;
}
}
| [
"justcme@a09ac5dc-a04a-0975-72ff-3257ca587d63",
"malcoholic@a09ac5dc-a04a-0975-72ff-3257ca587d63"
]
| [
[
[
1,
1
],
[
4,
14
],
[
21,
34
],
[
36,
41
]
],
[
[
2,
3
],
[
15,
20
],
[
35,
35
]
]
]
|
635dec2fb29c81687630ac8290fa0ffa1db7f853 | e7c45d18fa1e4285e5227e5984e07c47f8867d1d | /SMDK/TransCritical/TTechQAL/QALPipe.cpp | 80938883235a4cd68e8d86265a7b8036435eed0a | []
| no_license | abcweizhuo/Test3 | 0f3379e528a543c0d43aad09489b2444a2e0f86d | 128a4edcf9a93d36a45e5585b70dee75e4502db4 | refs/heads/master | 2021-01-17T01:59:39.357645 | 2008-08-20T00:00:29 | 2008-08-20T00:00:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,627 | cpp | //================== SysCAD - Copyright Kenwalt (Pty) Ltd ===================
// Time-stamp: <2006-11-01 11:54:19 Rod Stephenson Transcritical Pty Ltd>
// $Nokeywords: $ QAL Extensions by Transcritical Technologies Pty Ltd
//===========================================================================
#include "stdafx.h"
#include "QALPipe.h"
#include <stdio.h>
#define dbgModels 1
//====================================================================================
const long idSuction = 0;
const long idDischarge = 1;
enum {iPipe, iReducer, iExpander, iBend, iOrifice, iValve, iThruTee, iBranchTee, nItems};
std::string sPipeData[] = {"Length", "Diameter", "dH", "Roughness"};
static MInOutDefStruct s_IODefs[]=
{
// Desc; Name; PortId; Rqd; Max; CnId, FracHgt; Options;
{ "Inlet", "In", idSuction, 1, 1, 0, 1.0f, MIO_In |MIO_Material },
{ "Outlet", "Out", idDischarge, 1, 1, 0, 1.0f, MIO_Out|MIO_Material },
{ NULL },
};
#define H 3
static double Drw_CQALPipe[] =
{
MDrw_Poly, -10, -H, -10, H,
MDrw_Poly, -10, 0, 10, 0,
MDrw_Poly, 10, -H, 10, H,
MDrw_End
};
#undef H
//---------------------------------------------------------------------------
DEFINE_TRANSFER_UNIT(CQALPipe, "QALPipe", DLL_GroupName)
void CQALPipe_UnitDef::GetOptions()
{
SetDefaultTag("TR");
SetDrawing("Pipe", Drw_CQALPipe);
SetTreeDescription("QAL:Flash Pipe");
SetDescription("TODO: Flash Train Liquor Pipe Model");
SetModelSolveMode(MSolveMode_Probal);
SetModelGroup(MGroup_Energy);
SetModelLicense(MLicense_HeatExchange);
};
//---------------------------------------------------------------------------
CQALPipe::CQALPipe(MUnitDefBase *pUnitDef, TaggedObject * pNd) :
MBaseMethod(pUnitDef, pNd)
{
//default values...
m_lItems =3;
}
//---------------------------------------------------------------------------
CQALPipe::~CQALPipe()
{
}
//---------------------------------------------------------------------------
void CQALPipe::Init()
{
SetIODefinition(s_IODefs);
}
//---------------------------------------------------------------------------
static MDDValueLst DDB1[] = { // Number of data sets
{iPipe, "Pipe", 0},
{iReducer, "Reducer", 0},
{iExpander, "Expander", 0},
{iBend, "Bend", 0},
{iOrifice, "Orifice", 0},
{iValve, "Valve", 0},
{iThruTee, "Thru Tee", 0},
{iBranchTee, "Branch Tee", 0},
NULL
};
bool CQALPipe::ValidateDataFields()
{//ensure parameters are within expected ranges
m_lItems = Range((long) 0, m_lItems, (long) maxItems);
return true;
}
std::string fmt(char * s, int i)
{
std::stringstream os;
os << s << i;
return os.str();
}
void CQALPipe::BuildDataFields()
{
DD.Long("Items", "", &m_lItems, MF_PARAMETER|MF_SET_ON_CHANGE);
DD.Double("MassFlow", "", &m_dMassFlow, MF_PARAMETER, MC_Qm);
DD.Page("Entry");
DD.Double("EntryHead", "", &m_dEntryHead, MF_PARAMETER, MC_L("m"));
DD.Text("Stuff");
for (int i=1; i<m_lItems; i++) {
DD.Page(fmt("Item", i).c_str());
DD.Long(fmt("Itype", i).c_str(), "", m_plItemArray+i, MF_PARAMETER|MF_SET_ON_CHANGE, DDB1);
switch ((int) m_plItemArray[i]) {
case iPipe:
DD.Text("Pipe...");
DD.Double(fmt("Diameter", i).c_str(), "", mItemData[i], MF_PARAMETER|MF_NO_FILING, MC_L("m"));
DD.Double(fmt("Length", i).c_str(), "", mItemData[i]+1, MF_PARAMETER|MF_NO_FILING, MC_L("m"));
DD.Double(fmt("dH", i).c_str(), "", mItemData[i]+2, MF_PARAMETER|MF_NO_FILING, MC_L("m"));
DD.Double(fmt("Roughness", i).c_str(), "", mItemData[i]+3, MF_PARAMETER|MF_NO_FILING, MC_L("mm"));
break;
case iReducer:
DD.Text("Reducer...");
DD.Double(fmt("Diameter", i).c_str(), "", mItemData[i], MF_PARAMETER|MF_NO_FILING, MC_L("m"));
DD.Double(fmt("Length", i).c_str(), "", mItemData[i], MF_PARAMETER|MF_NO_FILING, MC_L("m"));
DD.Double(fmt("dH", i).c_str(), "", mItemData[i]+2, MF_PARAMETER|MF_NO_FILING, MC_L("m"));
DD.Double(fmt("Roughness", i).c_str(), "", mItemData[i]+3, MF_PARAMETER|MF_NO_FILING, MC_L("mm"));
break;
case iExpander:
DD.Text("Expander...");
DD.Double(fmt("Length", i).c_str(), "", mItemData[i], MF_PARAMETER|MF_NO_FILING, MC_L("m"));
DD.Double(fmt("Diameter", i).c_str(), "", mItemData[i]+1, MF_PARAMETER|MF_NO_FILING, MC_L("m"));
DD.Double(fmt("dH", i).c_str(), "", mItemData[i]+2, MF_PARAMETER|MF_NO_FILING, MC_L("m"));
DD.Double(fmt("Roughness", i).c_str(), "", mItemData[i]+3, MF_PARAMETER|MF_NO_FILING, MC_L("mm"));
break;
case iValve:
DD.Text("Valve...");
DD.Double(fmt("K", i).c_str(), "", mItemData[i], MF_PARAMETER|MF_NO_FILING, MC_);
break;
case iOrifice:
DD.Text("Orifice...");
DD.Double(fmt("Length", i).c_str(), "", mItemData[i], MF_PARAMETER|MF_NO_FILING, MC_L("m"));
DD.Double(fmt("Diameter", i).c_str(), "", mItemData[i]+1, MF_PARAMETER|MF_NO_FILING, MC_L("m"));
break;
}
}
DD.Page("Exit");
DD.Text("More Stuff");
// DD.Long("Operation", "", &m_lPumpMode , MF_PARAMETER|MF_SET_ON_CHANGE, DDPumpMode);
// DD.Double("PumpRPM", "", &m_dRPM, MF_PARAMETER, MC_pS);
// DD.Double("DeltaP", "", &m_dP, MF_RESULT, MC_P);
// DD.Double("Qv", "", &m_dQv, MF_RESULT, MC_Qv);
// DD.Double("Power", "", &m_dPwr, MF_RESULT, MC_Pwr);
// DD.Page("PumpData");
// DD.CheckBox("RawData", "", &m_bRawData, MF_PARAMETER|MF_SET_ON_CHANGE);
// DD.Long("DataSets", "", &iPD, MF_PARAMETER|MF_SET_ON_CHANGE, iPDSets);
// DD.Text("DataSet 1");
// DD.Double("RPM1", "", m_dRPMs, MF_PARAMETER, MC_pS);
// DD.Double("dPmax1", "", m_dPmax, MF_PARAMETER, MC_P); // Pressure boost for pump stalled
// DD.Text("Data");
// DD.Show(!m_bRawData);
// DD.Double("a11", "", &m_dPumpData[0][0], MF_PARAMETER, MC_None);
// DD.Double("a12", "", &m_dPumpData[0][1], MF_PARAMETER, MC_None);
// DD.Double("a13", "", &m_dPumpData[0][2], MF_PARAMETER, MC_None);
// DD.Show(m_bRawData);
// DD.Double("dP11", "", &m_dRawPumpData[0][0][0], MF_PARAMETER, MC_P);
// DD.Double("Q11", "", &m_dRawPumpData[0][0][1], MF_PARAMETER, MC_Qv);
// DD.Double("dP12", "", &m_dRawPumpData[0][1][0], MF_PARAMETER, MC_P);
// DD.Double("Q12", "", &m_dRawPumpData[0][1][1], MF_PARAMETER, MC_Qv);
// DD.Double("dP13", "", &m_dRawPumpData[0][2][0], MF_PARAMETER, MC_P);
// DD.Double("Q13", "", &m_dRawPumpData[0][2][1], MF_PARAMETER, MC_Qv);
// DD.Double("dP14", "", &m_dRawPumpData[0][3][0], MF_PARAMETER, MC_P);
// DD.Double("Q14", "", &m_dRawPumpData[0][3][1], MF_PARAMETER, MC_Qv);
// DD.Show(iPD>0);
// DD.Text("DataSet 2");
// DD.Double("RPM2", "", m_dRPMs+1, MF_PARAMETER, MC_pS);
// DD.Double("dPmax2", "", m_dPmax+1, MF_PARAMETER, MC_P); // Pressure boost for pump stalled
// DD.Text("Data");
// DD.Show(!m_bRawData && iPD>0);
// DD.Double("a21", "", &m_dPumpData[1][0], MF_PARAMETER, MC_None);
// DD.Double("a22", "", &m_dPumpData[1][1], MF_PARAMETER, MC_None);
// DD.Double("a23", "", &m_dPumpData[1][2], MF_PARAMETER, MC_None);
// DD.Show(m_bRawData && iPD>0);
// DD.Double("dP21", "", &m_dRawPumpData[1][0][0], MF_PARAMETER, MC_P);
// DD.Double("Q21", "", &m_dRawPumpData[1][0][1], MF_PARAMETER, MC_Qv);
// DD.Double("dP22", "", &m_dRawPumpData[1][1][0], MF_PARAMETER, MC_P);
// DD.Double("Q22", "", &m_dRawPumpData[1][1][1], MF_PARAMETER, MC_Qv);
// DD.Double("dP23", "", &m_dRawPumpData[1][2][0], MF_PARAMETER, MC_P);
// DD.Double("Q23", "", &m_dRawPumpData[1][2][1], MF_PARAMETER, MC_Qv);
// DD.Double("dP24", "", &m_dRawPumpData[1][3][0], MF_PARAMETER, MC_P);
// DD.Double("Q24", "", &m_dRawPumpData[1][3][1], MF_PARAMETER, MC_Qv);
// DD.Show(iPD>1);
// DD.Text("DataSet 3");
// DD.Double("RPM3", "", m_dRPMs+2, MF_PARAMETER, MC_pS);
// DD.Double("dPmax3", "", m_dPmax+2, MF_PARAMETER, MC_P); // Pressure boost for pump stalled
// DD.Text("Data");
// DD.Show(!m_bRawData && iPD>1);
// DD.Double("a31", "", &m_dPumpData[2][0], MF_PARAMETER, MC_None);
// DD.Double("a32", "", &m_dPumpData[2][1], MF_PARAMETER, MC_None);
// DD.Double("a33", "", &m_dPumpData[2][2], MF_PARAMETER, MC_None);
// DD.Show(m_bRawData && iPD>1);
// DD.Double("dP31", "", &m_dRawPumpData[2][0][0], MF_PARAMETER, MC_P);
// DD.Double("Q31", "", &m_dRawPumpData[2][0][1], MF_PARAMETER, MC_Qv);
// DD.Double("dP32", "", &m_dRawPumpData[2][1][0], MF_PARAMETER, MC_P);
// DD.Double("Q32", "", &m_dRawPumpData[2][1][1], MF_PARAMETER, MC_Qv);
// DD.Double("dP33", "", &m_dRawPumpData[2][2][0], MF_PARAMETER, MC_P);
// DD.Double("Q33", "", &m_dRawPumpData[2][2][1], MF_PARAMETER, MC_Qv);
// DD.Double("dP34", "", &m_dRawPumpData[2][3][0], MF_PARAMETER, MC_P);
// DD.Double("Q34", "", &m_dRawPumpData[2][3][1], MF_PARAMETER, MC_Qv);
// DD.Show(iPD>2);
// DD.Text("DataSet 4");
// DD.Double("RPM4", "", m_dRPMs+3, MF_PARAMETER, MC_pS);
// DD.Double("dPmax4", "", m_dPmax+3, MF_PARAMETER, MC_P); // Pressure boost for pump stalled
// DD.Text("Data");
// DD.Show(!m_bRawData && iPD>2);
// DD.Double("a41", "", &m_dPumpData[3][0], MF_PARAMETER, MC_None);
// DD.Double("a42", "", &m_dPumpData[3][1], MF_PARAMETER, MC_None);
// DD.Double("a43", "", &m_dPumpData[3][2], MF_PARAMETER, MC_None);
// DD.Show(m_bRawData && iPD>2);
// DD.Double("dP41", "", &m_dRawPumpData[3][0][0], MF_PARAMETER, MC_P);
// DD.Double("Q41", "", &m_dRawPumpData[3][0][1], MF_PARAMETER, MC_Qv);
// DD.Double("dP42", "", &m_dRawPumpData[3][1][0], MF_PARAMETER, MC_P);
// DD.Double("Q42", "", &m_dRawPumpData[3][1][1], MF_PARAMETER, MC_Qv);
// DD.Double("dP43", "", &m_dRawPumpData[3][2][0], MF_PARAMETER, MC_P);
// DD.Double("Q43", "", &m_dRawPumpData[3][2][1], MF_PARAMETER, MC_Qv);
// DD.Double("dP44", "", &m_dRawPumpData[3][3][0], MF_PARAMETER, MC_P);
// DD.Double("Q44", "", &m_dRawPumpData[3][3][1], MF_PARAMETER, MC_Qv);
// DD.Show();
// DD.Page("Efficiency");
// DD.Text("Peak Efficiency");
// DD.Double("eMax", "", &m_dEffData[0][0], MF_PARAMETER, MC_None);
// DD.Double("QMax", "", &m_dEffData[0][1], MF_PARAMETER, MC_Qv);
// DD.Text("Curve Points");
// DD.Double("e1", "", &m_dEffData[1][0], MF_PARAMETER, MC_None);
// DD.Double("Q1", "", &m_dEffData[1][1], MF_PARAMETER, MC_Qv);
// DD.Double("e2", "", &m_dEffData[2][0], MF_PARAMETER, MC_None);
// DD.Double("Q2", "", &m_dEffData[2][1], MF_PARAMETER, MC_Qv);
// DD.Double("e3", "", &m_dEffData[3][0], MF_PARAMETER, MC_None);
// DD.Double("Q3", "", &m_dEffData[3][1], MF_PARAMETER, MC_Qv);
// DD.Double("e4", "", &m_dEffData[4][0], MF_PARAMETER, MC_None);
// DD.Double("Q4", "", &m_dEffData[4][1], MF_PARAMETER, MC_Qv);
// DD.Text("Coeffs");
// DD.Double("a2", "", m_dEff, MF_RESULT|MF_NO_FILING, MC_None);
// DD.Double("a3", "", m_dEff+1, MF_RESULT|MF_NO_FILING, MC_None);
// DD.Double("a4", "", m_dEff+2, MF_RESULT|MF_NO_FILING, MC_None);
// DD.Text("Test");
// DD.Double("QQ", "", &m_dQQ, MF_PARAMETER, MC_Qv);
// DD.Double("Eff", "", &m_dEf, MF_RESULT|MF_NO_FILING, MC_None);
/*
DD.Page("Debug");
DD.Double("tmp1", "", &m_tmp1, MF_RESULT|MF_NO_FILING, MC_None);
DD.Double("tmp2", "", &m_tmp2, MF_RESULT|MF_NO_FILING, MC_None);
DD.Double("tmp3", "", &m_tmp3, MF_RESULT|MF_NO_FILING, MC_None);
DD.Double("tmp4", "", &m_tmp4, MF_RESULT|MF_NO_FILING, MC_None);
DD.Double("tmp5", "", &m_tmp5, MF_RESULT|MF_NO_FILING, MC_None);
*/
}
double CQALPipe::findDP()
{
double dP = -5.0;
return dP;
}
//---------------------------------------------------------------------------
bool CQALPipe::ConfigureJoins()
{
MBaseMethod::ConfigureJoins();
//Joins.Count=2;
return true;
}
//---------------------------------------------------------------------------
bool CQALPipe::EvalJoinPressures()
{
if (1)
{//set pressures at each join (pipes connected to unit)
for (int j=0; j<Joins.Count; j++) {
double Pj=Joins[j].GetProbalPIn();
Joins[j].SetProbalP(Pj+m_dP, false, true);
}
return true;
}
else
{
//INCOMPLETECODE()
}
return false;
}
//---------------------------------------------------------------------------
void CQALPipe::EvalProducts()
{
try {
MStreamI PipeI;
MStream & PipeO = FlwIOs[FlwIOs.First[idDischarge]].Stream;
FlwIOs.AddMixtureIn_Id(PipeI, idSuction);
PipeO = PipeI;
m_dP = findDP();
}
catch (MMdlException &e)
{
Log.Message(MMsg_Error, e.Description);
}
catch (MFPPException &e)
{
e.ClearFPP();
Log.Message(MMsg_Error, e.Description);
}
catch (MSysException &e)
{
Log.Message(MMsg_Error, e.Description);
}
catch (...)
{
Log.Message(MMsg_Error, "Some Unknown Exception occured");
}
}
//--------------------------------------------------------------------------
void CQALPipe::ClosureInfo(MClosureInfo & CI)
{
if (CI.DoFlows())
{
// HtIn += dActualDuty; //ensure heat balance
}
}
//====================================================================================
| [
"[email protected]"
]
| [
[
[
1,
390
]
]
]
|
9ba84bc992fb95203b8c0b67bfdb4aed73580e73 | f13f46fbe8535a7573d0f399449c230a35cd2014 | /JelloMan/ALOptions.cpp | b3775ef371e74a0219465eacfa0d10d0c28dfd28 | []
| no_license | fangsunjian/jello-man | 354f1c86edc2af55045d8d2bcb58d9cf9b26c68a | 148170a4834a77a9e1549ad3bb746cb03470df8f | refs/heads/master | 2020-12-24T16:42:11.511756 | 2011-06-14T10:16:51 | 2011-06-14T10:16:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,150 | cpp | #include "ALOptions.h"
#include "ContentManager.h"
/* CONSTRUCTOR - DESTRUCTOR */
ALOptions::ALOptions() : m_bUseAO(false)
{
m_SSAOSettings.radius = 0.1f;
m_SSAOSettings.intensity = 14.0f;
m_SSAOSettings.scale = 2.0f;
m_SSAOSettings.bias = 0.03f;
m_SSAOSettings.minIterations = 8;
m_SSAOSettings.maxIterations = 64;
m_AddSubtractButtonImages.push_back(Content->LoadImage(_T("../Content/Images/Editor/add_small_normal.png")));
m_AddSubtractButtonImages.push_back(Content->LoadImage(_T("../Content/Images/Editor/add_small_hover.png")));
m_AddSubtractButtonImages.push_back(Content->LoadImage(_T("../Content/Images/Editor/subtract_small_normal.png")));
m_AddSubtractButtonImages.push_back(Content->LoadImage(_T("../Content/Images/Editor/subtract_small_hover.png")));
m_UseAOButtonImages.push_back(Content->LoadImage(_T("../Content/Images/Editor/checkbox_empty_normal.png")));
m_UseAOButtonImages.push_back(Content->LoadImage(_T("../Content/Images/Editor/checkbox_full_normal.png")));
m_Buttons["USEAO"] = new Button(20,150,15,15, true);
m_Buttons["USEAO"]->SetNormalState(m_UseAOButtonImages[1]);
m_Buttons["USEAO"]->SetHoverState(m_UseAOButtonImages[1]);
m_Buttons["USEAO"]->SetDownState(m_UseAOButtonImages[1]);
m_Buttons["USEAO"]->SetDeactivatedState(m_UseAOButtonImages[0]);
m_Buttons["USEAO"]->SetDeactivatedStateHover(m_UseAOButtonImages[0]);
m_Buttons["USEAO"]->SetDeactivatedStateDown(m_UseAOButtonImages[0]);
m_Buttons["USEAO"]->SetState(Button::STATE_DEACTIVATED);
m_Buttons["RADIUS_ADD"] = new Button(40,230,15,15);
m_Buttons["RADIUS_ADD"]->SetNormalState(m_AddSubtractButtonImages[0]);
m_Buttons["RADIUS_ADD"]->SetHoverState(m_AddSubtractButtonImages[1]);
m_Buttons["RADIUS_ADD"]->SetDownState(m_AddSubtractButtonImages[1]);
m_Buttons["RADIUS_SUB"] = new Button(20,230,15,15);
m_Buttons["RADIUS_SUB"]->SetNormalState(m_AddSubtractButtonImages[2]);
m_Buttons["RADIUS_SUB"]->SetHoverState(m_AddSubtractButtonImages[3]);
m_Buttons["RADIUS_SUB"]->SetDownState(m_AddSubtractButtonImages[3]);
m_Buttons["INTENSITY_ADD"] = new Button(40,289,15,15);
m_Buttons["INTENSITY_ADD"]->SetNormalState(m_AddSubtractButtonImages[0]);
m_Buttons["INTENSITY_ADD"]->SetHoverState(m_AddSubtractButtonImages[1]);
m_Buttons["INTENSITY_ADD"]->SetDownState(m_AddSubtractButtonImages[1]);
m_Buttons["INTENSITY_SUB"] = new Button(20,289,15,15);
m_Buttons["INTENSITY_SUB"]->SetNormalState(m_AddSubtractButtonImages[2]);
m_Buttons["INTENSITY_SUB"]->SetHoverState(m_AddSubtractButtonImages[3]);
m_Buttons["INTENSITY_SUB"]->SetDownState(m_AddSubtractButtonImages[3]);
m_Buttons["SCALE_ADD"] = new Button(40,348,15,15);
m_Buttons["SCALE_ADD"]->SetNormalState(m_AddSubtractButtonImages[0]);
m_Buttons["SCALE_ADD"]->SetHoverState(m_AddSubtractButtonImages[1]);
m_Buttons["SCALE_ADD"]->SetDownState(m_AddSubtractButtonImages[1]);
m_Buttons["SCALE_SUB"] = new Button(20,348,15,15);
m_Buttons["SCALE_SUB"]->SetNormalState(m_AddSubtractButtonImages[2]);
m_Buttons["SCALE_SUB"]->SetHoverState(m_AddSubtractButtonImages[3]);
m_Buttons["SCALE_SUB"]->SetDownState(m_AddSubtractButtonImages[3]);
m_Buttons["BIAS_ADD"] = new Button(40,407,15,15);
m_Buttons["BIAS_ADD"]->SetNormalState(m_AddSubtractButtonImages[0]);
m_Buttons["BIAS_ADD"]->SetHoverState(m_AddSubtractButtonImages[1]);
m_Buttons["BIAS_ADD"]->SetDownState(m_AddSubtractButtonImages[1]);
m_Buttons["BIAS_SUB"] = new Button(20,407,15,15);
m_Buttons["BIAS_SUB"]->SetNormalState(m_AddSubtractButtonImages[2]);
m_Buttons["BIAS_SUB"]->SetHoverState(m_AddSubtractButtonImages[3]);
m_Buttons["BIAS_SUB"]->SetDownState(m_AddSubtractButtonImages[3]);
m_Buttons["MIN_IT_ADD"] = new Button(40,466,15,15);
m_Buttons["MIN_IT_ADD"]->SetNormalState(m_AddSubtractButtonImages[0]);
m_Buttons["MIN_IT_ADD"]->SetHoverState(m_AddSubtractButtonImages[1]);
m_Buttons["MIN_IT_ADD"]->SetDownState(m_AddSubtractButtonImages[1]);
m_Buttons["MIN_IT_SUB"] = new Button(20,466,15,15);
m_Buttons["MIN_IT_SUB"]->SetNormalState(m_AddSubtractButtonImages[2]);
m_Buttons["MIN_IT_SUB"]->SetHoverState(m_AddSubtractButtonImages[3]);
m_Buttons["MIN_IT_SUB"]->SetDownState(m_AddSubtractButtonImages[3]);
m_Buttons["MAX_IT_ADD"] = new Button(40,525,15,15);
m_Buttons["MAX_IT_ADD"]->SetNormalState(m_AddSubtractButtonImages[0]);
m_Buttons["MAX_IT_ADD"]->SetHoverState(m_AddSubtractButtonImages[1]);
m_Buttons["MAX_IT_ADD"]->SetDownState(m_AddSubtractButtonImages[1]);
m_Buttons["MAX_IT_SUB"] = new Button(20,525,15,15);
m_Buttons["MAX_IT_SUB"]->SetNormalState(m_AddSubtractButtonImages[2]);
m_Buttons["MAX_IT_SUB"]->SetHoverState(m_AddSubtractButtonImages[3]);
m_Buttons["MAX_IT_SUB"]->SetDownState(m_AddSubtractButtonImages[3]);
m_pFont = Content->LoadTextFormat(_T("Verdana"),12, false,false);
}
ALOptions::~ALOptions()
{
for_each(m_Buttons.begin(), m_Buttons.end(), [&](pair<string, Button*> p)
{
delete p.second;
});
}
/* GENERAL */
void ALOptions::Tick()
{
// buttons
for_each(m_Buttons.begin(), m_Buttons.end(), [&](pair<string, Button*> p)
{
p.second->Tick();
});
// radius
if (m_Buttons["RADIUS_ADD"]->Clicked())
m_SSAOSettings.radius += 0.02f;
else if (m_Buttons["RADIUS_SUB"]->Clicked())
m_SSAOSettings.radius -= 0.02f;
// intensity
if (m_Buttons["INTENSITY_ADD"]->Clicked())
m_SSAOSettings.intensity += 0.5f;
else if (m_Buttons["INTENSITY_SUB"]->Clicked())
m_SSAOSettings.intensity -= 0.5f;
// scale
if (m_Buttons["SCALE_ADD"]->Clicked())
m_SSAOSettings.scale += 0.2f;
else if (m_Buttons["SCALE_SUB"]->Clicked())
m_SSAOSettings.scale -= 0.2f;
// bias
if (m_Buttons["BIAS_ADD"]->Clicked())
m_SSAOSettings.bias += 0.01f;
else if (m_Buttons["BIAS_SUB"]->Clicked())
m_SSAOSettings.bias -= 0.01f;
// minIterations
if (m_Buttons["MIN_IT_ADD"]->Clicked())
m_SSAOSettings.minIterations += 2;
else if (m_Buttons["MIN_IT_SUB"]->Clicked())
m_SSAOSettings.minIterations -= 2;
// maxIterations
if (m_Buttons["MAX_IT_ADD"]->Clicked())
m_SSAOSettings.maxIterations += 2;
else if (m_Buttons["MAX_IT_SUB"]->Clicked())
m_SSAOSettings.maxIterations -= 2;
if (m_Buttons["USEAO"]->IsActive())
m_bUseAO = true;
else
m_bUseAO = false;
}
void ALOptions::Draw()
{
// buttons
for_each(m_Buttons.begin(), m_Buttons.end(), [&](pair<string, Button*> p)
{
p.second->Show();
});
tstringstream stream;
stream.precision(3);
stream << _T("SSAO:\n\n\n\n");
stream << _T("Use AO:\n\n\n\n\n\n");
stream << _T("Radius: ") << m_SSAOSettings.radius << _T("\n\n\n\n");
stream << _T("Intensity: ") << m_SSAOSettings.intensity << _T("\n\n\n\n");
stream << _T("Scale: ") << m_SSAOSettings.scale << _T("\n\n\n\n");
stream << _T("Bias: ") << m_SSAOSettings.bias << _T("\n\n\n\n");
stream << _T("Min Iterations: ") << m_SSAOSettings.minIterations << _T("\n\n\n\n");
stream << _T("Max Iterations: ") << m_SSAOSettings.maxIterations << _T("\n\n\n\n");
BX2D->SetColor(255,255,255);
BX2D->SetFont(m_pFont);
BX2D->DrawString(stream.str(), 10, 60);
} | [
"[email protected]"
]
| [
[
[
1,
178
]
]
]
|
e65121cc15784c8b15960ba2d1031997377b14b2 | 195c3fb86c574671374cd1c227ee2c2e4ce96863 | /glslprogram.cpp | dc4816690bcee1545097742ce8323ec4eaa8631c | []
| no_license | russellhaering/cs450-project4 | 32d6f4507a0de60d56af13d48ac47306e0571700 | 7aab23e8abbaeba348c87975775afbdefde03fc4 | refs/heads/master | 2021-01-23T20:50:59.673993 | 2010-11-29T23:55:16 | 2010-11-29T23:55:16 | 1,104,637 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,231 | cpp | #ifndef GLSLPROGRAM_H
#define GLSLPROGRAM_H
#include "glslprogram.h"
#include <map>
void
GLSLProgram::Create( char *vfile, char *gfile, char *ffile )
{
CanDoFragmentShader = IsExtensionSupported( "GL_ARB_fragment_shader" );
CanDoGeometryShader = IsExtensionSupported( "GL_EXT_geometry_shader4" );
CanDoVertexShader = IsExtensionSupported( "GL_ARB_vertex_shader" );
InputTopology = GL_TRIANGLES;
OutputTopology = GL_TRIANGLE_STRIP;
Vshader = Gshader = Fshader = 0;
Program = 0;
AttributeLocs.clear();
UniformLocs.clear();
Verbose = false;
this->Program = glCreateProgram();
CheckGlErrors( "glCreateProgram" );
if( vfile != NULL && vfile[0] != '\0' )
{
if( ! CanDoVertexShader )
{
fprintf( stderr, "Warning: this system cannot handle vertex shaders\n" );
}
this->Vshader = LoadVertexShader( vfile );
int status = CompileShader( this->Vshader );
if( status != 0 )
{
if( this->Verbose )
fprintf( stderr, "Shader '%s' compiled.\n", vfile );
AttachShader( this->Vshader );
}
else
{
fprintf( stderr, "Shader '%s' did not compile.\n", vfile );
}
}
if( gfile != NULL && gfile[0] != '\0' )
{
if( ! CanDoGeometryShader )
{
fprintf( stderr, "Warning: this system cannot handle geometry shaders\n" );
}
this->Gshader = LoadGeometryShader( gfile );
int status = CompileShader( this->Gshader );
if( status != 0 )
{
if( this->Verbose )
fprintf( stderr, "Shader '%s' compiled.\n", gfile );
AttachShader( Gshader );
}
else
{
fprintf( stderr, "Shader '%s' did not compile.\n", gfile );
}
}
if( ffile != NULL && ffile[0] != '\0' )
{
if( ! CanDoFragmentShader )
{
fprintf( stderr, "Warning: this system cannot handle fragment shaders\n" );
}
this->Fshader = LoadFragmentShader( ffile );
int status = CompileShader( this->Fshader );
if( status != 0 )
{
if( this->Verbose )
fprintf( stderr, "Shader '%s' compiled.\n", ffile );
AttachShader( Fshader );
}
else
{
fprintf( stderr, "Shader '%s' did not compile.\n", ffile );
}
}
LinkProgram();
};
// default constructor:
GLSLProgram::GLSLProgram()
{
Create( NULL, NULL, NULL );
}
// alternate constructor with a geometry shader:
GLSLProgram::GLSLProgram( char *vfile, char *gfile, char *ffile )
{
Create( vfile, gfile, ffile );
}
// alternate constructor with no geometry shader:
GLSLProgram::GLSLProgram( char *vfile, char *ffile )
{
Create( vfile, NULL, ffile );
}
GLuint
GLSLProgram::LoadVertexShader( char *vfile )
{
GLuint shader = glCreateShader( GL_VERTEX_SHADER );
if( LoadShader( vfile, shader ) != 0 )
{
if( this->Verbose )
fprintf( stderr, "Vertex shader '%s' loaded.\n", vfile );
return shader;
}
else
{
fprintf( stderr, "Vertex shader '%s' failed to load.\n", vfile );
glDeleteShader( shader );
return 0;
}
};
GLuint
GLSLProgram::LoadGeometryShader( char *gfile )
{
GLuint shader = glCreateShader( GL_GEOMETRY_SHADER_EXT );
if( LoadShader( gfile, shader ) != 0 )
{
if( this->Verbose )
fprintf( stderr, "Geometry shader '%s' loaded.\n", gfile );
return shader;
}
else
{
fprintf( stderr, "Geometry shader '%s' failed to load.\n", gfile );
glDeleteShader( shader );
return 0;
}
};
GLuint
GLSLProgram::LoadFragmentShader( char *ffile )
{
GLuint shader = glCreateShader( GL_FRAGMENT_SHADER );
if( LoadShader( ffile, shader ) != 0 )
{
if( this->Verbose )
fprintf( stderr, "Fragment shader '%s' loaded.\n", ffile );
return shader;
}
else
{
fprintf( stderr, "Fragment shader '%s' failed to load.\n", ffile );
glDeleteShader( shader );
return 0;
}
};
int
GLSLProgram::LoadShader( const char* fname, GLuint shader )
{
FILE * in = fopen( fname, "rb" );
if( in == NULL )
{
fprintf( stderr, "Cannot open shader file '%s'\n", fname );
return 0;
}
fseek( in, 0, SEEK_END );
int length = ftell( in );
fseek( in, 0, SEEK_SET ); // rewind
GLubyte * buf = new GLubyte[length+1];
fread( buf, sizeof(GLubyte), length, in );
buf[length] = '\0';
fclose( in ) ;
// Now, tell GL about the source!
glShaderSource( shader, 1, (const char**)&buf, NULL );
delete [] buf;
CheckGlErrors( "LoadShader:ShaderSource" );
return 1;
};
int
GLSLProgram::CompileShader( GLuint shader )
{
glCompileShader( shader );
GLint infoLogLen;
GLint compileStatus;
CheckGlErrors( "CompileShader:" );
glGetShaderiv( shader, GL_COMPILE_STATUS, &compileStatus );
if( compileStatus == 0 )
{
fprintf( stderr, "Failed to compile shader.\n" );
glGetShaderiv( shader, GL_INFO_LOG_LENGTH, &infoLogLen );
if( infoLogLen > 0)
{
GLchar *infoLog = new GLchar[infoLogLen+1];
glGetShaderInfoLog( shader, infoLogLen, NULL, infoLog);
infoLog[infoLogLen] = '\0';
FILE * file = fopen( "glsllog.txt", "w");
fprintf( file, "\n%s\n", infoLog );
fprintf( stderr, "\n%s\n", infoLog );
fclose( file );
delete [] infoLog;
}
glDeleteShader( shader );
return 0;
}
CheckGlErrors("LoadShader:Compile 2");
return 1;
};
void
GLSLProgram::AttachShader( GLuint shader )
{
glAttachShader( this->Program, shader );
};
int
GLSLProgram::LinkProgram()
{
if( Gshader != 0 )
{
glProgramParameteriEXT( Program, GL_GEOMETRY_INPUT_TYPE_EXT, InputTopology );
glProgramParameteriEXT( Program, GL_GEOMETRY_OUTPUT_TYPE_EXT, OutputTopology );
glProgramParameteriEXT( Program, GL_GEOMETRY_VERTICES_OUT_EXT, 1024 );
}
glLinkProgram( Program );
CheckGlErrors("LoadShader:Link 1");
GLchar* infoLog;
GLint infoLogLen;
GLint linkStatus;
glGetProgramiv( this->Program, GL_LINK_STATUS, &linkStatus );
CheckGlErrors("LoadShader:Link 2");
if( linkStatus == 0 )
{
glGetProgramiv( this->Program, GL_INFO_LOG_LENGTH, &infoLogLen );
fprintf( stderr, "Failed to link program -- Info Log Length = %d\n", infoLogLen );
if( infoLogLen > 0 )
{
infoLog = new GLchar[infoLogLen+1];
glGetProgramInfoLog( this->Program, infoLogLen, NULL, infoLog );
infoLog[infoLogLen] = '\0';
fprintf( stderr, "Info Log:\n%s\n", infoLog );
delete [] infoLog;
}
glDeleteProgram( Program );
glDeleteShader( Vshader );
glDeleteShader( Gshader );
glDeleteShader( Fshader );
return 0;
}
return 1;
};
void
GLSLProgram::SetVerbose( bool v )
{
Verbose = v;
};
void
GLSLProgram::Use()
{
Use( this->Program );
};
void
GLSLProgram::Use( int p )
{
glUseProgram( p );
};
int
GLSLProgram::GetAttributeLocation( char *name )
{
std::map<char *, int>::iterator pos;
pos = AttributeLocs.find( name );
if( pos == AttributeLocs.end() )
{
AttributeLocs[name] = glGetAttribLocation( this->Program, name );
}
return AttributeLocs[name];
};
void
GLSLProgram::SetAttribute( char* name, int val )
{
int loc;
if( ( loc = GetAttributeLocation( name ) ) >= 0 )
{
this->Use();
glUniform1i( loc, val );
}
};
void
GLSLProgram::SetAttribute( char* name, float val )
{
int loc;
if( ( loc = GetAttributeLocation( name ) ) >= 0 )
{
this->Use();
glUniform1f( loc, val );
}
};
int
GLSLProgram::GetUniformLocation( char *name )
{
std::map<char *, int>::iterator pos;
pos = UniformLocs.find( name );
if( pos == UniformLocs.end() )
{
UniformLocs[name] = glGetUniformLocation( this->Program, name );
}
return UniformLocs[name];
};
void
GLSLProgram::SetUniform( char* name, int val )
{
int loc;
if( ( loc = GetUniformLocation( name ) ) >= 0 )
{
this->Use();
glUniform1i( loc, val );
}
};
void
GLSLProgram::SetUniform( char* name, float val )
{
int loc;
if( ( loc = GetUniformLocation( name ) ) >= 0 )
{
this->Use();
glUniform1f( loc, val );
}
};
void
GLSLProgram::SetInputTopology( GLenum t )
{
if( t != GL_POINTS && t != GL_LINES && t != GL_LINES_ADJACENCY_EXT && t != GL_TRIANGLES && t != GL_TRIANGLES_ADJACENCY_EXT )
{
fprintf( stderr, "Warning: You have not specified a supported Input Topology\n" );
}
InputTopology = t;
}
void
GLSLProgram::SetOutputTopology( GLenum t )
{
if( t != GL_POINTS && t != GL_LINE_STRIP && t != GL_TRIANGLE_STRIP )
{
/// Corrected a small typo here : "Onput" -> "Output"
fprintf( stderr, "Warning: You have not specified a supported Output Topology\n" );
}
OutputTopology = t;
}
bool
GLSLProgram::IsExtensionSupported( const char *extension )
{
// see if the extension is bogus:
if( extension == NULL || extension[0] == '\0' )
return false;
GLubyte *where = (GLubyte *) strchr( extension, ' ' );
if( where != 0 )
return false;
// get the full list of extensions:
const GLubyte *extensions = glGetString( GL_EXTENSIONS );
/// if (extensions == (GLubyte *) 0)
/// return false;
for( const GLubyte *start = extensions; ; )
{
where = (GLubyte *) strstr( (const char *) start, extension );
if( where == 0 )
return false;
GLubyte *terminator = where + strlen(extension);
if( where == start || *(where - 1) == '\n' || *(where - 1) == ' ' )
if( *terminator == ' ' || *terminator == '\n' || *terminator == '\0' )
return true;
start = terminator;
}
return false;
}
#endif
#ifndef CHECK_GL_ERRORS
#define CHECK_GL_ERRORS
void
CheckGlErrors( const char* caller )
{
unsigned int gle = glGetError();
if( gle != GL_NO_ERROR )
{
fprintf( stderr, "GL Error discovered from caller %s: ", caller );
switch (gle)
{
case GL_INVALID_ENUM:
fprintf( stderr, "Invalid enum.\n" );
break;
case GL_INVALID_VALUE:
fprintf( stderr, "Invalid value.\n" );
break;
case GL_INVALID_OPERATION:
fprintf( stderr, "Invalid Operation.\n" );
break;
case GL_STACK_OVERFLOW:
fprintf( stderr, "Stack overflow.\n" );
break;
case GL_STACK_UNDERFLOW:
fprintf(stderr, "Stack underflow.\n" );
break;
case GL_OUT_OF_MEMORY:
fprintf( stderr, "Out of memory.\n" );
break;
}
return;
}
}
#endif
| [
"[email protected]"
]
| [
[
[
1,
479
]
]
]
|
d5db1f24974610b1f3be19931c01b10904aee144 | 9310fd7bac6871c98b216a2e081b19e9232c14ed | /lib/agr/samples/prototype/src/WiimoteTest.cpp | cc9fda1dd7763ec94666f674dc1bb63fdf49fb29 | []
| no_license | baloo/wiidrums | 1345525c759a2325274ddbfe182a9549c6c4e325 | ed3832d4f91cd9932bfeb321b8aa57340a502d48 | refs/heads/master | 2016-09-09T18:19:06.403352 | 2009-05-21T02:04:09 | 2009-05-21T02:04:09 | 179,309 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,992 | cpp | // WiimoteTest.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "WiimoteTest.h"
#include "MainFrm.h"
#include "WiiAccelerometer.h"
#include "WiimoteTestDoc.h"
#include "WiimoteTestView.h"
#include "MFCGLView.h"
#include ".\wiimotetest.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// TODO : clean that !!!
extern CWiimoteTestDoc* g_Doc;
// CWiimoteTestApp
BEGIN_MESSAGE_MAP(CWiimoteTestApp, CWinApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
// CWiimoteTestApp construction
CWiimoteTestApp::CWiimoteTestApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CWiimoteTestApp object
CWiimoteTestApp theApp;
// CWiimoteTestApp initialization
BOOL CWiimoteTestApp::InitInstance()
{
CWinApp::InitInstance();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(4); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CWiimoteTestDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CWiimoteTestView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line. Will return FALSE if
// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
// call DragAcceptFiles only if there's a suffix
// In an SDI app, this should occur after ProcessShellCommand
return TRUE;
}
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
// Implementation
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// App command to run the dialog
void CWiimoteTestApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// CWiimoteTestApp message handlers
int CWiimoteTestApp::ExitInstance()
{
wiiuse_shutdown();
return CWinApp::ExitInstance();
}
extern float time();
BOOL CWiimoteTestApp::OnIdle(LONG lCount)
{
// For testing refresh rate
static float before = time();
float now = time();
float elapsed = now - before;
before = now;
static float start = time();
static unsigned int nbtimer = 0;
float refreshrate = nbtimer/(now-start);
nbtimer++;
if( g_Doc )
{
g_Doc->updateAccelerometer();
}
CWinApp::OnIdle(lCount);
return TRUE;
}
int CWiimoteTestApp::Run()
{
// TODO: Add your specialized code here and/or call the base class
return CWinApp::Run();
}
| [
"[email protected]"
]
| [
[
[
1,
172
]
]
]
|
9e431978e84d59f2e744131947cf26fe930d80e3 | faacd0003e0c749daea18398b064e16363ea8340 | /modules/module.template.h | 0c996ff49584c043e2aa9f7495af39ca8ba82694 | []
| no_license | yjfcool/lyxcar | 355f7a4df7e4f19fea733d2cd4fee968ffdf65af | 750be6c984de694d7c60b5a515c4eb02c3e8c723 | refs/heads/master | 2016-09-10T10:18:56.638922 | 2009-09-29T06:03:19 | 2009-09-29T06:03:19 | 42,575,701 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 884 | h | /*
* Copyright (C) 2008 Pavlov Denis
*
* Comments unavailable.
*
* 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 any later version.
*
*/
#ifndef __MODULE_H__
#define __MODULE_H__
#include "../../m_interface.h"
class templateModule : public QObject, M_Interface {
Q_OBJECT
Q_INTERFACES(M_Interface)
public:
void activate(QWidget *parent = 0);
void activatePeriodically(QWidget *parent = 0);
void appendToPanel(APanel *panel = 0, int position = 0);
};
class templateModuleApplet : public QWidget {
Q_OBJECT
public:
/* public members */
templateModuleApplet(QWidget *parent = 0);
~templateModuleApplet();
private:
/* private members */
};
#endif
| [
"futurelink.vl@9e60f810-e830-11dd-9b7c-bbba4c9295f9"
]
| [
[
[
1,
39
]
]
]
|
629929d31a5cf270777e5a26bfa5f720fb722cad | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/graph/example/interior_pmap_bundled.cpp | 3c074e0536b6fe9d062d160227cd95b76bac1c8d | [
"Artistic-2.0",
"LicenseRef-scancode-public-domain",
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,734 | cpp | //=======================================================================
// Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
// Copyright 2004 Trustees of Indiana University
// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek, Douglas Gregor
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================
#include <boost/config.hpp>
#include <iostream>
#include <algorithm>
#include <boost/graph/adjacency_list.hpp>
#include <boost/property_map.hpp>
#include <string>
using namespace std;
using namespace boost;
/*
Interior Property Map Basics
An interior property map is a way of associating properties
with the vertices or edges of a graph. The "interior" part means
that the properties are stored inside the graph object. This can be
convenient when the need for the properties is somewhat permanent,
and when the properties will be with a graph for the duration of its
lifetime. A "distance from source vertex" property is often of this
kind.
Sample Output
Jeremy owes Rich some money
Jeremy owes Andrew some money
Jeremy owes Jeff some money
Jeremy owes Kinis some money
Andrew owes Jeremy some money
Andrew owes Kinis some money
Jeff owes Jeremy some money
Jeff owes Rich some money
Jeff owes Kinis some money
Kinis owes Jeremy some money
Kinis owes Rich some money
*/
template <class EdgeIter, class Graph>
void who_owes_who(EdgeIter first, EdgeIter last, const Graph& G)
{
while (first != last) {
cout << G[source(*first, G)].first_name << " owes "
<< G[target(*first, G)].first_name << " some money" << endl;
++first;
}
}
struct VertexData
{
string first_name;
};
int
main()
{
{
// Create the graph, and specify that we will use std::string to
// store the first name's.
typedef adjacency_list<vecS, vecS, directedS, VertexData> MyGraphType;
typedef pair<int,int> Pair;
Pair edge_array[11] = { Pair(0,1), Pair(0,2), Pair(0,3), Pair(0,4),
Pair(2,0), Pair(3,0), Pair(2,4), Pair(3,1),
Pair(3,4), Pair(4,0), Pair(4,1) };
MyGraphType G(5);
for (int i=0; i<11; ++i)
add_edge(edge_array[i].first, edge_array[i].second, G);
G[0].first_name = "Jeremy";
G[1].first_name = "Rich";
G[2].first_name = "Andrew";
G[3].first_name = "Jeff";
G[4].first_name = "Doug";
who_owes_who(edges(G).first, edges(G).second, G);
}
cout << endl;
return 0;
}
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
92
]
]
]
|
ede42b5f8aee71da697f5e6f62e82da66d8550e5 | 91b964984762870246a2a71cb32187eb9e85d74e | /SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/program_options/test/winmain.cpp | ce721d1c56a3e65355052808f3dc7002b6e64bb2 | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | willrebuild/flyffsf | e5911fb412221e00a20a6867fd00c55afca593c7 | d38cc11790480d617b38bb5fc50729d676aef80d | refs/heads/master | 2021-01-19T20:27:35.200154 | 2011-02-10T12:34:43 | 2011-02-10T12:34:43 | 32,710,780 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,660 | cpp | // Copyright Vladimir Prus 2002-2004.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#if defined(_WIN32)
#include <string>
#include <vector>
#include <cctype>
#include <boost/program_options/parsers.hpp>
using namespace boost::program_options;
#include <boost/test/test_tools.hpp>
#include <boost/preprocessor/cat.hpp>
void test_winmain()
{
using namespace std;
#define C ,
#define TEST(input, expected) \
char* BOOST_PP_CAT(e, __LINE__)[] = expected;\
vector<string> BOOST_PP_CAT(v, __LINE__) = split_winmain(input);\
BOOST_CHECK_EQUAL_COLLECTIONS(BOOST_PP_CAT(v, __LINE__).begin(),\
BOOST_PP_CAT(v, __LINE__).end(),\
BOOST_PP_CAT(e, __LINE__),\
BOOST_PP_CAT(e, __LINE__) + \
sizeof(BOOST_PP_CAT(e, __LINE__))/sizeof(char*));
// The following expectations were obtained in Win2000 shell:
TEST("1 ", {"1"});
TEST("1\"2\" ", {"12"});
TEST("1\"2 ", {"12 "});
TEST("1\"\\\"2\" ", {"1\"2"});
TEST("\"1\" \"2\" ", {"1" C "2"});
TEST("1\\\" ", {"1\""});
TEST("1\\\\\" ", {"1\\ "});
TEST("1\\\\\\\" ", {"1\\\""});
TEST("1\\\\\\\\\" ", {"1\\\\ "});
TEST("1\" 1 ", {"1 1 "});
TEST("1\\\" 1 ", {"1\"" C "1"});
TEST("1\\1 ", {"1\\1"});
TEST("1\\\\1 ", {"1\\\\1"});
}
int test_main(int, char*[])
{
test_winmain();
return 0;
}
#else
int test_main(int, char*[])
{
return 0;
}
#endif
| [
"[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278"
]
| [
[
[
1,
58
]
]
]
|
8de83274a59d2b54a5004581dbe86cfcff0ffd70 | 1e976ee65d326c2d9ed11c3235a9f4e2693557cf | /LocalPictureManager.cpp | 02ea16eb674aad59022b736140b7ee29bc527be7 | []
| no_license | outcast1000/Jaangle | 062c7d8d06e058186cb65bdade68a2ad8d5e7e65 | 18feb537068f1f3be6ecaa8a4b663b917c429e3d | refs/heads/master | 2020-04-08T20:04:56.875651 | 2010-12-25T10:44:38 | 2010-12-25T10:44:38 | 19,334,292 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,586 | cpp | // /*
// *
// * Copyright (C) 2003-2010 Alexandros Economou
// *
// * This file is part of Jaangle (http://www.jaangle.com)
// *
// * 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, or (at your option)
// * any later version.
// *
// * This Program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with GNU Make; see the file COPYING. If not, write to
// * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
// * http://www.gnu.org/copyleft/gpl.html
// *
// */
#include "StdAfx.h"
#include "LocalPictureManager.h"
#include "PrgAPI.h"
#include "SQLManager.h"
#include "InformationProviders/CachedImageInfoProvider/CachedImageInfoProvider.h"
#include "InformationProviders/DirImageInfoProvider/DirImageInfoProvider.h"
//#include "InformationProviders/CompositeInfoProvider/CompositeInfoProvider.h"
//#include "InformationProviders/InfoProviderRequestHelper.h"
#include "InformationProviders/InfoProviderFactory.h"
#include "InfoDownloadManager.h"
#include "resource.h"
#define MAX_FAILED_ARTISTS_REQUESTS_QUEUE 15
#define MAX_FAILED_ALBUMS_REQUESTS_QUEUE 15
LocalPictureManager::LocalPictureManager():
m_pCIIP(NULL),
m_pDIIP(NULL),
m_bEnableFolderImages(TRUE),
m_pThumbnailCache(NULL)
{
for (INT i = IIT_Unknown; i < IIT_Last; i++)
m_defDrawer[i] = &m_defGlobal;
m_defDrawer[IIT_AlbumPicture] = &m_defAlbum;
}
LocalPictureManager::~LocalPictureManager()
{
delete m_pThumbnailCache;
//delete m_pCIIP;
//delete m_pDIIP;
}
BOOL LocalPictureManager::Init(LPCTSTR storagePath)
{
if (m_pCIIP == NULL)
{
TRACEST(_T("LocalPictureManager::Init"));
PrgAPI* pAPI = PRGAPI();
InfoProviderFactory* pIPF = pAPI->GetInfoProviderFactory();
ASSERT(storagePath != NULL);
m_pCIIP = new CachedImageInfoProvider;
pIPF->RegisterInfoProvider(m_pCIIP, FALSE);
m_pDIIP = new DirImageInfoProvider;
m_pDIIP->SetSQLManager(pAPI->GetSQLManager());
pIPF->RegisterInfoProvider(m_pDIIP, FALSE);
m_defGlobal.LoadResourceID(IDR_PNG_ARTIST, _T("png"));
m_defGlobal.SetBkColor(RGB(0,0,0), 0);
m_defGlobal.GetDrawParams().zoomLockMode = GdiPlusPicDrawer::ZLM_FillArea;
m_defAlbum.LoadResourceID(IDR_ALBUM, _T("jpg"));
m_defAlbum.SetBkColor(RGB(0,0,0), 0);
m_defAlbum.GetDrawParams().zoomLockMode = GdiPlusPicDrawer::ZLM_FillArea;
}
m_pCIIP->SetStoragePath(storagePath);
m_pThumbnailCache = new GdiPlusBitmapCache(64, 64, 80);
//m_pThumbnailCache = new GdiPlusBitmapCache(96, 96, 50);
//m_pThumbnailCache = new GdiPlusBitmapCache(128, 128, 100);
return TRUE;
}
static const LPCTSTR sThumbsDB = _T("thumbs.db");
void LocalPictureManager::LoadState(LPCTSTR stateRoot)
{
TRACEST(_T("LocalPictureManager::LoadState"));
ASSERT(m_pThumbnailCache != NULL);//=== You must call Init first
if (m_pThumbnailCache != NULL)
{
std::tstring thumbsDB(stateRoot);
thumbsDB += sThumbsDB;
m_pThumbnailCache->LoadState(thumbsDB.c_str());
}
}
void LocalPictureManager::SaveState(LPCTSTR stateRoot)
{
TRACEST(_T("LocalPictureManager::SaveState"));
ASSERT(m_pThumbnailCache != NULL);//=== You must call Init first
if (m_pThumbnailCache != NULL)
{
std::tstring thumbsDB(stateRoot);
thumbsDB += sThumbsDB;
m_pThumbnailCache->SaveState(thumbsDB.c_str());
}
}
void LocalPictureManager::RemoveArtistPicture(const ArtistRecord& rec, LPCTSTR imagePath)
{
ResetArtistCache(rec);
DeleteFile(imagePath);
//=== No need to check if this is the default picture. GetMain...Picture will detect it
}
void LocalPictureManager::RemoveAlbumPicture(const FullAlbumRecord& rec, LPCTSTR imagePath)
{
ResetAlbumCache(rec);
DeleteFile(imagePath);
//=== No need to check if this is the default picture. GetMain...Picture will detect it
}
BOOL LocalPictureManager::AddArtistPicture(const ArtistRecord& rec, LPCTSTR imagePath)
{
TRACEST(_T("LocalPictureManager::AddArtistPicture"));
ASSERT(rec.IsValid() && imagePath != NULL);
ASSERT(m_pCIIP != NULL);
if (m_pCIIP == NULL || !rec.IsValid() || imagePath == NULL) return FALSE;
IInfoProvider::Request req(IInfoProvider::SRV_ArtistImage);
req.artist = rec.name.c_str();
if (m_pCIIP->OpenRequest(req))
{
IInfoProvider::Result res;
res.main = imagePath;
res.additionalInfo = _T("");
res.service = IInfoProvider::SRV_ArtistImage;
if (m_pCIIP->AddResult(res))
{
if (GetMainArtistPicture(rec) == NULL)
ResetArtistCache(rec);
return TRUE;
}
}
return FALSE;
}
BOOL LocalPictureManager::AddAlbumPicture(const FullAlbumRecord& rec, LPCTSTR imagePath)
{
TRACEST(_T("LocalPictureManager::AddAlbumPicture"));
ASSERT(rec.IsValid() && imagePath != NULL);
ASSERT(m_pCIIP != NULL);
if (m_pCIIP == NULL || !rec.IsValid() || imagePath == NULL) return FALSE;
IInfoProvider::Request req(IInfoProvider::SRV_AlbumImage);
req.artist = rec.artist.name.c_str();
req.album = rec.album.name.c_str();
if (m_pCIIP->OpenRequest(req))
{
IInfoProvider::Result res;
res.main = imagePath;
res.additionalInfo = _T("");
res.service = IInfoProvider::SRV_AlbumImage;
if (m_pCIIP->AddResult(res))
{
if (GetMainAlbumPicture(rec) == NULL)
ResetAlbumCache(rec);
return TRUE;
}
}
return FALSE;
}
void LocalPictureManager::SetMainArtistPicture(const ArtistRecord& rec, LPCTSTR path)
{
ResetArtistCache(rec);
PicRecord pr(IIT_ArtistPicture, rec.ID);
pr.path = path;
pr.pictureType = PT_Main;
PRGAPI()->GetSQLManager()->AddOrUpdatePicRecord(pr);
}
void LocalPictureManager::SetMainAlbumPicture(const FullAlbumRecord& rec, LPCTSTR path)
{
ResetAlbumCache(rec);
PicRecord pr(IIT_AlbumPicture, rec.album.ID);
pr.path = path;
pr.pictureType = PT_Main;
PRGAPI()->GetSQLManager()->AddOrUpdatePicRecord(pr);
}
BOOL LocalPictureManager::GetArtistPictures(const ArtistRecord& rec, std::tstringvector& col)
{
//TRACEST(_T("LocalPictureManager::GetArtistPictures"));
ASSERT(rec.IsValid());
ASSERT(m_pCIIP != NULL);
if (m_pCIIP == NULL || !rec.IsValid()) return FALSE;
if (rec.name.empty()) return FALSE;
if (rec.name[0] == '[') return FALSE;
IInfoProvider::Request req(IInfoProvider::SRV_ArtistImage);
req.artist = rec.name.c_str();
if (m_pCIIP->OpenRequest(req))
{
IInfoProvider::Result res;
INT i = 0;
while (m_pCIIP->GetNextResult(res))
{
col.push_back(std::tstring(res.main));
i++;
}
return i > 0;
}
return FALSE;
}
BOOL LocalPictureManager::GetAlbumPictures(const FullAlbumRecord& rec, std::tstringvector& col)
{
//TRACEST(_T("LocalPictureManager::GetAlbumPictures"));
ASSERT(rec.IsValid());
ASSERT(m_pCIIP != NULL);
if (m_pCIIP == NULL || !rec.IsValid()) return FALSE;
if (rec.album.name.empty()) return FALSE;
if (rec.album.name[0] == '[') return FALSE;
if (rec.artist.name.empty()) return FALSE;
if (rec.artist.name[0] == '[') return FALSE;
IInfoProvider::Request req(IInfoProvider::SRV_AlbumImage);
req.artist = rec.artist.name.c_str();
req.album = rec.album.name.c_str();
IInfoProvider::Result res;
INT images = 0;
if (m_bEnableFolderImages && m_pDIIP != NULL)
{
if (m_pDIIP->OpenRequest(req))
{
while (m_pDIIP->GetNextResult(res))
{
col.push_back(std::tstring(res.main));
images++;
}
}
}
if (TRUE)
{
if (m_pCIIP->OpenRequest(req))
{
while (m_pCIIP->GetNextResult(res))
{
col.push_back(std::tstring(res.main));
images++;
}
}
}
return images > 0;
}
//void LocalPictureManager::RequestArtistPicDownload(const FullArtistRecordSP& rec)
//{
// while (m_failedArtistRequests.size() >= MAX_FAILED_ARTISTS_REQUESTS_QUEUE)
// m_failedArtistRequests.pop_front();
// m_failedArtistRequests.push_back(rec);
//}
//void LocalPictureManager::RequestAlbumPicDownload(const FullAlbumRecordSP& rec)
//{
// while (m_failedAlbumRequests.size() >= MAX_FAILED_ALBUMS_REQUESTS_QUEUE)
// m_failedAlbumRequests.pop_front();
// m_failedAlbumRequests.push_back(rec);
//}
//
//void LocalPictureManager::ProcessFailedRequests()
//{
// InfoDownloadManager* pIDM = PRGAPI()->GetInfoDownloadManager();
// if (pIDM->GetPendingJobs() == 0)
// {
// if (m_failedArtistRequests.size() > 0)
// {
// pIDM->RequestArtistPic(m_failedArtistRequests.back()->artist, NULL);
// m_failedArtistRequests.pop_back();
// }
// if (m_failedAlbumRequests.size() > 0)
// {
// pIDM->RequestAlbumPic(m_failedAlbumRequests.back()->album, m_failedAlbumRequests.back()->artist.name.c_str(), NULL);
// m_failedAlbumRequests.pop_back();
// }
// }
//}
LPCTSTR LocalPictureManager::GetFirstArtistPicture(const ArtistRecord& rec)
{
ASSERT(rec.IsValid());
ASSERT(m_pCIIP != NULL);
if (m_pCIIP == NULL || !rec.IsValid()) return FALSE;
if (rec.name.empty()) return FALSE;
if (rec.name[0] == '[') return FALSE;
IInfoProvider::Request req(IInfoProvider::SRV_ArtistImage);
req.artist = rec.name.c_str();
if (m_pCIIP->OpenRequest(req))
{
IInfoProvider::Result res;
if (m_pCIIP->GetNextResult(res))
return res.main;//res.main is just a pointer to the internal m_pCIIP object which is not destroyed
}
return NULL;
}
LPCTSTR LocalPictureManager::GetFirstAlbumPicture(const FullAlbumRecord& rec)
{
if (m_pCIIP == NULL || !rec.IsValid()) return FALSE;
if (rec.album.name.empty()) return FALSE;
if (rec.album.name[0] == '[') return FALSE;
if (rec.artist.name.empty()) return FALSE;
if (rec.artist.name[0] == '[') return FALSE;
IInfoProvider::Request req(IInfoProvider::SRV_AlbumImage);
req.artist = rec.artist.name.c_str();
req.album = rec.album.name.c_str();
if (m_bEnableFolderImages && m_pDIIP != NULL)
{
if (m_pDIIP->OpenRequest(req))
{
IInfoProvider::Result res;
if (m_pDIIP->GetNextResult(res))
return res.main;//res.main is just a pointer to the internal m_pDIIP object which is not destroyed
}
}
if (m_pCIIP->OpenRequest(req))
{
IInfoProvider::Result res;
if (m_pCIIP->GetNextResult(res))
return res.main;//res.main is just a pointer to the internal m_pCIIP object which is not destroyed
}
return NULL;
}
LPCTSTR LocalPictureManager::GetMainArtistPicture(const ArtistRecord& rec)
{
ASSERT(rec.IsValid());
ASSERT(rec.IsValid());
if (!rec.IsValid())
return FALSE;
if (rec.name[0] == '[')
return NULL;
CacheContainer::iterator it = m_artists.find(rec.ID);
if (it == m_artists.end())
{
//TRACEST(_T("@4 LocalPictureManager::GetMainArtistPicture (Uncached)"));
//=== This is the first request. We will try to find one
//=== First Try the ArtistsPic Table
SQLManager* pSM = PRGAPI()->GetSQLManager();
PicRecord apr(IIT_ArtistPicture, rec.ID);
if (pSM->GetPicRecord(apr))
{
//=== A db entry already exists. Lets check if the file exists.
if (_taccess(apr.path.c_str(), 4) == 0)
{
//=== Exists. All OK. Add to cache and return the path
m_artists[rec.ID] = apr.path;
//TRACE(_T("@3 LocalPictureManager::GetMainArtistPicture. Found In DB\r\n"));
return m_artists[rec.ID].c_str();
}
else
{
//=== Does NOT Exist. Maybe it is deleted from the FS. Adjust the database apr.path.clear();
TRACE(_T("@1 LocalPictureManager::GetMainArtistPicture. Found In DB but not in FS\r\n"));
pSM->DeletePicRecord(apr.infoType, rec.ID);
}
}
//=== The Picture does NOT exist in the database (OR it is does not exist in the FS anymore)
//=== Get The Picture with the normal way
LPCTSTR pic = GetFirstArtistPicture(rec);
if (pic != NULL)
{
//TRACE(_T("@3 LocalPictureManager::GetMainArtistPicture. Found In Folder\r\n"));
//=== We have a picture. Let's cache it to the database.
SetMainArtistPicture(rec, pic);
//=== Let's cache it here and return the record
m_artists[rec.ID] = pic;
return m_artists[rec.ID].c_str();
}
//=== No Pictures found
//TRACE(_T("@3 LocalPictureManager::GetMainArtistPicture. Picture Not Found\r\n"));
m_artists[rec.ID] = _T("");
return NULL;
}
else if (!(*it).second.empty())
{
if (_taccess((*it).second.c_str(), 4) == 0)
return (*it).second.c_str();//Return Cached answer
TRACE(_T("@1 LocalPictureManager::GetMainArtistPicture. A previously cached Picture has ot been found\r\n"));
m_artists.erase(it);
}
return NULL;
}
LPCTSTR LocalPictureManager::GetMainAlbumPicture(const FullAlbumRecord& rec)
{
//TRACEST(_T("LocalPictureManager::GetMainAlbumPicture"));
ASSERT(rec.IsValid());
if (!rec.IsValid())
return FALSE;
if (rec.album.name[0] == '[' || rec.artist.name[0] == '[' )
return NULL;
CacheContainer::iterator it = m_albums.find(rec.album.ID);
if (it == m_albums.end())
{
//TRACEST(_T("LocalPictureManager::GetMainAlbumPicture (Uncached)"));
//=== This is the first request. We will try to find one
//=== First Try the AlbumsPic Table
SQLManager* pSM = PRGAPI()->GetSQLManager();
PicRecord apr(IIT_AlbumPicture, rec.album.ID);
if (pSM->GetPicRecord(apr))
{
//=== A db entry already exists. Lets check if the file exists.
if (_taccess(apr.path.c_str(), 4) == 0)
{
//=== Exists. All OK. Add to cache and return the path
m_albums[rec.album.ID] = apr.path;
return m_albums[rec.album.ID].c_str();
}
else
{
//=== Does NOT Exist. Maybe it is deleted from the FS. Adjust the database apr.path.clear();
pSM->DeletePicRecord(apr.infoType, rec.album.ID);
}
}
//=== The Picture does NOT exist in the database (OR it is does not exist in the FS anymore)
//=== Get The Picture with the normal way
LPCTSTR pic = GetFirstAlbumPicture(rec);
if (pic != NULL)
{
//=== We have a picture. Let's cache it to the database.
apr.path = pic;
apr.pictureType = PT_Main;
pSM->AddOrUpdatePicRecord(apr);
//=== Let's cache it here and return the record
m_albums[rec.album.ID] = pic;
return m_albums[rec.album.ID].c_str();
}
//=== No Pictures found
m_albums[rec.album.ID] = _T("");
return NULL;
}
else if (!(*it).second.empty())
{
if (_taccess((*it).second.c_str(), 4) == 0)
return (*it).second.c_str();//Return Cached answer
TRACE(_T("@1 LocalPictureManager::GetMainAlbumPicture. A previously cached Picture has not been found\r\n"));
m_albums.erase(it);
}
return NULL;
}
void LocalPictureManager::ResetArtistCache(const ArtistRecord& rec)
{
//=== Reset Session Cache
TRACEST(_T("LocalPictureManager::ClearCachedArtistPicture"));
ASSERT(rec.IsValid());
if (rec.IsValid())
{
CacheContainer::iterator it = m_artists.find(rec.ID);
if (it != m_artists.end())
m_artists.erase(it);
}
//=== Reset DB Cache
SQLManager* pSM = PRGAPI()->GetSQLManager();
pSM->DeletePicRecord(IIT_ArtistPicture, rec.ID);
}
void LocalPictureManager::ResetAlbumCache(const FullAlbumRecord& rec)
{
//=== Reset Session Cache
TRACEST(_T("LocalPictureManager::ClearCachedAlbumPicture"));
ASSERT(rec.IsValid());
if (rec.IsValid())
{
CacheContainer::iterator it = m_albums.find(rec.album.ID);
if (it != m_albums.end())
m_albums.erase(it);
}
//=== Reset DB Cache
SQLManager* pSM = PRGAPI()->GetSQLManager();
pSM->DeletePicRecord(IIT_AlbumPicture, rec.album.ID);
}
DWORD LocalPictureManager::CalculateCacheUID(InfoItemTypeEnum iit, UINT itemID)
{
return (itemID & 0xFFFFFF) | ((iit & 0xff) << 24);//=== 1 byte iit + 3bytes for the ID
//return MAKELONG(iit, itemID);//=== 2 bytes iit + 2bytes ID
}
BOOL LocalPictureManager::DrawDefaultThumbnail(InfoItemTypeEnum iit, HDC hdc, RECT& rcDest)
{
return DrawDefaultThumbnail(iit, Gdiplus::Graphics(hdc), Gdiplus::Rect(rcDest.left, rcDest.top, rcDest.right - rcDest.left, rcDest.bottom - rcDest.top));
}
BOOL LocalPictureManager::DrawDefaultThumbnail(InfoItemTypeEnum iit, Gdiplus::Graphics& g, Gdiplus::Rect& rcDest)
{
return m_defDrawer[iit]->Draw(g, rcDest);
}
BOOL LocalPictureManager::DrawThumbnail(InfoItemTypeEnum iit, UINT itemID, HDC hdc, RECT& rcDest)
{
return DrawThumbnail(iit, itemID, Gdiplus::Graphics(hdc), Gdiplus::Rect(rcDest.left, rcDest.top, rcDest.right - rcDest.left, rcDest.bottom - rcDest.top));
}
BOOL LocalPictureManager::DrawThumbnail(InfoItemTypeEnum iit, UINT itemID, Gdiplus::Graphics& g, Gdiplus::Rect& rcDest)
{
DWORD uid = CalculateCacheUID(iit, itemID);
PrgAPI* pAPI = PRGAPI();
InfoDownloadManager* pDM = pAPI->GetInfoDownloadManager();
BOOL bRet = FALSE;
if (itemID > 0)
{
switch (iit)
{
case IIT_ArtistPicture:
bRet = m_pThumbnailCache->Draw(uid, g, rcDest);
if (bRet == FALSE)
{
ArtistRecord rec;
if (pAPI->GetSQLManager()->GetArtistRecord(itemID, rec))
{
LPCTSTR picPath = GetMainArtistPicture(rec);
if (picPath != NULL)
{
INT nItem = m_pThumbnailCache->SetByPath(uid, picPath);
if (nItem != -1)
bRet = m_pThumbnailCache->DrawItem(nItem, g, rcDest);
else
TRACE(_T("@1 LocalPictureManager::DrawThumbnail Failed at '%s'\r\n"), picPath);
}
else
{
//=== We don't have the picture.
//=== Ask for a download
pDM->RequestArtistPic(rec);
}
}
}
break;
case IIT_AlbumPicture:
bRet = m_pThumbnailCache->Draw(uid, g, rcDest);
if (bRet == FALSE)
{
FullAlbumRecordSP rec;
if (pAPI->GetSQLManager()->GetFullAlbumRecordByID(rec, itemID))
{
LPCTSTR picPath = GetMainAlbumPicture(*rec);
if (picPath != NULL)
{
INT nItem = m_pThumbnailCache->SetByPath(uid, picPath);
if (nItem != -1)
bRet = m_pThumbnailCache->Draw(uid, g, rcDest);
else
TRACE(_T("@1 LocalPictureManager::DrawThumbnail Failed at '%s'\r\n"), picPath);
}
else
{
//=== We don't have the picture. Ask for a download
pDM->RequestAlbumPic(rec->album, rec->artist.name.c_str());
}
}
}
break;
default:
break;
//bRet = FALSE;
}
}
else
{
//Should be various
INT debug = 0;
}
return bRet;
}
| [
"outcast1000@dc1b949e-fa36-4f9e-8e5c-de004ec35678"
]
| [
[
[
1,
591
]
]
]
|
83bb7c0f274c03a774d354fd38101c98c5215149 | 5504cdea188dd5ceec6ab38863ef4b4f72c70b21 | /pcsxrr/plugins/cdrTAScdrom/scsi_cmds.cpp | f3640b14417524fc09f48a5c76f8b0ca18242bf6 | []
| no_license | mauzus/pcsxrr | 959051bed227f96045a9bba8971ba5dffc24ad33 | 1b4c66d6a2938da55761280617d288f3c65870d7 | refs/heads/master | 2021-03-12T20:00:56.954014 | 2011-03-21T01:16:35 | 2011-03-21T01:16:35 | 32,238,897 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,944 | cpp | #include <windows.h>
#include "winioctl.h"
#include "ntddcdrm.h"
#include "ntddmmc.h"
// Plugin Defs
#include "Locals.h"
static BOOL scsi_SelectReadMode(eReadMode rmode, eSubQMode subQmode);
static int prev_spindown_timer = -1;
//------------------------------------------------------------------------------
// SCSI common interface functions:
//------------------------------------------------------------------------------
BOOL scsi_Inquiry(INQUIRYDATA *inquiry)
{
CDB cdb;
BYTE cdblen;
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildInquiryCDB(&cdb, sizeof(*inquiry));
return if_layer.ExecScsiCmd(inquiry, sizeof(*inquiry), &cdb, cdblen, SCSI_IOCTL_DATA_IN, 2);
}
BOOL scsi_ModeSense(int page_code, char *sense_buf, int sense_len, BOOL dbd, BOOL use6Byte)
{
CDB cdb;
BYTE cdblen;
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildModeSenseCDB(&cdb, page_code, sense_len, dbd, use6Byte);
return if_layer.ExecScsiCmd(sense_buf, sense_len, &cdb, cdblen, SCSI_IOCTL_DATA_IN, 2);
}
BOOL scsi_DetectReadMode(eReadMode *rmode)
{
CDB cdb;
BYTE cdblen;
BOOL use6Byte;
char sense_buf[1024];
const void *mode_pages_ary[256];
int num_mode_pages, cnt, i;
BOOL use_read_cd = FALSE;
// BOOL use_nec_read_cdda = FALSE;
// BOOL use_plxtr_read_cdda = FALSE;
// const INQUIRYDATA *inquiry;
// - ricercare idx su found_drives[] di *addr tramite SCSIADDR_EQ(*addr, found_drives[idx])
// - leggere inquiry da drive_info[idx]
// The purpose of this function is to identify the drive capabilities.
// (mainly, to check if the drive supports the READ_CD command)
// NOTE: The identification sequence is 'very similar' to the one
// used from the CDROM driver sample of the 'Win2K DDK'.
// check inquiry.VendorId[] == "NEC" / "PLEXTOR "
// if (!strncmp(inquiry->VendorId, "NEC", 3))
// capab->use_nec_read_cdda = 1; // use NEC specific command to read CDDA
// if (!strncmp(inquiry->VendorId, "PLEXTOR ", 8))
// capab->use_plxtr_read_cdda = 1; // use PLEXTOR specific command to read CDDA
// check if the drive is a DVD
for (cnt = 0; cnt < 2; cnt++) {
use6Byte = (cnt == 0) ? TRUE : FALSE;
memset(&sense_buf, 0, sizeof(sense_buf));
if (!scsi_ModeSense(MODE_PAGE_CAPABILITIES, sense_buf, sizeof(sense_buf), TRUE, use6Byte))
continue;
num_mode_pages = sizeof(mode_pages_ary) / sizeof(mode_pages_ary[0]);
scsi_ParseModeSenseBuffer(sense_buf, NULL, NULL, mode_pages_ary, &num_mode_pages, use6Byte);
for (i = 0; i < num_mode_pages; i++) {
CDVD_CAPABILITIES_PAGE *capPage = (CDVD_CAPABILITIES_PAGE *)mode_pages_ary[i];
if (capPage->PageCode == MODE_PAGE_CAPABILITIES &&
capPage->PageLength == (sizeof(CDVD_CAPABILITIES_PAGE)-2) &&
(capPage->DVDROMRead || capPage->DVDRRead ||
capPage->DVDRAMRead || capPage->DVDRWrite ||
capPage->DVDRAMWrite)) {
*rmode = ReadMode_Scsi_BE; // DVD drives always support READ_CD command
return TRUE;
}
}
break;
}
// check if the drive is MMC capable
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildGetConfigurationCDB(&cdb, SCSI_GET_CONFIGURATION_REQUEST_TYPE_ALL, FeatureProfileList, sizeof(GET_CONFIGURATION_HEADER));
if (if_layer.ExecScsiCmd(sense_buf, sizeof(GET_CONFIGURATION_HEADER), &cdb, cdblen, SCSI_IOCTL_DATA_IN, 2)) {
*rmode = ReadMode_Scsi_BE; // MMC drives always support READ_CD command
return TRUE;
}
// if (scsi_err != ERROR_INVALID_FUNCTION && scsi_err != ERROR_NOT_READY &&
// scsi_err == ERROR_IO_DEVICE && scsi_err != ERROR_SEM_TIMEOUT)
// return FALSE;
// try issuing directly a READ_CD command to the driver
for (cnt = 0; cnt < 2; cnt++) {
use6Byte = (cnt == 0) ? TRUE : FALSE;
if (!scsi_ModeSense(MODE_PAGE_ERROR_RECOVERY, sense_buf, sizeof(sense_buf), FALSE, use6Byte))
continue;
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildReadSectorCDB(&cdb, 0, 0, &scsi_addr, ReadMode_Scsi_BE, SubQMode_Disabled);
if (if_layer.ExecScsiCmd(NULL, 0, &cdb, cdblen, SCSI_IOCTL_DATA_IN, 2) ||
scsi_err == ERROR_NOT_READY ||
scsi_err == ERROR_SECTOR_NOT_FOUND ||
scsi_err == ERROR_UNRECOGNIZED_MEDIA) {
*rmode = ReadMode_Scsi_BE; // drive support READ_CD command
return TRUE;
}
}
// drive doesn't support READ_CD, defaulting read mode to READ_10
*rmode = ReadMode_Scsi_28;
return TRUE;
}
BOOL scsi_InitReadMode(eReadMode rmode)
{
// N.B.: save current READ MODE !!! (see *ReadSector() functions)
scsi_rmode = rmode;
// N.B.: always use subQmode == SubQMode_Disabled for reads (sector size = 2352) !!!
return scsi_SelectReadMode(rmode, SubQMode_Disabled);
}
static BOOL scsi_SelectReadMode(eReadMode rmode, eSubQMode subQmode)
{
char sense_buf[255];
int cnt, sense_len, block_size;
BOOL use6Byte;
CDB cdb;
BYTE cdblen;
static int last_block_size = COOKED_SECTOR_SIZE;
block_size = (rmode == ReadMode_Auto) ? COOKED_SECTOR_SIZE :
(subQmode == SubQMode_Read_PW) ? RAW_PW_SECTOR_SIZE :
(subQmode == SubQMode_Read_Q) ? RAW_Q_SECTOR_SIZE :
RAW_SECTOR_SIZE;
switch (rmode)
{
case ReadMode_Auto: // set block size = 2048
case ReadMode_Scsi_28: // READ_10: set block size = 2352 / 2368 / 2448
break;
case ReadMode_Scsi_D4: // NEC_READ_CDDA: nothing to do
if (subQmode == SubQMode_Read_Q && subQmode == SubQMode_Read_PW)
return FALSE; // no subchannel read mode support
case ReadMode_Scsi_D8: // PLXTR_READ_CDDA: nothing to do
case ReadMode_Scsi_BE: // READ_CD: nothing to do
return TRUE; // no MODE_SELECT needed
case ReadMode_Raw:
default:
return FALSE; // not a valid SCSI read mode
}
// If the sector block size was already set as espected, don't need to send the MODE_SELECT command again.
// Note: The drive address is not saved and MUST NOT CHANGE until a ReadMode_Auto was issued !!!
if (block_size == last_block_size)
return TRUE; // no MODE_SELECT needed
for (cnt = 0; cnt < 2; cnt++)
{
use6Byte = (cnt == 0) ? TRUE : FALSE;
sense_len = sizeof(sense_buf);
scsi_BuildModeSelectDATA(sense_buf, &sense_len, block_size, NULL, 0, use6Byte);
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildModeSelectCDB(&cdb, sense_len, use6Byte);
if (if_layer.ExecScsiCmd(sense_buf, sense_len, &cdb, cdblen, SCSI_IOCTL_DATA_OUT, 2))
{
last_block_size = block_size; // save last block size sent to the drive
return TRUE;
}
}
return FALSE;
}
BOOL scsi_InitSubQMode(eSubQMode subQmode)
{
// N.B.: save current SUBCHANNEL READ MODE !!! (see *ReadSubQ() functions)
scsi_subQmode = subQmode;
return TRUE;
}
BOOL scsi_DetectSubQMode(eSubQMode *subQmode)
{
static eReadMode rmodes[] = { ReadMode_Scsi_BE, ReadMode_Scsi_D8, ReadMode_Scsi_28, };
static eSubQMode qmodes[] = { SubQMode_Read_PW, SubQMode_Read_Q };
int i, j, loc;
Q_SUBCHANNEL_DATA rbuf;
for (i = 0; i < (sizeof(rmodes) / sizeof(rmodes[0])); i++)
for (j = 0; j < (sizeof(qmodes) / sizeof(qmodes[0])); j++) {
if_layer.InitSubQMode(*subQmode = MAKE_SUBQMODE(rmodes[i], qmodes[j]));
for (loc = 16; loc < (16 + 3); loc++) {
memset(&rbuf, 0, sizeof(rbuf));
if (if_layer.ReadSubQ(&rbuf, loc)) {
// check if 'rbuf' contains a valid subQ data
if (!scsi_ValidateSubQData(&rbuf)) {
#ifdef _DEBUG
if (rbuf.ADR == ADR_ENCODES_CURRENT_POSITION) {
int n;
BYTE *p;
PRINTF(("Warning: Invalid subchannel data returned:\n"));
PRINTF(("SubQ Mode = '%s'\n", subq_mode_name(*subQmode)));
PRINTF(("Data ="));
for (n = 0, p = (BYTE *)&rbuf; n < 16; n++, p++)
PRINTF((" %02X", *p));
PRINTF(("\n"));
}
#endif//_DEBUG
continue; // if not valid, retry with next sector (max. 3 times)
}
{ int __TODO__check_se_tornato_address_in_BCD__; }
//@@@ TO DO: PROVARE ANCHE CON FORMATO NON-BCD !!!
return TRUE;
} else if (scsi_err == ERROR_NOT_READY) {
// if 'Unit not Ready' error, abort mode detection
if_layer.InitSubQMode(*subQmode = SubQMode_Auto);
return FALSE;
}
// if other scsi error, continue with next mode
break;
}
}
// as last resort, use the 'SEEK & READ SUBCHANNEL' mode (absolutely not reliable !!!)
if_layer.InitSubQMode(*subQmode = MAKE_SUBQMODE(ReadMode_Raw, SubQMode_SubQ));
return TRUE;
}
BOOL scsi_ReadToc(void)
{
CDB cdb;
BYTE cdblen;
// TOC Flag:
// - toc.TrackData[].Control & AUDIO_DATA_TRACK == 0 -> AUDIO TRACK
// - toc.TrackData[].Control & AUDIO_DATA_TRACK == 1 -> DATA TRACK
// Read sector Flag (DATA track only):
// sector_data.data_header.data_mode (data+15) == 0 / 1 / 2 (Sector Mode 0 / 1 / 2)
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildReadTocCDB(&cdb, sizeof(toc.TrackData));
if (!if_layer.ExecScsiCmd(&toc, sizeof(toc), &cdb, cdblen, SCSI_IOCTL_DATA_IN, 2))
return FALSE;
return TRUE;
}
BOOL scsi_PlayAudioTrack(const MSF *start, const MSF *end)
{
CDB cdb;
BYTE cdblen;
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildPlayAudioMSFCDB(&cdb, start, end);
return if_layer.ExecScsiCmd(NULL, 0, &cdb, cdblen, SCSI_IOCTL_DATA_UNSPECIFIED, 2);
}
BOOL scsi_StopAudioTrack(void)
{
CDB cdb;
BYTE cdblen;
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildPauseResumeCDB(&cdb, CDB_AUDIO_PAUSE, &scsi_addr);
return if_layer.ExecScsiCmd(NULL, 0, &cdb, cdblen, SCSI_IOCTL_DATA_UNSPECIFIED, 2);
}
BOOL scsi_TestUnitReady(BOOL do_retry)
{
CDB cdb;
BYTE cdblen;
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildTestUnitReadyCDB(&cdb, &scsi_addr);
return if_layer.ExecScsiCmd(NULL, 0, &cdb, cdblen, SCSI_IOCTL_DATA_UNSPECIFIED, do_retry ? 2 : 0); // arg6: nr. of retries
}
BOOL scsi_GetPlayLocation(MSF *play_loc, BYTE *audio_status)
{
CDB cdb;
BYTE cdblen;
SUB_Q_CHANNEL_DATA data;
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildReadQChannelCDB(&cdb, IOCTL_CDROM_CURRENT_POSITION);
if (!if_layer.ExecScsiCmd(&data, sizeof(data), &cdb, cdblen, SCSI_IOCTL_DATA_IN, 2))
return FALSE;
play_loc->minute = data.CurrentPosition.AbsoluteAddress[1];
play_loc->second = data.CurrentPosition.AbsoluteAddress[2];
play_loc->frame = data.CurrentPosition.AbsoluteAddress[3];
// audio_status: AUDIO_STATUS_IN_PROGRESS=play, AUDIO_STATUS_PAUSED=paused, AUDIO_STATUS_NO_STATUS/other=no play
*audio_status = data.CurrentPosition.Header.AudioStatus;
return TRUE;
}
BOOL scsi_LoadEjectUnit(BOOL load)
{
CDB cdb;
BYTE cdblen;
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildStartStopCDB(&cdb, load, TRUE, &scsi_addr);
return if_layer.ExecScsiCmd(NULL, 0, &cdb, cdblen, SCSI_IOCTL_DATA_UNSPECIFIED, 2);
}
BOOL scsi_SetCdSpeed(int speed)
{
CDB cdb;
BYTE cdblen;
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildSetCdSpeedCDB(&cdb, speed);
return if_layer.ExecScsiCmd(NULL, 0, &cdb, cdblen, SCSI_IOCTL_DATA_UNSPECIFIED, 2);
}
BOOL scsi_SetCdSpindown(int timer, int *prev_timer)
{
CDROM_PARAMETERS_PAGE mode_pages_data;
char sense_buf[1024];
const void *mode_pages_ary[1];
int num_mode_pages, i;
int cnt, sense_len;
BOOL use6Byte;
CDB cdb;
BYTE cdblen;
memset(&mode_pages_data, 0, sizeof(mode_pages_data));
mode_pages_data.PageCode = MODE_PAGE_CDROM_PARAMETERS;
mode_pages_data.PageLength = sizeof(CDROM_PARAMETERS_PAGE)-2;
mode_pages_data.InactivityTimerMultiplier = timer;
//mode_pages_data.NumberOfSUnitsPerMUnits[0] = 0;
mode_pages_data.NumberOfSUnitsPerMUnits[1] = 60;
//mode_pages_data.NumberOfFUnitsPerSUnits[0] = 0;
mode_pages_data.NumberOfFUnitsPerSUnits[1] = 75;
for (cnt = 0; cnt < 2; cnt++)
{
use6Byte = (cnt == 0) ? TRUE : FALSE;
memset(&sense_buf, 0, sizeof(sense_buf));
if (!scsi_ModeSense(MODE_PAGE_CDROM_PARAMETERS, sense_buf, sizeof(sense_buf), TRUE, use6Byte))
continue;
num_mode_pages = sizeof(mode_pages_ary) / sizeof(mode_pages_ary[0]);
scsi_ParseModeSenseBuffer(sense_buf, NULL, NULL, mode_pages_ary, &num_mode_pages, use6Byte);
for (i = 0; i < num_mode_pages; i++) {
CDROM_PARAMETERS_PAGE *cdpPage = (CDROM_PARAMETERS_PAGE *)mode_pages_ary[i];
if (cdpPage->PageCode != MODE_PAGE_CDROM_PARAMETERS ||
cdpPage->PageLength != (sizeof(CDROM_PARAMETERS_PAGE)-2))
continue;
if (prev_timer != NULL)
*prev_timer = cdpPage->InactivityTimerMultiplier;
PRINTF(("Default Spindown Timer = %s\n", cd_spindown_name(cdpPage->InactivityTimerMultiplier)));
break;
}
if (i == num_mode_pages)
continue;
sense_len = sizeof(sense_buf);
scsi_BuildModeSelectDATA(sense_buf, &sense_len, 0, &mode_pages_data, sizeof(mode_pages_data), use6Byte);
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildModeSelectCDB(&cdb, sense_len, use6Byte);
if (if_layer.ExecScsiCmd(sense_buf, sense_len, &cdb, cdblen, SCSI_IOCTL_DATA_OUT, 2))
return TRUE;
}
return FALSE;
}
BOOL scsi_ReadSubQ(Q_SUBCHANNEL_DATA *rbuf, int loc)
{
CDB cdb;
BYTE cdblen;
if (SUBQ_MODE(scsi_subQmode) == SubQMode_Auto) {
eSubQMode tmp_subQmode;
if (!if_layer.DetectSubQMode(&tmp_subQmode))
return FALSE;
PRINTF(("Detected SubQ Mode = %s\n", subq_mode_name(tmp_subQmode)));
if_layer.InitSubQMode(tmp_subQmode);
}
switch (SUBQ_MODE(scsi_subQmode))
{
case SubQMode_Read_Q:
case SubQMode_Read_PW: {
BYTE data[RAW_PW_SECTOR_SIZE];
BOOL res;
int tmp_scsi_err;
if (!scsi_SelectReadMode(SUBQ_RMODE(scsi_subQmode), SUBQ_MODE(scsi_subQmode))) // adjust block size (for ReadMode_Scsi_28)
return FALSE;
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildReadSectorCDB(&cdb, loc, 1, &scsi_addr, SUBQ_RMODE(scsi_subQmode), SUBQ_MODE(scsi_subQmode));
memset(&data[RAW_SECTOR_SIZE], 0, sizeof(data) - RAW_SECTOR_SIZE);
res = if_layer.ExecScsiCmd(data, (SUBQ_MODE(scsi_subQmode) == SubQMode_Read_Q) ? RAW_Q_SECTOR_SIZE : RAW_PW_SECTOR_SIZE, &cdb, cdblen, SCSI_IOCTL_DATA_IN, 2);
tmp_scsi_err = scsi_err; // save result & 'scsi_err' value
scsi_SelectReadMode(scsi_rmode, SubQMode_Disabled); // restore block size (for ReadMode_Scsi_28)
scsi_err = tmp_scsi_err; // restore the 'scsi_err'value returned from 'ExecScsiCmd' call
if (!res)
return FALSE;
if (SUBQ_MODE(scsi_subQmode) == SubQMode_Read_Q) {
memcpy(rbuf, &data[RAW_SECTOR_SIZE], 16);
{ int __TODO__check_se_convertire_address_in_BCD__; }
// se necessario, convertire TrackRelativeAddress[] & AbsoluteAddress[] in BCD
} else {
scsi_DecodeSubPWtoQ(rbuf, &data[RAW_SECTOR_SIZE]);
}
} break;
case SubQMode_SubQ: {
SUB_Q_CHANNEL_DATA data;
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildSeekCDB(&cdb, loc, &scsi_addr);
if (!if_layer.ExecScsiCmd(NULL, 0, &cdb, cdblen, SCSI_IOCTL_DATA_UNSPECIFIED, 2))
return FALSE;
memset(&cdb, 0, sizeof(cdb));
cdblen = scsi_BuildReadQChannelCDB(&cdb, IOCTL_CDROM_CURRENT_POSITION);
memset(&data, 0, sizeof(data));
if (!if_layer.ExecScsiCmd(&data, sizeof(data), &cdb, cdblen, SCSI_IOCTL_DATA_IN, 2))
return FALSE;
rbuf->ADR = data.CurrentPosition.ADR;
rbuf->Control = data.CurrentPosition.Control;
rbuf->TrackNumber = INT2BCD(data.CurrentPosition.TrackNumber);
rbuf->IndexNumber = INT2BCD(data.CurrentPosition.IndexNumber);
rbuf->TrackRelativeAddress[0] = INT2BCD(data.CurrentPosition.TrackRelativeAddress[1]);
rbuf->TrackRelativeAddress[1] = INT2BCD(data.CurrentPosition.TrackRelativeAddress[2]);
rbuf->TrackRelativeAddress[2] = INT2BCD(data.CurrentPosition.TrackRelativeAddress[3]);
//rbuf->Filler = 0;
rbuf->AbsoluteAddress[0] = INT2BCD(data.CurrentPosition.AbsoluteAddress[1]);
rbuf->AbsoluteAddress[1] = INT2BCD(data.CurrentPosition.AbsoluteAddress[2]);
rbuf->AbsoluteAddress[2] = INT2BCD(data.CurrentPosition.AbsoluteAddress[3]);
//rbuf->Crc[0] = 0;
//rbuf->Crc[1] = 0;
} break;
case SubQMode_Auto:
case SubQMode_Disabled:
default:
return FALSE;
}
return TRUE;
}
| [
"mauzus@b38eb22e-9255-0410-b643-f940c3bf2d76"
]
| [
[
[
1,
434
]
]
]
|
27f65f20816d6707ab2fd66bd18d6be32f758bc2 | d0ae9c74f91979b9a99c122e8a40de4a5d955bae | /AstroVis2/CPosition.h | 1573bbb88f10a9e9737418726b433b83bbb9bae7 | []
| no_license | RyanDuToit/AstroVis | fe36bedb4f6fa628578de26c2173f9fe155483b0 | a8864f20553e0a824bbf0c309cb9d76617ba5aad | refs/heads/master | 2021-01-17T08:08:58.780711 | 2011-07-06T19:01:24 | 2011-07-06T19:01:24 | 2,008,297 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,007 | h | #ifndef CPosition_H
#define CPosition_H
class CPosition
{
private:
double value_[2];
public:
CPosition(
);
CPosition(
const CPosition& vector_in
);
CPosition(
const double& a_in,
const double& b_in
);
CPosition&
operator=(
const CPosition& vector_in
);
double&
operator[](
const unsigned short index_in
);
double
operator[](
const unsigned short index_in
) const;
double&
operator()(
const unsigned short index_in
);
double
operator()(
const unsigned short index_in
) const;
void
set(
const double& a_in,
const double& b_in
);
void
get(
double& a_out,
double& b_out
) const;
bool
operator==(
const CPosition& vector_in
) const;
bool
operator!=(
const CPosition& vector_in
) const;
CPosition
operator-(
) const;
friend CPosition
operator-(
const CPosition& vector0_in,
const CPosition& vector1_in
);
friend CPosition
operator+(
const CPosition& vector0_in,
const CPosition& vector1_in
);
friend double
operator*(
const CPosition& vector0_in,
const CPosition& vector1_in
);
friend CPosition
operator*(
const double& scalar_in,
const CPosition& vector_in
);
friend CPosition
operator*(
const CPosition& vector_in,
const double& scalar_in
);
friend CPosition
operator/(
const CPosition& vector_in,
const double& scalar_in
);
CPosition&
operator+=(
const CPosition& vector_in
);
CPosition&
operator-=(
const CPosition& vector_in
);
CPosition&
operator*=(
const double& scalar_in
);
CPosition&
operator/=(
const double& scalar_in
);
double
getLength(
) const;
void
getNormalized(
CPosition& vector_out
) const;
CPosition
getNormalized(
) const;
void
normalize(
);
bool
isNormalized(
) const;
bool
isNil(
) const;
};
#endif // CPosition_H
| [
"[email protected]"
]
| [
[
[
1,
157
]
]
]
|
43796748e0e2ed69f2295f0c8edec1848a74910b | 2112057af069a78e75adfd244a3f5b224fbab321 | /branches/refactor/src_root/src/ireon_ws/db/world_db.cpp | 7105902f5e08084566d578b00ff9beae4ef4f854 | []
| no_license | blockspacer/ireon | 120bde79e39fb107c961697985a1fe4cb309bd81 | a89fa30b369a0b21661c992da2c4ec1087aac312 | refs/heads/master | 2023-04-15T00:22:02.905112 | 2010-01-07T20:31:07 | 2010-01-07T20:31:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,149 | cpp | /* Copyright (C) 2005 ireon.org developers council
* $Id: world_db.cpp 361 2005-12-09 12:30:12Z llyeli $
* 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 program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file world_db.cpp
* World database
*/
#include "stdafx.h"
#include "world_app.h"
#include "db/world_db.h"
#include "db/account.h"
#include "net/ws_client.h"
#include "file/file.h"
#include "world/world.h"
#include "world/world_char_player.h"
#include "world/world_char_mob.h"
#include "net/ws_player_context.h"
#include "net/world_server.h"
CWorldDB* CWorldDB::m_singleton = 0;
bool CWorldDB::init()
{
assert(m_singleton == 0);
m_singleton = new CWorldDB;
if (!m_singleton->load())
return false;
return true;
};
bool CWorldDB::load()
{
FilePtr f(new CFile);
f->open("pdb.dat","r");
if( !f->isOpen() )
return true;
char* data = new char[f->getSize()];
f->read(data,f->getSize());
CData d(data,f->getSize(),false);
int num,i;
d >> CWorld::m_pulse;
///Loading accounts
d >> num;
AccPtr ptr;
for( i = 0; i < num; i++ )
{
ptr.reset( new CAccount );
ptr->serialize(d);
m_accounts.push_back(ptr);
}
///Loading player's data
d >> num;
CharPlayerPtr ch;
for( i = 0; i < num; i++ )
{
ch.reset(new CWorldCharPlayer());
ch->serialize(d);
m_players.insert(std::pair<uint,CharPlayerPtr>(ch->getId(),ch));
};
return true;
}
bool CWorldDB::save()
{
g_log("Saving db... ");
CData d;
d << CWorld::m_pulse;
//Saving accounts
d.wrt((int)m_accounts.size());
std::vector<AccPtr>::iterator i;
for( i = m_accounts.begin(); i != m_accounts.end(); i++ )
(*i)->serialize(d);
d.wrt((int)m_players.size());
std::map<uint,CharPlayerPtr>::iterator j;
for( j = m_players.begin(); j != m_players.end(); j++ )
{
(*j).second->serialize(d);
};
//Saving to file
FilePtr f(new CFile);
f->open("pdb.dat","w");
f->write(d.data(),d.length());
g_log("done.\n");
return true;
};
void CWorldDB::checkLogin(String name, String passwd, CNetClient* context)
{
removeWaitLogin(context);
WaitLoginStruct s;
s.context = context;
s.name = name;
s.password = passwd;
m_waitLogin.push_back(s);
CWorldApp::instance()->client()->getAccount(name.c_str());
};
void CWorldDB::removeWaitLogin(CNetClient* context)
{
std::vector<WaitLoginStruct>::iterator i,j;
for ( i = m_waitLogin.begin(); i < m_waitLogin.end(); i++ )
if( (*i).context == context )
{
j = i;
i--;
m_waitLogin.erase(j);
};
};
AccPtr CWorldDB::findAccount(String name)
{
std::vector<AccPtr>::iterator i;
for( i = m_accounts.begin(); i != m_accounts.end(); i++ )
if( (*i)->getName() == name )
return *i;
return AccPtr();
};
AccPtr CWorldDB::findAccount(uint id)
{
std::vector<AccPtr>::iterator i;
for( i = m_accounts.begin(); i != m_accounts.end(); i++ )
if( (*i)->getId() == id )
return *i;
return AccPtr();
};
void CWorldDB::removeAccount(uint id)
{
std::vector<AccPtr>::iterator i;
for( i = m_accounts.begin(); i != m_accounts.end(); i++ )
if( (*i)->getId() == id )
{
m_accounts.erase(i);
return;
}
};
AccPtr CWorldDB::updateAccount(AccPtr acc)
{
removeAccount(acc->getId());
m_accounts.push_back(acc);
return acc;
};
CharPlayerPtr CWorldDB::findCharPlayer(String name)
{
std::map<uint,CharPlayerPtr>::iterator i;
for( i = m_players.begin(); i != m_players.end(); i++ )
if( (*i).second->getName() == name )
return (*i).second;
return CharPlayerPtr();
};
CharPlayerPtr CWorldDB::findCharPlayer(uint id)
{
std::map<uint,CharPlayerPtr>::iterator i = m_players.find(id);
if( i != m_players.end() )
return (*i).second;
return CharPlayerPtr();
};
void CWorldDB::removeCharPlayer(uint id)
{
CLog::instance()->log(CLog::msgLvlInfo,"Removing player with id %d from database.\n",id);
std::map<uint,CharPlayerPtr>::iterator i = m_players.find(id);
if( i != m_players.end() )
{
CWorld::instance()->removeCharPlayer(id);
CWSPlayerContext* con = CWorldApp::instance()->server()->findContext((*i).second->getAccountId());
if( (*i).second->getContext() )
CWorldApp::instance()->server()->closeContext((*i).second->getContext());
m_players.erase(i);
return;
}
};
byte CWorldDB::updateCharPlayer(CharPlayerPtr ch)
{
removeCharPlayer(ch->getId());
m_players.insert(std::pair<uint,CharPlayerPtr>(ch->getId(),ch));
return CCE_NONE;
};
| [
"[email protected]"
]
| [
[
[
1,
209
]
]
]
|
601e71eacf7a7a62b012b83cdcbb66f004fe02ed | a62d03eea64b3d456d95fa7c1df38f8b545319e0 | /EntityRefNode.h | 5c1ed204dc6a0e7512ae2f87ebf39ca148a60027 | []
| no_license | radtek/evtx-cpp | 32dc4e30301739b069f7de19f04e807b9cdcc826 | c7f08457ec19b7e617685ba9e36a59e52a25384d | refs/heads/master | 2020-06-28T19:19:24.216152 | 2010-12-13T21:13:23 | 2010-12-13T21:13:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 422 | h | #ifndef _BXML_ENTITYREFNODE_
#define _BXML_ENTITYREFNODE_
#include "CustomTypes.h"
#include "Node.h"
#include "Name.h"
namespace Bxml {
class EntityRefNode :
public Node
{
public:
EntityRefNode(char* data, size_t length);
~EntityRefNode(void);
public:
// returns content string length
size_t getLength();
std::wstring* toXml();
bool isLast();
protected:
Name* name;
};
}
#endif
| [
"?????????????@SPARXXX-MOBILE"
]
| [
[
[
1,
29
]
]
]
|
c7faea411f89ef5c859a289ded74a300da285ec9 | 5dc78c30093221b4d2ce0e522d96b0f676f0c59a | /src/common/Data.h | 5743e97f08ffc1266444da7217625e6cc12ae45e | [
"Zlib"
]
| permissive | JackDanger/love | f03219b6cca452530bf590ca22825170c2b2eae1 | 596c98c88bde046f01d6898fda8b46013804aad6 | refs/heads/master | 2021-01-13T02:32:12.708770 | 2009-07-22T17:21:13 | 2009-07-22T17:21:13 | 142,595 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,322 | h | /**
* Copyright (c) 2006-2009 LOVE Development Team
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
**/
#ifndef LOVE_DATA_H
#define LOVE_DATA_H
// LOVE
#include "Object.h"
namespace love
{
class Data : public Object
{
public:
virtual ~Data() {};
/**
* Gets a pointer to the data.
**/
virtual void * getData() const = 0 ;
/**
* Gets the size of the data buffer.
**/
virtual int getSize() const = 0;
}; // Data
} // love
#endif // LOVE_DATA_H | [
"prerude@3494dbca-881a-0410-bd34-8ecbaf855390"
]
| [
[
[
1,
48
]
]
]
|
7c3a2e02cedf0f064b5aa09b45fd6081359bb52a | 11c7904170760e079f064347e62570ec3e1549fd | /borb/VesselAccelerationTracker.cpp | e527b142e8aa1dfae12f83aa1671eb792219c056 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | rstarkov/BoostOrbiter | 17f68b289f513cf056dc4324ac9c927f271dd849 | f9e481f23831edcf9ea799b56fe6768465316703 | refs/heads/master | 2020-11-29T20:44:32.725856 | 2011-03-27T21:27:36 | 2011-03-27T21:27:36 | 96,652,896 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,513 | cpp | //----------------------------------------------------------------------------
// This file is part of the BoostOrbiter project, and is subject to the terms
// and conditions defined in file 'license.txt'. Full list of contributors is
// available in file 'contributors.txt'.
//----------------------------------------------------------------------------
#include <PrecompiledBoostOrbiter.h>
#include "VesselAccelerationTracker.h"
namespace borb {
using namespace std;
void VesselAccelerationTracker::PreStep(VESSEL *vessel, double simdt)
{
MATRIX3 vesselRotLocal2Global;
vessel->GetRotationMatrix(vesselRotLocal2Global);
// Main acceleration calculation
VECTOR3 vel, gravForce;
vessel->GetWeightVector(gravForce);
GravAccel = mul(vesselRotLocal2Global, gravForce / vessel->GetMass());
vessel->GetGlobalVel(vel);
TotalAccel = (vel - _lastGlobalVel) / _simdtLast; // true acceleration in the inertial reference frame
PerceivedAccel = tmul(vesselRotLocal2Global, TotalAccel - GravAccel); // perceived acceleration onboard the ship
_simdtLast = simdt;
_lastGlobalVel = vel;
// Auxillary values
LatDeflectionFromVertical = atan2(-PerceivedAccel.x, PerceivedAccel.y);
if (_first)
{
_first = false;
LatDeflectionFromVertical = 0;
TotalAccel = GravAccel = PerceivedAccel = _V(0, 0, 0);
}
}
}
| [
"[email protected]"
]
| [
[
[
1,
40
]
]
]
|
f180e5413e40c65451f03d0648ebb7a74cf90ebe | 45fce7543d16bc451271e3e70dc6278d90e8e23b | /ActivityExample/Notifiee.h | 0012a367f62a77bb48eb9dbcc0c212be9161430e | []
| no_license | karlssonper/cs249a | 4bd40b20e903648a9eb2999f25a837e80e8edb34 | 63afe678ef5e1a76e05b474759a9d5ae68093625 | refs/heads/master | 2020-04-24T23:09:14.991112 | 2011-12-09T08:48:45 | 2011-12-09T08:48:45 | 2,816,441 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,067 | h | #ifndef __NOTIFIEE_H__
#define __NOTIFIEE_H__
#include <string>
#include "PtrInterface.h"
#include "Ptr.h"
using namespace std;
namespace Fwk {
class RootNotifiee : public PtrInterface<RootNotifiee> {
/* Deliberately empty */
};
template<typename Notifier>
class BaseNotifiee : public RootNotifiee {
public:
BaseNotifiee(Notifier* n = NULL) : notifier_(n) {
if (n != NULL) {
n->lastNotifieeIs(static_cast<typename Notifier::Notifiee*>(this));
}
}
~BaseNotifiee() {
if (notifier_ != NULL) {
notifier_->lastNotifieeIs(0);
}
}
Ptr<Notifier> notifier() const {
return notifier_;
}
void notifierIs(Ptr<Notifier> n) {
if (notifier_ != n) {
if (notifier_ != NULL) {
notifier_->lastNotifieeIs(0);
}
notifier_ = n;
if (n != NULL) {
n->lastNotifieeIs(
static_cast<typename Notifier::Notifiee*>(this)
);
}
}
}
private:
Ptr<Notifier> notifier_;
};
} //end namespace Fwk
#endif
| [
"[email protected]"
]
| [
[
[
1,
58
]
]
]
|
620dfccc979095dcf7f7a84a4d6c8cd9992f6f41 | 1d2705c9be9ee0f974c224eb794f2f8a9e9a3d50 | /gaze_machine_gui/gazemachine_mainframe.cpp | 7f1471ad681c9be5baf25b41235d3c050d80fb6f | []
| no_license | llvllrbreeze/alcorapp | dfe2551f36d346d73d998f59d602c5de46ef60f7 | 3ad24edd52c19f0896228f55539aa8bbbb011aac | refs/heads/master | 2021-01-10T07:36:01.058011 | 2008-12-16T12:51:50 | 2008-12-16T12:51:50 | 47,865,136 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,027 | cpp | /////////////////////////////////////////////////////////////////////////////
// Name: gazemachine_mainframe.cpp
// Purpose:
// Author: Andrea Carbone
// Modified by:
// Created: 25/03/2007 19:46:39
// RCS-ID:
// Copyright: Alcor
// Licence:
/////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "gazemachine_mainframe.h"
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
////@begin includes
////@end includes
#include "gazemachine_mainframe.h"
////@begin XPM images
////@end XPM images
/*!
* gazemachine_mainframe type definition
*/
IMPLEMENT_CLASS( gazemachine_mainframe, wxFrame )
/*!
* gazemachine_mainframe event table definition
*/
BEGIN_EVENT_TABLE( gazemachine_mainframe, wxFrame )
////@begin gazemachine_mainframe event table entries
EVT_BUTTON( ID_GAZELOG_BUTTON, gazemachine_mainframe::OnGazelogButtonClick )
EVT_BUTTON( ID_STOP_BUTTON, gazemachine_mainframe::OnStopButtonClick )
////@end gazemachine_mainframe event table entries
END_EVENT_TABLE()
/*!
* gazemachine_mainframe constructors
*/
gazemachine_mainframe::gazemachine_mainframe()
{
Init();
}
gazemachine_mainframe::gazemachine_mainframe( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
Init();
Create( parent, id, caption, pos, size, style );
}
/*!
* gazemachine_mainframe creator
*/
bool gazemachine_mainframe::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
{
////@begin gazemachine_mainframe creation
wxFrame::Create( parent, id, caption, pos, size, style );
CreateControls();
if (GetSizer())
{
GetSizer()->SetSizeHints(this);
}
Centre();
////@end gazemachine_mainframe creation
return true;
}
/*!
* gazemachine_mainframe destructor
*/
gazemachine_mainframe::~gazemachine_mainframe()
{
////@begin gazemachine_mainframe destruction
////@end gazemachine_mainframe destruction
}
/*!
* Member initialisation
*/
void gazemachine_mainframe::Init()
{
////@begin gazemachine_mainframe member initialisation
gazelog_btn = NULL;
stoplog_btn = NULL;
m_logname_ = NULL;
////@end gazemachine_mainframe member initialisation
gaze_.reset(new all::gaze::gaze_machine_t);
}
/*!
* Control creation for gazemachine_mainframe
*/
void gazemachine_mainframe::CreateControls()
{
////@begin gazemachine_mainframe content construction
gazemachine_mainframe* itemFrame1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
itemFrame1->SetSizer(itemBoxSizer2);
gazelog_btn = new wxButton;
gazelog_btn->Create( itemFrame1, ID_GAZELOG_BUTTON, _("Log\n"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer2->Add(gazelog_btn, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
stoplog_btn = new wxButton;
stoplog_btn->Create( itemFrame1, ID_STOP_BUTTON, _("Stop"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer2->Add(stoplog_btn, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
m_logname_ = new wxTextCtrl;
m_logname_->Create( itemFrame1, ID_NAME_TEXTCTRL, _("gazelog.bin"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer2->Add(m_logname_, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
////@end gazemachine_mainframe content construction
}
/*!
* Should we show tooltips?
*/
bool gazemachine_mainframe::ShowToolTips()
{
return true;
}
/*!
* Get bitmap resources
*/
wxBitmap gazemachine_mainframe::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin gazemachine_mainframe bitmap retrieval
wxUnusedVar(name);
return wxNullBitmap;
////@end gazemachine_mainframe bitmap retrieval
}
/*!
* Get icon resources
*/
wxIcon gazemachine_mainframe::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin gazemachine_mainframe icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end gazemachine_mainframe icon retrieval
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_GAZELOG_BUTTON
*/
void gazemachine_mainframe::OnGazelogButtonClick( wxCommandEvent& event )
{
wxString temp = m_logname_->GetValue();
std::string temps(temp.mb_str());
gaze_->set_logname( temps );
gaze_->run_machine(gaze::binlog);
gazelog_btn->Enable(false);
stoplog_btn->Enable(true);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_STOP_BUTTON
*/
void gazemachine_mainframe::OnStopButtonClick( wxCommandEvent& event )
{
gaze_->cancel();
gazelog_btn->Enable(true);
stoplog_btn->Enable(false);
}
| [
"andrea.carbone@1ffd000b-a628-0410-9a29-793f135cad17"
]
| [
[
[
1,
202
]
]
]
|
ba30559b53e39dd83ff3bda497aecb30b6b6bb96 | 032ea9816579a9869070a285d0224f95ba6a767b | /3dProject/trunk/findpath.cpp | bd076bf0fa0685ac9e82263d1e33849b706fb3a6 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
]
| permissive | sennheiser1986/oglproject | 3577bae81c0e0b75001bde57b8628d59c8a5c3cf | d975ed5a4392036dace4388e976b88fc4280a116 | refs/heads/master | 2021-01-13T17:05:14.740056 | 2010-06-01T15:48:38 | 2010-06-01T15:48:38 | 39,767,324 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,111 | cpp | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// STL A* Search implementation
// (C)2001 Justin Heyes-Jones
//
// Finding a path on a simple grid maze
// This shows how to do shortest path finding using A*
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "stlastar.h" // See header for copyright and usage information
#include "Map.h"
#include <iostream>
#include <math.h>
#define DEBUG_LISTS 0
#define DEBUG_LIST_LENGTHS_ONLY 0
using namespace std;
// Definitions
// Main
//int main( int argc, char *argv[] )
//{
//
// cout << "STL A* Search implementation\n(C)2001 Justin Heyes-Jones\n";
//
// // Our sample problem defines the world as a 2d array representing a terrain
// // Each element contains an integer from 0 to 5 which indicates the cost
// // of travel across the terrain. Zero means the least possible difficulty
// // in travelling (think ice rink if you can skate) whilst 5 represents the
// // most difficult. 9 indicates that we cannot pass.
//
// // Create an instance of the search class...
//
// AStarSearch<MapSearchNode> astarsearch;
// Map * instance = Map::getInstance();
// int width = instance->getWidth();
// int height = instance->getHeight();
//
// unsigned int SearchCount = 0;
//
// const unsigned int NumSearches = 1;
//
// while(SearchCount < NumSearches)
// {
//
// // Create a start state
// MapSearchNode nodeStart;
// nodeStart.x = rand()%width;
// nodeStart.y = rand()%height;
//
// // Define the goal state
// MapSearchNode nodeEnd;
// nodeEnd.x = rand()%width;
// nodeEnd.y = rand()%height;
//
// // Set Start and goal states
//
// astarsearch.SetStartAndGoalStates( nodeStart, nodeEnd );
//
// unsigned int SearchState;
// unsigned int SearchSteps = 0;
//
// do
// {
// SearchState = astarsearch.SearchStep();
//
// SearchSteps++;
//
// #if DEBUG_LISTS
//
// cout << "Steps:" << SearchSteps << "\n";
//
// int len = 0;
//
// cout << "Open:\n";
// MapSearchNode *p = astarsearch.GetOpenListStart();
// while( p )
// {
// len++;
// #if !DEBUG_LIST_LENGTHS_ONLY
// ((MapSearchNode *)p)->PrintNodeInfo();
// #endif
// p = astarsearch.GetOpenListNext();
//
// }
//
// cout << "Open list has " << len << " nodes\n";
//
// len = 0;
//
// cout << "Closed:\n";
// p = astarsearch.GetClosedListStart();
// while( p )
// {
// len++;
// #if !DEBUG_LIST_LENGTHS_ONLY
// p->PrintNodeInfo();
// #endif
// p = astarsearch.GetClosedListNext();
// }
//
// cout << "Closed list has " << len << " nodes\n";
// #endif
//
// }
// while( SearchState == AStarSearch<MapSearchNode>::SEARCH_STATE_SEARCHING );
//
// if( SearchState == AStarSearch<MapSearchNode>::SEARCH_STATE_SUCCEEDED )
// {
// cout << "Search found goal state\n";
//
// MapSearchNode *node = astarsearch.GetSolutionStart();
//
// #if DISPLAY_SOLUTION
// cout << "Displaying solution\n";
// #endif
// int steps = 0;
//
// node->PrintNodeInfo();
// for( ;; )
// {
// node = astarsearch.GetSolutionNext();
//
// if( !node )
// {
// break;
// }
//
// node->PrintNodeInfo();
// steps ++;
//
// };
//
// cout << "Solution steps " << steps << endl;
//
// // Once you're done with the solution you can free the nodes up
// astarsearch.FreeSolutionNodes();
//
//
// }
// else if( SearchState == AStarSearch<MapSearchNode>::SEARCH_STATE_FAILED )
// {
// cout << "Search terminated. Did not find goal state\n";
//
// }
//
// // Display the number of loops the search went through
// cout << "SearchSteps : " << SearchSteps << "\n";
//
// SearchCount ++;
//
// astarsearch.EnsureMemoryFreed();
// }
//
// return 0;
//}
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
| [
"fionnghall@444a4038-2bd8-11df-954b-21e382534593"
]
| [
[
[
1,
169
]
]
]
|
5c5172631b8db3a0af9cc44b3bcc680556969de7 | 0355816da4439e3022ff47421d542466ba8f6087 | /lab1/lab1gldrawer.h | bb60fdcf3dec696ade0e122d65a91b52c6d924ad | []
| no_license | winkie/cg | 59ca9b089866457752347d5000c3fa14dcb5604c | 2b70e4f28e08f7639c046e5d1c44ab649a81b2f1 | refs/heads/master | 2016-08-03T16:36:29.548040 | 2011-04-15T11:03:17 | 2011-04-15T11:06:11 | 1,599,604 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 726 | h | #ifndef LAB1GLWIDGET_H_
#define LAB1GLWIDGET_H_
#include <QtOpenGL>
#include <QDebug>
#include "lab1.h"
class Lab1GLDrawer : public QGLWidget
{
Q_OBJECT
public:
Lab1GLDrawer(QWidget *parent);
virtual ~Lab1GLDrawer();
protected:
int phi, psi;
void printAngles();
void keyPressEvent(QKeyEvent *e);
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
/*inline void putPixel(const QPoint &p, const QRgb &color)
{
glBegin(GL_POINT);
glColor3f(qRed(color) / 255.0f, qGreen(color) / 255.0f, qBlue(color) / 255.0f);
glVertex2i(p.x(), p.y());
glEnd();
}*/
};
#endif /* LAB1GLWIDGET_H_ */
| [
"winkie@desktop.(none)"
]
| [
[
[
1,
36
]
]
]
|
65e33d2007198fe4b5191383dcb3aa0bf2f3e0d5 | d64ed1f7018aac768ddbd04c5b465c860a6e75fa | /DlgVia.h | 1ee93d0c4d02a9a0b4bcb59a88af3f5eed997409 | []
| no_license | roc2/archive-freepcb-codeproject | 68aac46d19ac27f9b726ea7246cfc3a4190a0136 | cbd96cd2dc81a86e1df57b86ce540cf7c120c282 | refs/heads/master | 2020-03-25T00:04:22.712387 | 2009-06-13T04:36:32 | 2009-06-13T04:36:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,191 | h | #pragma once
#include "afxwin.h"
#include "SubdlgViaWidth.h"
#include "SubdlgClearance.h"
// CDlgViaPinSize dialog
class CDlgViaPinSize
: public CDialog
, public CSubDlg_ViaWidth
, public CSubDlg_Clearance
{
DECLARE_DYNAMIC(CDlgViaPinSize)
public:
CDlgViaPinSize(CWnd* pParent = NULL); // standard constructor
virtual ~CDlgViaPinSize();
void Initialize( CInheritableInfo const &via_width );
// Dialog Data
enum { IDD = IDD_VIA_PIN_SIZE };
CViaWidthInfo m_via_width;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
afx_msg void OnBnClicked_v_modify() { CSubDlg_ViaWidth::OnBnClicked_v_modify(); }
afx_msg void OnBnClicked_v_Default() { CSubDlg_ViaWidth::OnBnClicked_v_Default(); }
afx_msg void OnBnClicked_v_Set() { CSubDlg_ViaWidth::OnBnClicked_v_Set(); }
afx_msg void OnBnClicked_c_modify() { CSubDlg_Clearance::OnBnClicked_c_modify(); }
afx_msg void OnBnClicked_c_Default() { CSubDlg_Clearance::OnBnClicked_c_Default(); }
afx_msg void OnBnClicked_c_Set() { CSubDlg_Clearance::OnBnClicked_c_Set(); }
};
| [
"freepcb@9bfb2a70-7351-0410-8a08-c5b0c01ed314",
"jamesdily@9bfb2a70-7351-0410-8a08-c5b0c01ed314"
]
| [
[
[
1,
2
],
[
5,
6
],
[
8,
8
],
[
13,
13
],
[
15,
16
],
[
20,
21
],
[
25,
27
],
[
29,
30
],
[
39,
39
]
],
[
[
3,
4
],
[
7,
7
],
[
9,
12
],
[
14,
14
],
[
17,
19
],
[
22,
24
],
[
28,
28
],
[
31,
38
]
]
]
|
b15e1b340327d18ca2e048bc7f8accb55fa08a6c | b0252ba622183d115d160eb28953189930ebf9c0 | /Source/LoseGameState.cpp | 3e8e66382feaa95198984bfc8545eeb92dc26bce | []
| no_license | slewicki/khanquest | 6c0ced33bffd3c9ee8a60c1ef936139a594fe2fc | f2d68072a1d207f683c099372454add951da903a | refs/heads/master | 2020-04-06T03:40:18.180208 | 2008-08-28T03:43:26 | 2008-08-28T03:43:26 | 34,305,386 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,293 | cpp | #include "LoseGameState.h"
#include "CSGD_DirectInput.h"
#include "CSGD_TextureManager.h"
#include "CSGD_WaveManager.h"
#include "CGame.h"
#include "MainMenuState.h"
CLoseGameState::CLoseGameState(void)
{
}
CLoseGameState::~CLoseGameState(void)
{
}
void CLoseGameState::Enter()
{
m_pTM = CSGD_TextureManager::GetInstance();
m_pDI = CSGD_DirectInput::GetInstance();
m_pWM = CSGD_WaveManager::GetInstance();
m_nImageID = m_pTM->LoadTexture("Resource/KQ_LoseGame.png");
CMainMenuState::GetInstance()->SetPause(true);
m_BF.InitBitmapFont(m_pTM->LoadTexture("Resource/KQ_FontLucidiaWhite.png"),' ',16,128,128);
m_bAlpha = false;
m_bEsc = false;
m_fEscTimer = 0;
m_fTimer = 0;
m_nAlpha = 0;
CGame::GetInstance()->SetSongPlay(LOSEGAME);
}
void CLoseGameState::Exit()
{
m_pTM->ReleaseTexture(m_nImageID);
CMainMenuState::GetInstance()->SetPause(false);
}
bool CLoseGameState::Input(float fElapsedTime)
{
m_fEscTimer += fElapsedTime;
if(m_bEsc)
StartEsc();
if(m_pDI->GetBufferedKey(DIK_RETURN) || m_pDI->GetBufferedKey(DIK_NUMPADENTER) || m_pDI->GetBufferedJoyButton(JOYSTICK_X) || m_pDI->GetBufferedJoyButton(JOYSTICK_R2))
{
m_bEsc = true;
}
if(m_pDI->GetBufferedMouseButton(M_BUTTON_LEFT))
{
m_bEsc = true;
}
return true;
}
void CLoseGameState::Render(float fElapsedTime)
{
CSGD_Direct3D::GetInstance()->Clear(0,0,0);
m_pTM->Draw(m_nImageID,0,25,.80f,.80f,0,0,0,0,D3DCOLOR_ARGB(m_nAlpha,255,255,255));
m_BF.DrawTextA("The War Is Over!/Unfortunately, You have been defeated.",25,25,.30f,.30f,D3DCOLOR_ARGB(m_nAlpha,0,0,0));
}
void CLoseGameState::Update(float fElapsedTime)
{
if(m_bEsc)
return;
m_fTimer += fElapsedTime;
m_fEscTimer += fElapsedTime;
if(!m_bAlpha)
if(m_fTimer > .002f && m_nAlpha < 255)
{
m_fTimer = 0;
m_nAlpha++;
if(m_nAlpha == 255)
m_bAlpha = true;
}
if(m_bAlpha)
{
if(m_fTimer > 2.f)
if(m_fTimer > 6.f)
{
m_nAlpha--;
m_fTimer = 0;
if(m_nAlpha == 0)
CGame::GetInstance()->PopCurrentState();
}
}
}
void CLoseGameState::StartEsc()
{
if(m_fEscTimer > .001)
{
m_nAlpha--;
m_fEscTimer = 0;
if(m_nAlpha == 0)
{
CGame::GetInstance()->PopCurrentState();
}
}
} | [
"[email protected]@631b4192-2952-0410-9426-c5ed74a7d3ec",
"[email protected]@631b4192-2952-0410-9426-c5ed74a7d3ec"
]
| [
[
[
1,
61
],
[
63,
106
]
],
[
[
62,
62
]
]
]
|
49a8060e4d17b72719310a999eed76d7889d5f7e | 36bf908bb8423598bda91bd63c4bcbc02db67a9d | /WallPaper/include/WallPaperIconIndex.h | d7e382ee6ac853763b6373957d9952eb6eb1631b | []
| no_license | code4bones/crawlpaper | edbae18a8b099814a1eed5453607a2d66142b496 | f218be1947a9791b2438b438362bc66c0a505f99 | refs/heads/master | 2021-01-10T13:11:23.176481 | 2011-04-14T11:04:17 | 2011-04-14T11:04:17 | 44,686,513 | 0 | 1 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 2,996 | h | /*
WallPaperIconIndex.h
Luca Piergentili, 06/08/98
[email protected]
WallPaper (alias crawlpaper) - the hardcore of Windows desktop
http://www.crawlpaper.com/
copyright © 1998-2004 Luca Piergentili, all rights reserved
crawlpaper is a registered name, all rights reserved
This is a free software, released under the terms of the BSD license. Do not
attempt to use it in any form which violates the license or you will be persecuted
and charged for this.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
- Neither the name of "crawlpaper" nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _WALLPAPERICONINDEX_H
#define _WALLPAPERICONINDEX_H 1
#include "window.h"
#include "CListCtrlEx.h"
/*
ICONINDEX
*/
struct ICONINDEX {
int index;
char ext[_MAX_EXT+1];
};
/*
CIconIndexList
*/
class CIconIndexList : public CNodeList
{
public:
CIconIndexList() : CNodeList() {}
virtual ~CIconIndexList() {CNodeList::DeleteAll();}
void* Create(void)
{
return(new ICONINDEX);
}
void* Initialize(void* pVoid)
{
ICONINDEX* pData = (ICONINDEX*)pVoid;
if(!pData)
pData = (ICONINDEX*)Create();
if(pData)
memset(pData,'\0',sizeof(ICONINDEX));
return(pData);
}
BOOL PreDelete(ITERATOR iter)
{
if((ICONINDEX*)iter->data)
delete ((ICONINDEX*)iter->data),iter->data = (ICONINDEX*)NULL;
return(TRUE);
}
int Size(void) {return(sizeof(ICONINDEX));}
#ifdef _DEBUG
const char* Signature(void) {return("CIconIndexList");}
#endif
};
int GetIconIndex(LPCSTR lpcszFileName,CIconIndexList* plistIconIndex,CListCtrlEx* pListCtrlEx);
#endif // _WALLPAPERICONINDEX_H
| [
"[email protected]"
]
| [
[
[
1,
89
]
]
]
|
c0c62ed3c5122a0810c3e77feaf05b8ab071bcfa | 95a8d2b18434b00ff35ffddd6b4c2fb744ffab48 | /src/tagger.h | e3d707bace13deb2b4c197f5dd7ae3c7da61a6f8 | []
| no_license | DTM9025/musicroom | 912ee0829a26e67be2d3c070fcb1cf2680ec2883 | cf1e97209c279fbbeb210601e7466af35f9848fd | refs/heads/master | 2020-03-20T13:07:44.448378 | 2011-09-01T22:50:42 | 2011-09-01T22:50:42 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,106 | h | // Music Room Interface
// --------------------
// tagger.h - Music Room specific tagging
// --------------------
// "©" Nmlgc, 2010-2011
// Forward declarations
class MRTag;
class Tagger : public FXThread, FXObject
{
protected:
// Temporary string storage
FXString Comment[LANG_COUNT];
FXString Game[LANG_COUNT];
FXString TN[2];
FXString Genre;
FXString Year;
volatile bool StopReq;
bool Search(TrackInfo* TI, const FXString& Ext, FXString* FN); // Searches for a file which might match the given track
public:
FXString Ext;
bool Active;
virtual FXint run(); // FOX Thread function. Runs the extraction loop
MRTag* NewFmtClass(const FXString& Ext); // Gets a new tag class for the [Ext] extension
bool TagBasic(MRTag* TF, GameInfo* GI, TrackInfo* TI); // Writes only the basic tags
bool TagExt(MRTag* TF, GameInfo* GI, TrackInfo* TI); // Writes comments and other language tags
// Writes complete tags of [TI] for the [Ext] format to [TagFN]
mrerr Tag(TrackInfo* TI, FXString& TagFN, FXString& Ext);
void Stop();
SINGLETON(Tagger);
};
| [
"[email protected]"
]
| [
[
[
1,
40
]
]
]
|
fbe83a321604d9b1dae35aed66a20e5c81739656 | f90b1358325d5a4cfbc25fa6cccea56cbc40410c | /src/GUI/proRataImage.h | ffe2c615262d04b70b6738815dab813f31325e13 | []
| no_license | ipodyaco/prorata | bd52105499c3fad25781d91952def89a9079b864 | 1f17015d304f204bd5f72b92d711a02490527fe6 | refs/heads/master | 2021-01-10T09:48:25.454887 | 2010-05-11T19:19:40 | 2010-05-11T19:19:40 | 48,766,766 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 831 | h |
#ifndef PRORATAIMAGE_H
#define PRORATAIMAGE_H
#include <QString>
#include <QPixmap>
#include <QLabel>
#include <QVBoxLayout>
#include <QSize>
#include <QToolButton>
#include <QIcon>
#if 0
#include "helpIcons.h"
#endif
#include "notAvailableImage.h"
#include "titleLabel.h"
class ProRataImage : public QWidget
{
public:
ProRataImage( const QString & qsFilename, QWidget * qwParent = 0 );
ProRataImage( const QPixmap & qpImg, QWidget * qwParent = 0 );
~ProRataImage();
void setTitle( const QString & );
protected:
void resizeEvent( QResizeEvent * );
private slots:
void helpClicked();
private:
void setup();
QPixmap qpImage;
QLabel *qlGraph;
TitleLabel *tlImageTitle;
QVBoxLayout *qvbMainLayout;
//QToolButton *qpbHelp;
};
#endif //PRORATAIMAGE_H
| [
"chongle.pan@c58cc1ec-c975-bb1e-ac29-6983d7497d3a"
]
| [
[
[
1,
46
]
]
]
|
f12cd80149b6e02ece77bbb752aa645e20523c23 | c4da0878cc154162ef24f3601755396038bff5c1 | /Collision.cpp | 20c663597eff9d0236ddc35cf880021d650fffb1 | []
| no_license | splinterofchaos/Gravity-Battle | e19c166fa5b130c43e9a8150cca36ea23e0046f0 | 1fb26743be4a6f39eae095dc1bb42bfdc64511a0 | refs/heads/master | 2016-09-06T04:12:35.568646 | 2011-10-23T17:01:48 | 2011-10-23T17:01:48 | 935,258 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 304 | cpp |
#include "Collision.h"
bool collision( CollisionData& x, CollisionData& y )
{
return x.collide_with( y );
}
bool collision( LoopCollisionData& loop, PointCollisionData& point )
{
Vector<float,2> diff = point.pos() - loop.pos();
return magnitude(diff) > loop.inner_radius();
}
| [
"[email protected]"
]
| [
[
[
1,
13
]
]
]
|
9c274955f1005dd4014b1edbaebf527463dbc318 | 58496be10ead81e2531e995f7d66017ffdfc6897 | /Include/IStreamFileImpl.h | 71481a3ff04c8c3e4860082c321e2270648d40ba | []
| no_license | Diego160289/cross-fw | ba36fc6c3e3402b2fff940342315596e0365d9dd | 532286667b0fd05c9b7f990945f42279bac74543 | refs/heads/master | 2021-01-10T19:23:43.622578 | 2011-01-09T14:54:12 | 2011-01-09T14:54:12 | 38,457,864 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,553 | h | //============================================================================
// Date : 22.12.2010
// Author : Tkachenko Dmitry
// Copyright : (c) Tkachenko Dmitry ([email protected])
//============================================================================
#ifndef __ISTREAMFILEIMPL_H__
#define __ISTREAMFILEIMPL_H__
#include "IFacesTools.h"
#include "Exceptions.h"
#include "File.h"
#include "Pointers.h"
#include "IStreamMemoryImpl.h"
#include "IStreamHelper.h"
namespace IFacesImpl
{
using IFaces::RetCode;
using IFaces::retOk;
using IFaces::retFalse;
using IFaces::retFail;
using IFaces::retBadParam;
DECLARE_RUNTIME_EXCEPTION(IStreamFileImpl)
class IStreamFileImpl
: public Common::CoClassBase
<
TYPE_LIST_1(IFaces::IStream)
>
{
public:
DECLARE_UUID(26e45dfb-cd96-4d83-8302-6201e3e82160)
IStreamFileImpl();
virtual ~IStreamFileImpl();
// IStream
virtual RetCode GetSize(unsigned long *size) const;
virtual RetCode Read(void *buf, unsigned long bufSize, unsigned long *readBytes);
virtual RetCode Write(const void *buf, unsigned long bytes);
virtual RetCode SeekToBegin();
virtual RetCode SeekToEnd();
virtual RetCode SeekTo(unsigned long pos);
virtual RetCode GetPos(unsigned long *pos) const;
virtual RetCode CopyTo(IStream *dest) const;
void Init(const std::string &name, bool isNew);
private:
Common::SharedPtr<System::File> File;
};
Common::RefObjPtr<IStreamFileImpl>
OpenFileStream(const std::string &name, bool createNew,
const Common::ISynObj &syn);
template <typename TSyn>
Common::RefObjPtr<IStreamFileImpl>
OpenFileStream(const std::string &name, bool createNew)
{
Common::RefObjPtr<IStreamFileImpl> Ret =
Common::IBaseImpl<IStreamFileImpl>::Create<TSyn>();
Ret->Init(name, createNew);
return Ret;
}
Common::RefObjPtr<IFaces::IRawDataBuffer>
LoadFileToBuffer(const std::string &fileName, const Common::ISynObj &syn);
template <typename TSyn>
Common::RefObjPtr<IFaces::IRawDataBuffer>
LoadFileToBuffer(const std::string &fileName)
{
Common::RefObjPtr<IFaces::IStream> Stream(OpenFileStream<TSyn>(fileName, false));
Common::RefObjPtr<IFaces::IStream> Ret(OpenMemoryStream<TSyn>());
IStreamHelper(Stream).CopyTo(Ret);
return Common::RefObjQIPtr<IFaces::IRawDataBuffer>(Ret);
}
}
#endif // !__ISTREAMFILEIMPL_H__
| [
"TkachenkoDmitryV@d548627a-540d-11de-936b-e9512c4d2277"
]
| [
[
[
1,
85
]
]
]
|
1e90fe516f03c06e6227ebbe41e30e40bfb662a0 | e4e657d86ee7dedea0b3af98b377d649e5f12ef8 | /matching_to_many_images/StatsTable.cpp | 8d536e8b08c11e76d1e1a5e1bad10bc2fa396eb9 | []
| no_license | LZH711/Image-Matching | dc5b46d77d5dcf762f17688e5f8eb1a00eb0c3b0 | 2d58a68996cbb67f7fae5201109d8e1e754257aa | refs/heads/master | 2021-01-23T23:03:58.683085 | 2011-05-25T01:00:02 | 2011-05-25T01:00:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,047 | cpp | // TODO: this is very specific for use with SURFMatcher right now
#include <fstream>
#include <string>
#include "util.h"
#include "StatsTable.h"
StatsTable::StatsTable() {
struct tm timeinfo = Util::GetTimeInfo();
char buffer[80];
strftime(buffer, 80, "MATCH-%m-%d-%Y.html", &timeinfo);
file_ = new std::ofstream(buffer, std::ios::out);
(*file_) << "<html><head>Match stats</head><body>\n";
BeginTable();
}
StatsTable::~StatsTable() {
EndTable();
if (file_) {
(*file_) << "\n</body></html>\n";
file_->close();
delete file_;
file_ = NULL;
}
}
void StatsTable::BeginTable() {
(*file_) << "<table>\n\t<tr><th>filename</th><th>match %</th><th>match with</th><th>time</th></tr>\n";
}
void StatsTable::WriteRow(string filename, double match_percent, string match_with, double time) {
(*file_) << "\t<tr><td>" << filename << "</td><td>" << match_percent << "</td><td>" << match_with << "</td><td>" << time << "<td></td></tr>\n";
}
void StatsTable::EndTable() {
(*file_) << "</table>\n";
} | [
"[email protected]"
]
| [
[
[
1,
39
]
]
]
|
3b8c06e6a9fa260d442d3edd9d356938285fc960 | c4e8cb1539bc0cf5cb119af4a6b6212230f937aa | /Babel/AudioThread.hpp | bc73a194496297fc66fb56e48326c11625526878 | []
| no_license | RemiGuillard/Babel-save-03 | 56e93fd7beda23be5faad102b43090a2d756f0d2 | 25893350dc14c6434dcc053302440bdca710c59e | refs/heads/master | 2021-01-13T02:14:46.982890 | 2010-11-29T17:40:53 | 2010-11-29T17:40:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,252 | hpp | #ifndef AUDIOTHREAD_H
# define AUDIOTHREAD_H
#include <QThread>
#include <QMessageBox>
#include "IOStreamData.hpp"
#include "AbsIOSound.hpp"
#include "PaIOSound.h"
#include "UdpNetwork.h"
#include "DataClientPack.h"
template <typename T>
class AudioThread : public QThread
{
public:
AudioThread(QString ip, quint16 port, IOStreamData<T> *Data) : data(Data)
{
this->net.socketConnection(ip, port);
/* QUdpSocket& socket = static_cast<QUdpSocket&>(this->net.getSocket());
socket.bind(port);
this->net.socketConnection(ip, port);*/
}
//Instanciation explicite!!!!!!
public:
//void setIOSound(AbsIOSound<T> *);
template <typename A>
void setBuf(A *dest, A *from)
{
int i;
for (i = 0 ; i < FRAMES_PER_BUFFER ; i++)
dest[i] = from[i];
}
/////////////////////////////////////////
void setData(IOStreamData<T> &Data, IOStreamData<T> *obj)
{
Data.IAvailable = obj->IAvailable;
Data.IMaxFrameIndex = obj->IMaxFrameIndex;
Data.OAvailable = obj->IAvailable;
this->setBuf<T>(Data.IBuf, obj->IBuf);
}
///////////////////////////////////////////
void run()
{
while (this->data->ThreadEnd)
{
this->setData(this->DataTmp, this->data);
//if (this->DataTmp.IAvailable)
//{
this->enc.encode(this->DataTmp.IBuf, this->DataTmp.encoded);
DataClientPack send;
send.dataLenght = FRAMES_PER_BUFFER;
this->setBuf(send.data, this->DataTmp.encoded);
this->net.packetSend(reinterpret_cast<char*>(&send));
//this->data->IAvailable = false;
//}
/*if (!this->DataTmp.OAvailable)
{
if (this->net.getSocket().waitForReadyRead(10))
{
DataClientPack *rcv;
rcv = reinterpret_cast<DataClientPack*>(this->net.packetRcv());
SAMPLE output[FRAMES_PER_BUFFER];
this->enc.decode(rcv->data, output);
this->data->OMaxFrameIndex = rcv->dataLenght / NUM_CHANNELS;
this->setBuf(this->data->OBuf, output);
this->data->OAvailable = true;
}
}*/
}
/*this->net.disconnect();*/
return ;
}
private:
IOStreamData<T> *data;
UdpNetwork net;
IOStreamData<T> DataTmp;
Encoder enc;
};
#endif // !AUDIOTHREAD_H
| [
"[email protected]",
"[email protected]"
]
| [
[
[
1,
6
],
[
8,
67
],
[
69,
81
]
],
[
[
7,
7
],
[
68,
68
]
]
]
|
09501cf0dd9e8842a808f4fa557171af9f134c21 | 12460a725069d35c4040970da95de11e997d668a | /CodePaint/CPP/UIParser.cpp | d6a30a99b308f77b15599e1aca38618d7fc991db | []
| no_license | lxyppc/lxyppc-codepaint | bae3778d299d197efcb990d24eb4505cc159e4d0 | 93ac2f3d7484e0e98a70470ab71ebfce2beb18bd | refs/heads/master | 2016-09-05T19:50:06.926231 | 2010-04-08T18:26:06 | 2010-04-08T18:26:06 | 32,801,595 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,327 | cpp | // UIParser.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "UIParser.h"
#include "UIParserDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CUIParserApp
BEGIN_MESSAGE_MAP(CUIParserApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
// CUIParserApp construction
CUIParserApp::CUIParserApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CUIParserApp object
CUIParserApp theApp;
// CUIParserApp initialization
BOOL CUIParserApp::InitInstance()
{
//TODO: call AfxInitRichEdit2() to initialize richedit2 library.
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
AfxInitRichEdit2();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
CUIParserDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
| [
"lxyppc@e4b13638-01d7-11df-a6f0-ed93ac2c91d0"
]
| [
[
[
1,
80
]
]
]
|
ff37f15cc47983d7715ed49a68e06d7df48bbc1a | 2f77d5232a073a28266f5a5aa614160acba05ce6 | /01.DevelopLibrary/03.Code/UI/EasySmsWndBase.h | 5508e78aa66e769f3dbfc742776f0072eb1b38f6 | []
| no_license | radtek/mobilelzz | 87f2d0b53f7fd414e62c8b2d960e87ae359c81b4 | 402276f7c225dd0b0fae825013b29d0244114e7d | refs/heads/master | 2020-12-24T21:21:30.860184 | 2011-03-26T02:19:47 | 2011-03-26T02:19:47 | 58,142,323 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,970 | h | #ifndef __EASYSMSWNDBASE_h__
#define __EASYSMSWNDBASE_h__
//#define UI_TEST
#include "../CommonLib/FunctionLib/CommonTypes.h"
class CEasySmsWndBase;
/////////////////CEasySmsListBase/////////////////////////////////////////////////////////
class CEasySmsListBase : public UiListEx
{
public:
friend CEasySmsWndBase;
CEasySmsListBase();
virtual ~CEasySmsListBase();
public:
// 当某一项即将被删除之前,delete 其自定义项数据
// virtual void OnRemoveItem( int nIndex );
virtual int OnLButtonUp( UINT fwKeys, int xPos, int yPos );
protected:
void setEasySmsWndBase( CEasySmsWndBase *pCEasySmsWndBase );
private:
ImageContainer m_imgContainer_base;
CEasySmsWndBase *m_pCEasySmsWndBase;
};
///////////////////////CEasySmsWndBase///////////////////////////////////////////////////
class CEasySmsWndBase : public CMzWndEx
{
MZ_DECLARE_DYNAMIC( CEasySmsWndBase );
public:
friend CEasySmsListBase;
CEasySmsWndBase(void);
virtual ~CEasySmsWndBase(void);
public:
virtual BOOL OnInitDialog();
virtual LRESULT MzDefWndProc(UINT message, WPARAM wParam, LPARAM lParam);
void SetListItem( ListItemEx* pItem );
protected:
virtual int DoModalBase( CMzWndEx *pCMzWndEx );
virtual void DoSthForItemRemove( ListItemEx* pItem );
virtual void DoSthForItemBtnUpSelect( ListItemEx* pItem );
virtual void DoSthForItemSelect( ListItemEx* pItem );
virtual void DoSthForTooBarHoldPress( int nIndex );
virtual void ReturnToMainWnd();
virtual HRESULT RemoveSmsInDb( ListItemEx* pItem );
wchar_t * GetNameOrTel( ListItemEx* pItem );
wchar_t * GetMsgInfoFromIterm( ListItemEx* pItem );
private:
protected:
CEasySmsListBase m_list_base;
UiToolbar_Text m_toolBar_base;
ImageContainer m_imgContainer_base;
ListItemEx* m_pItem;
CoreItemData_t* m_pCoreItemData;
private:
};
#endif
| [
"[email protected]",
"lidan8908589@8983de3c-2b35-11df-be6c-f52728ce0ce6"
]
| [
[
[
1,
3
],
[
5,
92
],
[
94,
98
]
],
[
[
4,
4
],
[
93,
93
]
]
]
|
fe50dbcac4c0154724d97dbbc963420b618bb297 | 70ae839ba975347dc4c97ce6ff3e87056d4baa5e | /Tutorial4/Tutorial4/src/Tutorial4.cpp | 8714a242ca803700b79a777376ad6e8064d48c50 | []
| no_license | jbreslin33/networksinbad | 63a81d9a240b517b1a631bd2173dcd0bbe8ff7cb | e9f15b83aab010bfc7ae570880c11ec6d52aadf9 | refs/heads/master | 2020-06-03T15:20:15.140383 | 2011-03-12T13:41:51 | 2011-03-12T13:41:51 | 37,391,302 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,517 | cpp | //#include "Tutorial4.h"
#include "common.h"
#include "SinbadCharacterController.h"
CArmyWar* game;
bool keys[256];
void CArmyWar::createPlayer(int index)
{
/*
Ogre::Entity* NinjaEntity = mSceneMgr->createEntity("sinbad.mesh");
//Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(NinjaEntity);
//node->setPosition(Ogre::Vector3(10, 10, 10));
*/
//clientData *client = game->GetClientPointer(index);
//client->myNode = node;
clientData *client = game->GetClientPointer(index);
client->character = new SinbadCharacterController(mSceneMgr->getCamera("PlayerCam"), "Sinbad" + index);
}
//-------------------------------------------------------------------------------------
void CArmyWar::createScene(void)
{
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.75, 0.75, 0.75));
Ogre::Light* pointLight = mSceneMgr->createLight("pointLight");
pointLight->setType(Ogre::Light::LT_POINT);
pointLight->setPosition(Ogre::Vector3(250, 150, 250));
pointLight->setDiffuseColour(Ogre::ColourValue::White);
pointLight->setSpecularColour(Ogre::ColourValue::White);
//character = new SinbadCharacterController(mSceneMgr->getCamera("PlayerCam"), "sinbad");
}
//-------------------------------------------------------------------------------------
bool CArmyWar::processUnbufferedInput(const Ogre::FrameEvent& evt)
{
if (mKeyboard->isKeyDown(OIS::KC_W)) // Forward
{
keys[VK_UP] = TRUE;
}
else
{
keys[VK_UP] = FALSE;
}
if (mKeyboard->isKeyDown(OIS::KC_S)) // Backward
{
keys[VK_DOWN] = TRUE;
}
else
{
keys[VK_DOWN] = FALSE;
}
if (mKeyboard->isKeyDown(OIS::KC_A)) // Left - yaw or strafe
{
keys[VK_LEFT] = TRUE;
}
else
{
keys[VK_LEFT] = FALSE;
}
if (mKeyboard->isKeyDown(OIS::KC_D)) // Right - yaw or strafe
{
keys[VK_RIGHT] = TRUE;
}
else
{
keys[VK_RIGHT] = FALSE;
}
return true;
}
//-------------------------------------------------------------------------------------
bool CArmyWar::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
bool ret = BaseApplication::frameRenderingQueued(evt);
if(!processUnbufferedInput(evt)) return false;
//if (localClient)
//localClient->character->addTime(evt.timeSinceLastFrame);
if(game != NULL)
{
game->CheckKeys();
game->RunNetwork(evt.timeSinceLastFrame * 1000);
rendertime = evt.timeSinceLastFrame;
//game->Frame();
}
return ret;
}
//-------------------------------------------------------------------------------------
bool CArmyWar::keyPressed( const OIS::KeyEvent &arg )
{
//Ogre::LogManager::getSingletonPtr()->logMessage("*** keyPressed CArmyWar n***");
//LogString("keyPressed");
//game->localClient->character->injectKeyDown(arg);
if(localClient)
localClient->character->injectKeyDown(arg);
return BaseApplication::keyPressed(arg);
}
bool CArmyWar::keyReleased( const OIS::KeyEvent &arg )
{
//Ogre::LogManager::getSingletonPtr()->logMessage("*** keyPressed CArmyWar n***");
//LogString("keyReleased");
//game->localClient->character->injectKeyUp(arg);
if(localClient)
localClient->character->injectKeyUp(arg);
return BaseApplication::keyReleased(arg);
}
//-------------------------------------------------------------------------------------
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{
// Create application object
game = new CArmyWar;
//game = new CArmyWar;
game->StartConnection();
StartLogConsole();
try {
game->go();
} catch( Ogre::Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
std::cerr << "An exception has occured: " <<
e.getFullDescription().c_str() << std::endl;
#endif
}
return 0;
}
#ifdef __cplusplus
}
#endif | [
"[email protected]"
]
| [
[
[
1,
172
]
]
]
|
954e985f783b9f0a1dead1c30c1b47c6ddc7a16f | 27d5670a7739a866c3ad97a71c0fc9334f6875f2 | /CPP/Targets/WayFinder/symbian-r6/PictureContainer.h | ccbdeff275e92ef498a36054f9b9081ad857bfe6 | [
"BSD-3-Clause"
]
| permissive | ravustaja/Wayfinder-S60-Navigator | ef506c418b8c2e6498ece6dcae67e583fb8a4a95 | 14d1b729b2cea52f726874687e78f17492949585 | refs/heads/master | 2021-01-16T20:53:37.630909 | 2010-06-28T09:51:10 | 2010-06-28T09:51:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,837 | h | /*
Copyright (c) 1999 - 2010, Vodafone Group Services Ltd
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __PICTURECONTAINER_H__
#define __PICTURECONTAINER_H__
#include <gdi.h>
/**
* PictureContainer
*/
class PictureContainer
{
public:
/**
*
*/
virtual void PictureError( TInt aError ) = 0;
virtual void ScalingDone() = 0;
};
#endif //
| [
"[email protected]"
]
| [
[
[
1,
37
]
]
]
|
6f9222ff0c16f1c99c6e81f43695c059f7043855 | f8403b6b1005f80d2db7fad9ee208887cdca6aec | /JuceLibraryCode/modules/juce_gui_basics/menus/juce_MenuBarComponent.cpp | a1f660d565907a5cad8609874336c173381a7891 | []
| no_license | sonic59/JuceText | 25544cb07e5b414f9d7109c0826a16fc1de2e0d4 | 5ac010ffe59c2025d25bc0f9c02fc829ada9a3d2 | refs/heads/master | 2021-01-15T13:18:11.670907 | 2011-10-29T19:03:25 | 2011-10-29T19:03:25 | 2,507,112 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,187 | cpp | /*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-11 by Raw Material Software Ltd.
------------------------------------------------------------------------------
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
==============================================================================
*/
BEGIN_JUCE_NAMESPACE
//==============================================================================
MenuBarComponent::MenuBarComponent (MenuBarModel* model_)
: model (nullptr),
itemUnderMouse (-1),
currentPopupIndex (-1),
topLevelIndexClicked (0)
{
setRepaintsOnMouseActivity (true);
setWantsKeyboardFocus (false);
setMouseClickGrabsKeyboardFocus (false);
setModel (model_);
}
MenuBarComponent::~MenuBarComponent()
{
setModel (nullptr);
Desktop::getInstance().removeGlobalMouseListener (this);
}
MenuBarModel* MenuBarComponent::getModel() const noexcept
{
return model;
}
void MenuBarComponent::setModel (MenuBarModel* const newModel)
{
if (model != newModel)
{
if (model != nullptr)
model->removeListener (this);
model = newModel;
if (model != nullptr)
model->addListener (this);
repaint();
menuBarItemsChanged (nullptr);
}
}
//==============================================================================
void MenuBarComponent::paint (Graphics& g)
{
const bool isMouseOverBar = currentPopupIndex >= 0 || itemUnderMouse >= 0 || isMouseOver();
getLookAndFeel().drawMenuBarBackground (g,
getWidth(),
getHeight(),
isMouseOverBar,
*this);
if (model != nullptr)
{
for (int i = 0; i < menuNames.size(); ++i)
{
Graphics::ScopedSaveState ss (g);
g.setOrigin (xPositions [i], 0);
g.reduceClipRegion (0, 0, xPositions[i + 1] - xPositions[i], getHeight());
getLookAndFeel().drawMenuBarItem (g,
xPositions[i + 1] - xPositions[i],
getHeight(),
i,
menuNames[i],
i == itemUnderMouse,
i == currentPopupIndex,
isMouseOverBar,
*this);
}
}
}
void MenuBarComponent::resized()
{
xPositions.clear();
int x = 0;
xPositions.add (x);
for (int i = 0; i < menuNames.size(); ++i)
{
x += getLookAndFeel().getMenuBarItemWidth (*this, i, menuNames[i]);
xPositions.add (x);
}
}
int MenuBarComponent::getItemAt (const Point<int>& p)
{
for (int i = 0; i < xPositions.size(); ++i)
if (p.getX() >= xPositions[i] && p.getX() < xPositions[i + 1])
return reallyContains (p, true) ? i : -1;
return -1;
}
void MenuBarComponent::repaintMenuItem (int index)
{
if (isPositiveAndBelow (index, xPositions.size()))
{
const int x1 = xPositions [index];
const int x2 = xPositions [index + 1];
repaint (x1 - 2, 0, x2 - x1 + 4, getHeight());
}
}
void MenuBarComponent::setItemUnderMouse (const int index)
{
if (itemUnderMouse != index)
{
repaintMenuItem (itemUnderMouse);
itemUnderMouse = index;
repaintMenuItem (itemUnderMouse);
}
}
void MenuBarComponent::setOpenItem (int index)
{
if (currentPopupIndex != index)
{
repaintMenuItem (currentPopupIndex);
currentPopupIndex = index;
repaintMenuItem (currentPopupIndex);
Desktop& desktop = Desktop::getInstance();
if (index >= 0)
desktop.addGlobalMouseListener (this);
else
desktop.removeGlobalMouseListener (this);
}
}
void MenuBarComponent::updateItemUnderMouse (const Point<int>& p)
{
setItemUnderMouse (getItemAt (p));
}
void MenuBarComponent::showMenu (int index)
{
if (index != currentPopupIndex)
{
PopupMenu::dismissAllActiveMenus();
menuBarItemsChanged (nullptr);
setOpenItem (index);
setItemUnderMouse (index);
if (index >= 0)
{
PopupMenu m (model->getMenuForIndex (itemUnderMouse,
menuNames [itemUnderMouse]));
if (m.lookAndFeel == nullptr)
m.setLookAndFeel (&getLookAndFeel());
const Rectangle<int> itemPos (xPositions [index], 0, xPositions [index + 1] - xPositions [index], getHeight());
m.showMenuAsync (PopupMenu::Options().withTargetComponent (this)
.withTargetScreenArea (localAreaToGlobal (itemPos))
.withMinimumWidth (itemPos.getWidth()),
ModalCallbackFunction::forComponent (menuBarMenuDismissedCallback, this, index));
}
}
}
void MenuBarComponent::menuBarMenuDismissedCallback (int result, MenuBarComponent* bar, int topLevelIndex)
{
if (bar != nullptr)
bar->menuDismissed (topLevelIndex, result);
}
void MenuBarComponent::menuDismissed (int topLevelIndex, int itemId)
{
topLevelIndexClicked = topLevelIndex;
postCommandMessage (itemId);
}
void MenuBarComponent::handleCommandMessage (int commandId)
{
const Point<int> mousePos (getMouseXYRelative());
updateItemUnderMouse (mousePos);
if (currentPopupIndex == topLevelIndexClicked)
setOpenItem (-1);
if (commandId != 0 && model != nullptr)
model->menuItemSelected (commandId, topLevelIndexClicked);
}
//==============================================================================
void MenuBarComponent::mouseEnter (const MouseEvent& e)
{
if (e.eventComponent == this)
updateItemUnderMouse (e.getPosition());
}
void MenuBarComponent::mouseExit (const MouseEvent& e)
{
if (e.eventComponent == this)
updateItemUnderMouse (e.getPosition());
}
void MenuBarComponent::mouseDown (const MouseEvent& e)
{
if (currentPopupIndex < 0)
{
const MouseEvent e2 (e.getEventRelativeTo (this));
updateItemUnderMouse (e2.getPosition());
currentPopupIndex = -2;
showMenu (itemUnderMouse);
}
}
void MenuBarComponent::mouseDrag (const MouseEvent& e)
{
const MouseEvent e2 (e.getEventRelativeTo (this));
const int item = getItemAt (e2.getPosition());
if (item >= 0)
showMenu (item);
}
void MenuBarComponent::mouseUp (const MouseEvent& e)
{
const MouseEvent e2 (e.getEventRelativeTo (this));
updateItemUnderMouse (e2.getPosition());
if (itemUnderMouse < 0 && getLocalBounds().contains (e2.x, e2.y))
{
setOpenItem (-1);
PopupMenu::dismissAllActiveMenus();
}
}
void MenuBarComponent::mouseMove (const MouseEvent& e)
{
const MouseEvent e2 (e.getEventRelativeTo (this));
if (lastMousePos != e2.getPosition())
{
if (currentPopupIndex >= 0)
{
const int item = getItemAt (e2.getPosition());
if (item >= 0)
showMenu (item);
}
else
{
updateItemUnderMouse (e2.getPosition());
}
lastMousePos = e2.getPosition();
}
}
bool MenuBarComponent::keyPressed (const KeyPress& key)
{
bool used = false;
const int numMenus = menuNames.size();
const int currentIndex = jlimit (0, menuNames.size() - 1, currentPopupIndex);
if (key.isKeyCode (KeyPress::leftKey))
{
showMenu ((currentIndex + numMenus - 1) % numMenus);
used = true;
}
else if (key.isKeyCode (KeyPress::rightKey))
{
showMenu ((currentIndex + 1) % numMenus);
used = true;
}
return used;
}
void MenuBarComponent::menuBarItemsChanged (MenuBarModel* /*menuBarModel*/)
{
StringArray newNames;
if (model != nullptr)
newNames = model->getMenuBarNames();
if (newNames != menuNames)
{
menuNames = newNames;
repaint();
resized();
}
}
void MenuBarComponent::menuCommandInvoked (MenuBarModel* /*menuBarModel*/,
const ApplicationCommandTarget::InvocationInfo& info)
{
if (model == nullptr || (info.commandFlags & ApplicationCommandInfo::dontTriggerVisualFeedback) != 0)
return;
for (int i = 0; i < menuNames.size(); ++i)
{
const PopupMenu menu (model->getMenuForIndex (i, menuNames [i]));
if (menu.containsCommandItem (info.commandID))
{
setItemUnderMouse (i);
startTimer (200);
break;
}
}
}
void MenuBarComponent::timerCallback()
{
stopTimer();
updateItemUnderMouse (getMouseXYRelative());
}
END_JUCE_NAMESPACE
| [
"[email protected]"
]
| [
[
[
1,
350
]
]
]
|
7045d222a59b35b61323936a2ee58d36e695f96a | 5095bbe94f3af8dc3b14a331519cfee887f4c07e | /Shared/Components/Data/TFrequency_analysis.cpp | 86d7310f155ea98df7f4a8b10442e470271b89dd | []
| no_license | sativa/apsim_development | efc2b584459b43c89e841abf93830db8d523b07a | a90ffef3b4ed8a7d0cce1c169c65364be6e93797 | refs/heads/master | 2020-12-24T06:53:59.364336 | 2008-09-17T05:31:07 | 2008-09-17T05:31:07 | 64,154,433 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,319 | cpp | //---------------------------------------------------------------------------
#include <general\pch.h>
#include <vcl.h>
#pragma hdrstop
#include "TFrequency_analysis.h"
#include <general\math_functions.h>
#include <general\vcl_functions.h>
#include <ApsimShared\ApsimSettings.h>
#include "TFrequency_form.h"
#include <numeric>
#include <math.h>
#pragma link "TAPSTable"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//
static inline void ValidCtrCheck(TFrequency_analysis *)
{
new TFrequency_analysis(NULL);
}
//---------------------------------------------------------------------------
namespace Tfrequency_analysis
{
void __fastcall PACKAGE Register()
{
TComponentClass classes[1] = {__classid(TFrequency_analysis)};
RegisterComponents("APSRU", classes, 0);
}
}
// ------------------------------------------------------------------
// Short description:
// constructor
// Notes:
//
// Changes:
// DPH 15/7/98
// ------------------------------------------------------------------
__fastcall TFrequency_analysis::TFrequency_analysis(TComponent* Owner)
: TAnalysis(Owner)
{
FCreate_categories = true;
}
// ------------------------------------------------------------------
// Load settings.
// ------------------------------------------------------------------
void TFrequency_analysis::load()
{
TAnalysis::load();
ApsimSettings settings;
try
{
int numCategories;
settings.read(CHART_SETTINGS_KEY + "|NumFrequencyCategories", numCategories);
Num_categories = numCategories;
settings.read(CHART_SETTINGS_KEY + "|FrequencyAnalysis", FFrequency_analysis);
}
catch (const exception& err)
{
FNum_categories = 6;
FCategory_start_value[0] = 0;
FCategory_end_value[0] = 200;
FCategory_start_value[1] = 200;
FCategory_end_value[1] = 400;
FCategory_start_value[2] = 400;
FCategory_end_value[2] = 600;
FCategory_start_value[3] = 600;
FCategory_end_value[3] = 800;
FFrequency_analysis = true;
}
}
// ------------------------------------------------------------------
// Save settings.
// ------------------------------------------------------------------
void TFrequency_analysis::save()
{
TAnalysis::save();
ApsimSettings settings;
settings.write(CHART_SETTINGS_KEY + "|NumFrequencyCategories", Num_categories);
settings.write(CHART_SETTINGS_KEY + "|FrequencyAnalysis", FFrequency_analysis);
}
// ------------------------------------------------------------------
// Short description:
// get a specific starting value for a category.
// Notes:
// Changes:
// DPH 15/7/98
// ------------------------------------------------------------------
double __fastcall TFrequency_analysis::Get_start_value (int index)
{
if (index >= 0 && index < MAX_CATEGORIES)
return FCategory_start_value[index];
else
return 0;
}
// ------------------------------------------------------------------
// Short description:
// set a specific starting value for a category.
// Notes:
// Changes:
// DPH 15/7/98
// ------------------------------------------------------------------
void __fastcall TFrequency_analysis::Set_start_value (int index, double value)
{
FCreate_categories = false;
if (index >= 0 && index < MAX_CATEGORIES)
FCategory_start_value[index] = value;
}
// ------------------------------------------------------------------
// Short description:
// get a specific ending value for a category.
// Notes:
// Changes:
// DPH 15/7/98
// ------------------------------------------------------------------
double __fastcall TFrequency_analysis::Get_end_value (int index)
{
if (index >= 0 && index < MAX_CATEGORIES)
return FCategory_end_value[index];
else
return 0;
}
// ------------------------------------------------------------------
// Short description:
// set a specific ending value for a category.
// Notes:
// Changes:
// DPH 15/7/98
// ------------------------------------------------------------------
void __fastcall TFrequency_analysis::Set_end_value (int index, double value)
{
FCreate_categories = false;
if (index >= 0 && index < MAX_CATEGORIES)
FCategory_end_value[index] = value;
}
// ------------------------------------------------------------------
// Short description:
// set the number of categories to use. This will be used
// instead of the category values above.
// Notes:
// Changes:
// DPH 15/7/98
// ------------------------------------------------------------------
void __fastcall TFrequency_analysis::Set_num_categories (int num_categories)
{
FNum_categories = num_categories;
FCreate_categories = true;
}
// ------------------------------------------------------------------
// Short description:
// calculate and store all records in memory table.
// Notes:
// Changes:
// DPH 15/7/98
// DAH 7/2/02: fix for D-408
// ------------------------------------------------------------------
void TFrequency_analysis::calcAndStoreRecords()
{
if (Field_names_to_analyse->Items->Count == 1)
{
beginStoringData();
// create a list of field names to keep.
string fieldName = Field_names_to_analyse->Items->Strings[0].c_str();
// if we need to create categories then we'd better do it now.
if (FCreate_categories)
createCategories();
first();
// loop through all data blocks
bool ok = sourceDataset->first();
while (ok)
{
vector<double> values;
sourceDataset->fieldAsNumericArray(fieldName, values);
// calculate a frequency distribution.
vector<string> frequencyLabels;
vector<double> frequencyNumbers;
calculateFreqDist(values, frequencyLabels, frequencyNumbers);
storeStringArray(fieldName, frequencyLabels);
if (Frequency_analysis)
storeNumericArray(FREQUENCY_FIELD_NAME, frequencyNumbers);
else
storeNumericArray(PROBABILITY_FIELD_NAME, frequencyNumbers);
copyPivotsFrom(*sourceDataset);
next();
ok = sourceDataset->next();
}
endStoringData();
}
}
// ------------------------------------------------------------------
// Short description:
// calculate the frequency distribution
// Notes:
// Changes:
// DPH 15/7/98
// ------------------------------------------------------------------
void TFrequency_analysis::calculateFreqDist(vector<double>& Values,
vector<string>& Frequency_labels,
vector<double>& Frequency_numbers)
{
vector<double> Start_values, End_values;
int category = 0;
while (category < MAX_CATEGORIES && FCategory_end_value[category] > 0)
{
Start_values.push_back (FCategory_start_value[category]);
End_values.push_back (FCategory_end_value[category]);
category++;
}
::Calculate_freq_dist (Values,
Start_values, End_values,
Frequency_labels,
Frequency_numbers,
0);
if (!FFrequency_analysis)
{
// convert each frequency to a percentage from 0 to 1.
double Total = std::accumulate(Frequency_numbers.begin(), Frequency_numbers.end(), 0.0);
if (Total > 0.0)
{
for (unsigned int i = 0; i < Frequency_numbers.size(); i++)
Frequency_numbers[i] = Frequency_numbers[i] / Total;
}
}
}
// ------------------------------------------------------------------
// Short description:
// create the categories based on the values passed in.
// Notes:
// Changes:
// DPH 5/2/98
// DAH 31/1/02: D-497: the call to fieldAsNumericArray was erasing the vector 'values'
// on every pass through the while loop and hence not calculating
// max and min vals correctly
// ------------------------------------------------------------------
void TFrequency_analysis::createCategories (void)
{
string fieldName = Field_names_to_analyse->Items->Strings[0].c_str();
vector<double> values, all_values;
// get all data.
bool ok = sourceDataset->first();
while (ok)
{
sourceDataset->fieldAsNumericArray(fieldName, values);
all_values.insert(all_values.end(), values.begin(), values.end());
ok = sourceDataset->next();
}
double minimum = *std::min_element(all_values.begin(), all_values.end());
double maximum = *std::max_element(all_values.begin(), all_values.end());
double category_size = (maximum - minimum) / FNum_categories;
int Magnitude = 0;
if (category_size > 0)
Magnitude = log10(category_size);
int Nearest = pow(10, Magnitude);
Round_to_nearest (minimum, Nearest, false);
Round_to_nearest (maximum, Nearest, true);
category_size = (maximum - minimum) / FNum_categories;
int index;
double start_category = minimum;
for (index = 0; index < FNum_categories; index++)
{
FCategory_start_value[index] = start_category;
FCategory_end_value[index] = start_category + category_size;
start_category += category_size;
}
FCategory_start_value[index] = 0;
FCategory_end_value[index] = 0;
}
// ------------------------------------------------------------------
// Short description:
// create and return a pointer to an analysis form.
// Notes:
// Changes:
// DPH 5/2/98
// ------------------------------------------------------------------
TAPSTable_form* TFrequency_analysis::createPropertiesForm()
{
return new TFrequency_form(Application);
}
| [
"devoilp@8bb03f63-af10-0410-889a-a89e84ef1bc8"
]
| [
[
[
1,
341
]
]
]
|
15aa6acc633767fd5835ace8e1812ae05f7c4a6f | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SERenderers/SE_DX9_Renderer/SEDX9Rendering/SEDX9DrawBuffer.cpp | 69e79b13e3115aab8ab6b7a47494472c3cd1c52f | []
| no_license | pizibing/swingengine | d8d9208c00ec2944817e1aab51287a3c38103bea | e7109d7b3e28c4421c173712eaf872771550669e | refs/heads/master | 2021-01-16T18:29:10.689858 | 2011-06-23T04:27:46 | 2011-06-23T04:27:46 | 33,969,301 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,837 | cpp | // Swing Engine Version 1 Source Code
// Most of techniques in the engine are mainly based on David Eberly's
// Wild Magic 4 open-source code.The author of Swing Engine learned a lot
// from Eberly's experience of architecture and algorithm.
// Several sub-systems are totally new,and others are re-implimented or
// re-organized based on Wild Magic 4's sub-systems.
// Copyright (c) 2007-2010. All Rights Reserved
//
// Eberly's permission:
// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or (at
// your option) any later version. The license is available for reading at
// the location:
// http://www.gnu.org/copyleft/lgpl.html
#include "SEDX9RendererPCH.h"
#include "SEDX9Renderer.h"
using namespace Swing;
//----------------------------------------------------------------------------
void SEDX9Renderer::Draw(const unsigned char* aucBuffer)
{
if( !aucBuffer )
{
return;
}
IDirect3DSurface9* pBackBuffer = 0;
ms_hResult = m_pDXDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO,
&pBackBuffer);
SE_ASSERT( pBackBuffer );
SE_ASSERT( SUCCEEDED(ms_hResult) );
if( FAILED(ms_hResult) || !pBackBuffer )
{
return;
}
RECT SrcRect = { 0, 0, m_iWidth-1, m_iHeight-1 };
ms_hResult = D3DXLoadSurfaceFromMemory(pBackBuffer, 0, 0, aucBuffer,
D3DFMT_R8G8B8, 3*m_iWidth, 0, &SrcRect, D3DX_FILTER_NONE, 0);
SE_ASSERT( SUCCEEDED(ms_hResult) );
}
//----------------------------------------------------------------------------
| [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
]
| [
[
[
1,
50
]
]
]
|
808b192550999cc70df6644b2a1925b8ccf38b30 | 36bf908bb8423598bda91bd63c4bcbc02db67a9d | /Library/CBase64.cpp | 1dd15425cf6042a4dc5b266f8a4f2efc429dddd8 | []
| no_license | code4bones/crawlpaper | edbae18a8b099814a1eed5453607a2d66142b496 | f218be1947a9791b2438b438362bc66c0a505f99 | refs/heads/master | 2021-01-10T13:11:23.176481 | 2011-04-14T11:04:17 | 2011-04-14T11:04:17 | 44,686,513 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,588 | cpp | /*
CBase64.cpp
Classe per la codifica/decodifica in base64 .
Luca Piergentili, 14/09/96
[email protected]
I due metodi per la codifica/decodifica del buffer sono stati ripresi dal
codice di "Pavuk" di Stefan Ondrejicka (http://www.idata.sk/~ondrej/pavuk/).
*/
#include "env.h"
#include "pragma.h"
#include "macro.h"
#ifdef _WINDOWS
#include "window.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "CBase64.h"
#include "traceexpr.h"
//#define _TRACE_FLAG _TRFLAG_TRACEOUTPUT
//#define _TRACE_FLAG _TRFLAG_NOTRACE
#define _TRACE_FLAG _TRFLAG_NOTRACE
#define _TRACE_FLAG_INFO _TRFLAG_NOTRACE
#define _TRACE_FLAG_WARN _TRFLAG_NOTRACE
#define _TRACE_FLAG_ERR _TRFLAG_NOTRACE
#if (defined(_DEBUG) && defined(_WINDOWS)) && (defined(_AFX) || defined(_AFXDLL))
#ifdef PRAGMA_MESSAGE_VERBOSE
#pragma message("\t\t\t"__FILE__"("STR(__LINE__)"): using DEBUG_NEW macro")
#endif
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static const char base64table[] = {
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
};
/*
Encode()
*/
char* CBase64::Encode(const char* data)
{
int len = strlen(data);
unsigned char* outstr = (unsigned char*)new char[((len/3 + 1) * 4 + 1)];
unsigned char* instr = (unsigned char*)new char[(len+3)];
int idx = 0,outidx = 0;
memset(instr,'\0',len+3);
memcpy(instr,data,len);
memset(outstr,'\0',(len/3 + 1) * 4 + 1);
while(idx < len)
{
if((idx % 3)==0)
{
outstr[outidx] = base64table[(int)(instr[idx] >> 2)];
outidx ++;
}
else if((idx % 3)==1)
{
outstr[outidx] = base64table[(int)(((instr[idx - 1] << 4) & 0x30) | ((instr[idx] >> 4) & 0x0f))];
outidx ++;
outstr[outidx] = base64table[(int)(((instr[idx] << 2) & 0x3c) | ((instr[idx + 1] >> 6) & 0x03))];
outidx ++;
}
else
{
outstr[outidx] = base64table[(int)(instr[idx] & 0x3f)];
outidx ++;
}
idx ++;
}
if((idx % 3)==1)
{
outstr[outidx] = base64table[(int)(((instr[idx - 1] << 4) & 0x30) | ((instr[idx] >> 4) & 0x0f))];
outstr[outidx+1] = '=';
outstr[outidx+2] = '=';
}
else if((idx % 3)==2)
{
outstr[outidx] = '=';
}
delete [] instr;
return((char*)outstr);
}
/*
Decode()
*/
int CBase64::Decode(const char* inbuf,char** outbuf)
{
unsigned char* p = (unsigned char*)inbuf;
char* rv = new char[(((strlen(inbuf) + 1) * 3) / 4 + 1)];
int len = 0;
int stop = 0, err = 0;
while(*p)
{
int n = 0;
int c[4] = {0,0,0,0};
int nt[5] = {0,1,1,2,3};
unsigned char triple[3] = {'\0','\0','\0'};
for(n = 0; n < 4; n++)
{
if(!*(p+n) || *(p+n)=='=')
{
stop = 1;
break;
}
else
c[n] = ChrIndex(base64table,*(p+n));
if(c[n] < 0)
{
err = 1;
stop = 1;
break;
}
}
triple[0] = (c[0] << 2) | (c[1] >> 4);
triple[1] = (c[1] & 0x3f) << 4 | ((c[2] & 0x3c) >> 2);
triple[2] = (c[2] & 0x3) << 6 | (c[3] & 0x3f);
memcpy(rv + len,triple,nt[n]);
if(stop)
{
len += nt[n];
break;
}
else
len += 3;
p += 4;
}
if(err)
{
delete [] rv;
len = -1;
}
else
{
rv[len] = '\0';
*outbuf = rv;
}
return(len);
}
/*
Encode()
Codifica in BASE64 il file di input nel file di output.
0 per conversione effettuata
-1 se non puo' aprire il file di input
-2 se non puo' aprire il file di output
*/
int CBase64::Encode(const char *pPlainFile,const char *pEncodedFile)
{
char szBuffer[128];
FILE* pInputFile;
FILE* pOutputFile;
unsigned char cChr = 0;
unsigned long nShifted = 0L;
unsigned long lValue = 0L;
int nIndex = 0;
int nShift = 0;
int nSaveShift = 0;
int bDone = 0;
if((pInputFile = fopen(pPlainFile,"rb"))==(FILE*)NULL)
return(-1);
if((pOutputFile = fopen(pEncodedFile,"w"))==(FILE*)NULL)
{
fclose(pInputFile);
return(-2);
}
do
{
bDone = 0;
nShift = 0;
nShifted = 0L;
nIndex = 0;
while(!feof(pInputFile) || nShift!=0)
{
if(!feof(pInputFile) && !bDone)
{
cChr = (char)fgetc(pInputFile);
if(feof(pInputFile))
{
bDone = 1;
nSaveShift = nShift;
cChr = 0;
}
}
else
{
bDone = 1;
nSaveShift = nShift;
cChr = 0;
}
if(!bDone || nShift!=0)
{
lValue = (unsigned long)cChr;
nShifted <<= 8;
nShift += 8;
nShifted |= lValue;
}
while(nShift >= 6)
{
nShift -= 6;
lValue = (nShifted >> nShift) & 0x3fL;
cChr = (unsigned char)base64table[(int)lValue];
szBuffer[nIndex++] = cChr;
if(nIndex >= 60)
{
szBuffer[nIndex] = '\0';
fprintf(pOutputFile,"%s\n",szBuffer);
nIndex = 0;
}
if(bDone)
nShift = 0;
}
}
if(nSaveShift==2)
{
szBuffer[nIndex++] = '=';
if(nIndex >= 60)
{
szBuffer[nIndex] = '\0';
fprintf(pOutputFile,"%s\n",szBuffer);
nIndex = 0;
}
szBuffer[nIndex++] = '=';
if(nIndex >= 60)
{
szBuffer[nIndex] = '\0';
fprintf(pOutputFile,"%s\n",szBuffer);
nIndex = 0;
}
}
else if(nSaveShift==4)
{
szBuffer[nIndex++] = '=';
if(nIndex >= 60)
{
szBuffer[nIndex] = '\0';
fprintf(pOutputFile,"%s\n",szBuffer);
nIndex = 0;
}
}
if(nIndex!=0)
{
szBuffer[nIndex] = '\0';
fprintf(pOutputFile,"%s\n",szBuffer);
}
}
while(!feof(pInputFile));
fclose(pInputFile);
fclose(pOutputFile);
return(0);
}
/*
Decode()
Decodifica il file di input nel file di output.
0 per conversione effettuata
-1 se non puo' aprire il file di input
-2 se non puo' aprire il file di output
*/
int CBase64::Decode(const char *pEncodedFile,const char *pPlainFile)
{
char szBuffer[128];
FILE* pInputFile;
FILE* pOutputFile;
unsigned char cChr = 0;
unsigned long nShifted = 0L;
unsigned long lValue = 0L;
int nIndex = 0;
int nShift = 0;
int bDone = 0;
if((pInputFile = fopen(pEncodedFile,"r"))==(FILE*)NULL)
return(-1);
if((pOutputFile = fopen(pPlainFile,"wb"))==(FILE*)NULL)
{
fclose(pInputFile);
return(-2);
}
do
{
bDone = 0;
nShift = 0;
nShifted = 0L;
while(!feof(pInputFile) && !bDone)
{
if(fgets(szBuffer,sizeof(szBuffer),pInputFile))
{
for(nIndex = 0; szBuffer[nIndex] && szBuffer[nIndex]!='\n'; nIndex++)
{
lValue = ConvertToAscii(szBuffer[nIndex]);
if(lValue < 64)
{
nShifted <<= 6;
nShift += 6;
nShifted |= lValue;
if(nShift >= 8)
{
nShift -= 8;
lValue = nShifted >> nShift;
cChr = (unsigned char)(lValue & 0xffL);
fputc(cChr,pOutputFile);
}
}
else
{
bDone = 1;
break;
}
}
}
}
}
while(!feof(pInputFile));
fclose(pInputFile);
fclose(pOutputFile);
return(0);
}
/*
ConvertToAscii()
*/
int CBase64::ConvertToAscii(unsigned char c)
{
if((c >= 'A') && (c <= 'Z'))
return((int)(c - 'A'));
else if((c >= 'a') && (c <= 'z'))
return(26 + (int)(c - 'a'));
else if((c >= '0') && (c <= '9'))
return(52 + (int)(c - '0'));
else if(c=='+')
return(62);
else if(c=='/')
return(63);
else if(c=='=')
return(-2);
else
return(-1);
}
/*
ChrIndex()
*/
int CBase64::ChrIndex(const char* pString,int c)
{
char* p = (char*)strchr(pString,c);
if(!p)
return(-1);
else
return(p - pString);
}
| [
"[email protected]"
]
| [
[
[
1,
397
]
]
]
|
c9a5be24c2d21d836e440189433ec53eee00e84b | d115cf7a1b374d857f6b094d4b4ccd8e9b1ac189 | /gccxml_bin/v09/win32/share/gccxml-0.9/Vc8/Include/crtdefs.h | f76214e2bc5404045f1922b8004edb600c63bf08 | []
| no_license | gatoatigrado/pyplusplusclone | 30af9065fb6ac3dcce527c79ed5151aade6a742f | a64dc9aeeb718b2f30bd6a5ff8dcd8bfb1cd2ede | refs/heads/master | 2016-09-05T23:32:08.595261 | 2010-05-16T10:53:45 | 2010-05-16T10:53:45 | 700,369 | 4 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 93,559 | h | /***
*crtdefs.h - definitions/declarations common to all CRT
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
* This file has mostly defines used by the entire CRT.
*
* [Public]
*
****/
/* Lack of pragma once is deliberate */
/* Define _CRTIMP */
#ifndef _CRTIMP
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _CRTIMP
#endif /* _DLL */
#endif /* _CRTIMP */
#ifndef _INC_CRTDEFS
#define _INC_CRTDEFS
#if defined(__midl)
/* MIDL does not want to see this stuff */
#undef _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
#undef _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT
#undef _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 0
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT 0
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 0
#endif
#if !defined(_WIN32)
#error ERROR: Only Win32 target supported!
#endif
/* Note on use of "deprecate":
* Various places in this header and other headers use __declspec(deprecate) or macros that have the term DEPRECATE in them.
* We use deprecate here ONLY to signal the compiler to emit a warning about these items. The use of deprecate
* should NOT be taken to imply that any standard committee has deprecated these functions from the relevant standards.
* In fact, these functions are NOT deprecated from the standard.
*
* Full details can be found in our documentation by searching for "Security Enhancements in the CRT".
*/
#ifdef _CRT_NOFORCE_MANIFEST
#ifdef _CRT_FORCE_MANIFEST
#pragma message ("_CRT_FORCE_MANIFEST and _CRT_NOFORCE_MANIFEST defined. Define just one")
#pragma message ("_CRT_FORCE_MANIFEST ignored")
#endif
#else
#if !defined(_CRT_FORCE_MANIFEST) && defined(_VC_NODEFAULTLIB)
#define _CRT_NOFORCE_MANIFEST
#endif
#endif
#include <sal.h>
#ifdef _DLL
#if defined _USE_RTM_VERSION
#if defined(_M_IX86)
#pragma comment(linker, "/include:__forceCRTManifestRTM")
#else
#pragma comment(linker, "/include:_forceCRTManifestRTM")
#endif
#endif
#if !defined(_CRT_NOFORCE_MANIFEST)
#ifdef _DEBUG
#ifdef _CRT_MANIFEST_RETAIL
#define _CRT_MANIFEST_INCONSISTENT
#else
#define _CRT_MANIFEST_DEBUG
#endif
#else
#ifdef _CRT_MANIFEST_DEBUG
#define _CRT_MANIFEST_INCONSISTENT
#else
#define _CRT_MANIFEST_RETAIL
#endif
#endif
#ifdef _CRT_MANIFEST_INCONSISTENT
#error You have included some C++/C library header files with _DEBUG defined and some with _DEBUG not defined. This will not work correctly. Please have _DEBUG set or clear consistently.
#endif
#include <crtassem.h>
#ifdef _M_IX86
#ifdef _DEBUG
#pragma comment(linker,"/manifestdependency:\"type='win32' " \
"name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".DebugCRT' " \
"version='" _CRT_ASSEMBLY_VERSION "' " \
"processorArchitecture='x86' " \
"publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' " \
"name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".CRT' " \
"version='" _CRT_ASSEMBLY_VERSION "' " \
"processorArchitecture='x86' " \
"publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
#endif
#endif /* _M_IX86 */
#ifdef _M_AMD64
#ifdef _DEBUG
#pragma comment(linker,"/manifestdependency:\"type='win32' " \
"name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".DebugCRT' " \
"version='" _CRT_ASSEMBLY_VERSION "' " \
"processorArchitecture='amd64' " \
"publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' " \
"name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".CRT' " \
"version='" _CRT_ASSEMBLY_VERSION "' " \
"processorArchitecture='amd64' " \
"publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
#endif
#endif /* _M_AMD64 */
#ifdef _M_IA64
#ifdef _DEBUG
#pragma comment(linker,"/manifestdependency:\"type='win32' " \
"name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".DebugCRT' " \
"version='" _CRT_ASSEMBLY_VERSION "' " \
"processorArchitecture='ia64' " \
"publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' " \
"name='" __LIBRARIES_ASSEMBLY_NAME_PREFIX ".CRT' " \
"version='" _CRT_ASSEMBLY_VERSION "' " \
"processorArchitecture='ia64' " \
"publicKeyToken='" _VC_ASSEMBLY_PUBLICKEYTOKEN "'\"")
#endif
#endif /* _M_IA64 */
#endif /* !defined(_CRT_NOFORCE_MANIFEST) */
#endif /* _DLL */
#ifdef _MSC_VER
#undef _CRT_PACKING
#define _CRT_PACKING 8
#pragma pack(push,_CRT_PACKING)
#endif /* _MSC_VER */
#include <vadefs.h>
#ifdef __cplusplus
extern "C" {
#endif
/* preprocessor string helpers */
#ifndef _CRT_STRINGIZE
#define __CRT_STRINGIZE(_Value) #_Value
#define _CRT_STRINGIZE(_Value) __CRT_STRINGIZE(_Value)
#endif
#ifndef _CRT_WIDE
#define __CRT_WIDE(_String) L ## _String
#define _CRT_WIDE(_String) __CRT_WIDE(_String)
#endif
#if !defined(_W64)
#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
#define _W64 __w64
#else
#define _W64
#endif
#endif
/* Define _CRTIMP_NOIA64 */
#ifndef _CRTIMP_NOIA64
#if defined(_M_IA64)
#define _CRTIMP_NOIA64
#else
#define _CRTIMP_NOIA64 _CRTIMP
#endif
#endif
/* Define _CRTIMP2 */
#ifndef _CRTIMP2
#if defined(_DLL) && !defined(_STATIC_CPPLIB)
#define _CRTIMP2 __declspec(dllimport)
#else /* ndef _DLL && !STATIC_CPPLIB */
#define _CRTIMP2
#endif /* _DLL && !STATIC_CPPLIB */
#endif /* _CRTIMP2 */
/* Define _CRTIMP_ALTERNATIVE */
#ifndef _CRTIMP_ALTERNATIVE
#ifdef _DLL
#ifdef _CRT_ALTERNATIVE_INLINES
#define _CRTIMP_ALTERNATIVE
#else
#define _CRTIMP_ALTERNATIVE _CRTIMP
#define _CRT_ALTERNATIVE_IMPORTED
#endif
#else /* ndef _DLL */
#define _CRTIMP_ALTERNATIVE
#endif /* _DLL */
#endif /* _CRTIMP_ALTERNATIVE */
/* Define _MRTIMP */
#ifndef _MRTIMP
#define _MRTIMP __declspec(dllimport)
#endif /* _MRTIMP */
/* Define _MRTIMP2 */
#ifndef _MRTIMP2
#if defined(_DLL) && !defined(_STATIC_CPPLIB)
#define _MRTIMP2 __declspec(dllimport)
#else /* ndef _DLL && !STATIC_CPPLIB */
#define _MRTIMP2
#endif /* _DLL && !STATIC_CPPLIB */
#endif /* _MRTIMP2 */
#ifndef _MCRTIMP
#ifdef _DLL
#define _MCRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _MCRTIMP
#endif /* _DLL */
#endif /* _CRTIMP */
#ifndef __CLR_OR_THIS_CALL
#if defined(MRTDLL) || defined(_M_CEE_PURE)
#define __CLR_OR_THIS_CALL __clrcall
#else
#define __CLR_OR_THIS_CALL
#endif
#endif
#ifndef __CLRCALL_OR_CDECL
#if defined(MRTDLL) || defined(_M_CEE_PURE)
#define __CLRCALL_OR_CDECL __clrcall
#else
#define __CLRCALL_OR_CDECL __cdecl
#endif
#endif
#ifndef _CRTIMP_PURE
#if defined(_M_CEE_PURE) || defined(_STATIC_CPPLIB)
#define _CRTIMP_PURE
#else
#define _CRTIMP_PURE _CRTIMP
#endif
#endif
#ifndef _PGLOBAL
#ifdef _M_CEE
#if defined(__cplusplus_cli)
#define _PGLOBAL __declspec(process)
#else
#define _PGLOBAL
#endif
#else
#define _PGLOBAL
#endif
#endif
#ifndef _AGLOBAL
#ifdef _M_CEE
#define _AGLOBAL __declspec(appdomain)
#else
#define _AGLOBAL
#endif
#endif
/* define a specific constant for mixed mode */
#ifdef _M_CEE
#ifndef _M_CEE_PURE
#define _M_CEE_MIXED
#endif
#endif
/* Define __STDC_SECURE_LIB__ */
#define __STDC_SECURE_LIB__ 200411L
/* Retain__GOT_SECURE_LIB__ for back-compat */
#define __GOT_SECURE_LIB__ __STDC_SECURE_LIB__
/* Default value for __STDC_WANT_SECURE_LIB__ is 1 */
#ifndef __STDC_WANT_SECURE_LIB__
#define __STDC_WANT_SECURE_LIB__ 1
#endif
/* Turn off warnings if __STDC_WANT_SECURE_LIB__ is 0 */
#if !__STDC_WANT_SECURE_LIB__ && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif
/* See note on use of deprecate at the top of this file */
#if _MSC_FULL_VER >= 140050320
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text))
#else
#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated)
#endif
/* Define _CRT_INSECURE_DEPRECATE */
/* See note on use of deprecate at the top of this file */
#if defined(_CRT_SECURE_NO_DEPRECATE) && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif
#ifndef _CRT_INSECURE_DEPRECATE
#ifdef _CRT_SECURE_NO_WARNINGS
#define _CRT_INSECURE_DEPRECATE(_Replacement)
#else
#define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT("This function or variable may be unsafe. Consider using " #_Replacement " instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.")
#endif
#endif
/* Define _CRT_INSECURE_DEPRECATE_MEMORY */
/* See note on use of deprecate at the top of this file */
#if defined(_CRT_SECURE_DEPRECATE_MEMORY) && !defined(_CRT_SECURE_WARNINGS_MEMORY)
#define _CRT_SECURE_WARNINGS_MEMORY
#endif
#ifndef _CRT_INSECURE_DEPRECATE_MEMORY
#if !defined(_CRT_SECURE_WARNINGS_MEMORY)
#define _CRT_INSECURE_DEPRECATE_MEMORY(_Replacement)
#else
#define _CRT_INSECURE_DEPRECATE_MEMORY(_Replacement) _CRT_INSECURE_DEPRECATE(_Replacement)
#endif
#endif
/* Define _CRT_INSECURE_DEPRECATE_GLOBALS */
/* See note on use of deprecate at the top of this file */
#if !defined (RC_INVOKED)
#if defined(_CRT_SECURE_NO_DEPRECATE_GLOBALS) && !defined(_CRT_SECURE_NO_WARNINGS_GLOBALS)
#define _CRT_SECURE_NO_WARNINGS_GLOBALS
#endif
#endif
#ifndef _CRT_INSECURE_DEPRECATE_GLOBALS
#if defined (RC_INVOKED)
#define _CRT_INSECURE_DEPRECATE_GLOBALS(_Replacement)
#else
#if defined(_CRT_SECURE_NO_WARNINGS_GLOBALS)
#define _CRT_INSECURE_DEPRECATE_GLOBALS(_Replacement)
#else
#define _CRT_INSECURE_DEPRECATE_GLOBALS(_Replacement) _CRT_INSECURE_DEPRECATE(_Replacement)
#endif
#endif
#endif
/* Define _CRT_MANAGED_HEAP_DEPRECATE */
/* See note on use of deprecate at the top of this file */
#if defined(_CRT_MANAGED_HEAP_NO_DEPRECATE) && !defined(_CRT_MANAGED_HEAP_NO_WARNINGS)
#define _CRT_MANAGED_HEAP_NO_WARNINGS
#endif
#ifndef _CRT_MANAGED_HEAP_DEPRECATE
#ifdef _CRT_MANAGED_HEAP_NO_WARNINGS
#define _CRT_MANAGED_HEAP_DEPRECATE
#else
#if defined(_M_CEE)
#define _CRT_MANAGED_HEAP_DEPRECATE
/* Disabled to allow QA tests to get fixed
_CRT_DEPRECATE_TEXT("Direct heap access is not safely possible from managed code.")
*/
#else
#define _CRT_MANAGED_HEAP_DEPRECATE
#endif
#endif
#endif
/* _SECURECRT_FILL_BUFFER_PATTERN is the same as _bNoMansLandFill */
#define _SECURECRT_FILL_BUFFER_PATTERN 0xFD
/* obsolete stuff */
/* Define _CRT_OBSOLETE */
/* See note on use of deprecate at the top of this file */
#if defined(_CRT_OBSOLETE_NO_DEPRECATE) && !defined(_CRT_OBSOLETE_NO_WARNINGS)
#define _CRT_OBSOLETE_NO_WARNINGS
#endif
#ifndef _CRT_OBSOLETE
#ifdef _CRT_OBSOLETE_NO_WARNINGS
#define _CRT_OBSOLETE(_NewItem)
#else
#define _CRT_OBSOLETE(_NewItem) _CRT_DEPRECATE_TEXT("This function or variable has been superceded by newer library or operating system functionality. Consider using " #_NewItem " instead. See online help for details.")
#endif
#endif
/* jit64 instrinsic stuff */
#ifndef _CRT_JIT_INTRINSIC
#if defined(_M_CEE) && (defined(_M_AMD64) || defined(_M_IA64))
/* This is only needed when managed code is calling the native APIs, targeting the 64-bit runtime */
#define _CRT_JIT_INTRINSIC __declspec(jitintrinsic)
#else
#define _CRT_JIT_INTRINSIC
#endif
#endif
/* Define overload switches */
#if !defined (RC_INVOKED)
#if !defined(_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES)
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 0
#else
#if !__STDC_WANT_SECURE_LIB__ && _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
#error Cannot use Secure CRT C++ overloads when __STDC_WANT_SECURE_LIB__ is 0
#endif
#endif
#endif
#if !defined (RC_INVOKED)
#if !defined(_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT)
/* _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT is ignored if _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES is set to 0 */
#define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT 0
#else
#if !__STDC_WANT_SECURE_LIB__ && _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT
#error Cannot use Secure CRT C++ overloads when __STDC_WANT_SECURE_LIB__ is 0
#endif
#endif
#endif
#if !defined (RC_INVOKED)
#if !defined(_CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES)
#if __STDC_WANT_SECURE_LIB__
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1
#else
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 0
#endif
#else
#if !__STDC_WANT_SECURE_LIB__ && _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES
#error Cannot use Secure CRT C++ overloads when __STDC_WANT_SECURE_LIB__ is 0
#endif
#endif
#endif
/* Define _CRT_NONSTDC_DEPRECATE */
/* See note on use of deprecate at the top of this file */
#if defined(_CRT_NONSTDC_NO_DEPRECATE) && !defined(_CRT_NONSTDC_NO_WARNINGS)
#define _CRT_NONSTDC_NO_WARNINGS
#endif
#if !defined(_CRT_NONSTDC_DEPRECATE)
#if defined(_CRT_NONSTDC_NO_WARNINGS) || defined(_POSIX_)
#define _CRT_NONSTDC_DEPRECATE(_NewName)
#else
#define _CRT_NONSTDC_DEPRECATE(_NewName) _CRT_DEPRECATE_TEXT("The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: " #_NewName ". See online help for details.")
#endif
#endif
#ifndef _SIZE_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 size_t;
#else
typedef _W64 unsigned int size_t;
#endif
#define _SIZE_T_DEFINED
#endif
#if __STDC_WANT_SECURE_LIB__
#ifndef _RSIZE_T_DEFINED
typedef size_t rsize_t;
#define _RSIZE_T_DEFINED
#endif
#endif
#ifndef _INTPTR_T_DEFINED
#ifdef _WIN64
typedef __int64 intptr_t;
#else
typedef _W64 int intptr_t;
#endif
#define _INTPTR_T_DEFINED
#endif
#ifndef _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef _W64 unsigned int uintptr_t;
#endif
#define _UINTPTR_T_DEFINED
#endif
#ifndef _PTRDIFF_T_DEFINED
#ifdef _WIN64
typedef __int64 ptrdiff_t;
#else
typedef _W64 int ptrdiff_t;
#endif
#define _PTRDIFF_T_DEFINED
#endif
#ifndef _WCHAR_T_DEFINED
typedef unsigned short wchar_t;
#define _WCHAR_T_DEFINED
#endif
#ifndef _WCTYPE_T_DEFINED
typedef unsigned short wint_t;
typedef unsigned short wctype_t;
#define _WCTYPE_T_DEFINED
#endif
#ifndef _VA_LIST_DEFINED
#ifdef _M_CEE_PURE
typedef System::ArgIterator va_list;
#else
typedef char * va_list;
#endif
#define _VA_LIST_DEFINED
#endif
#ifdef _USE_32BIT_TIME_T
#ifdef _WIN64
#error You cannot use 32-bit time_t (_USE_32BIT_TIME_T) with _WIN64
#undef _USE_32BIT_TIME_T
#endif
#else
#if _INTEGRAL_MAX_BITS < 64
#define _USE_32BIT_TIME_T
#endif
#endif
#ifndef _ERRCODE_DEFINED
#define _ERRCODE_DEFINED
/* errcode is deprecated in favor or errno_t, which is part of the standard proposal */
#if !defined(__midl)
_CRT_DEPRECATE_TEXT("This name was supported during some Whidbey pre-releases. Instead, use the standard name errno_t." ) typedef int errcode;
#else
typedef int errcode;
#endif
typedef int errno_t;
#endif
#ifndef _TIME32_T_DEFINED
typedef _W64 long __time32_t; /* 32-bit time value */
#define _TIME32_T_DEFINED
#endif
#ifndef _TIME64_T_DEFINED
#if _INTEGRAL_MAX_BITS >= 64
typedef __int64 __time64_t; /* 64-bit time value */
#endif
#define _TIME64_T_DEFINED
#endif
#ifndef _TIME_T_DEFINED
#ifdef _USE_32BIT_TIME_T
typedef __time32_t time_t; /* time value */
#else
typedef __time64_t time_t; /* time value */
#endif
#define _TIME_T_DEFINED /* avoid multiple def's of time_t */
#endif
#ifndef _CONST_RETURN
#ifdef __cplusplus
#define _CONST_RETURN const
#define _CRT_CONST_CORRECT_OVERLOADS
#else
#define _CONST_RETURN
#endif
#endif
#if !defined(UNALIGNED)
#if defined(_M_IA64) || defined(_M_AMD64)
#define UNALIGNED __unaligned
#else
#define UNALIGNED
#endif
#endif
#if !defined(_CRT_ALIGN)
#if defined(__midl)
#define _CRT_ALIGN(x)
#else
#define _CRT_ALIGN(x) __declspec(align(x))
#endif
#endif
/* Define _CRTNOALIAS, _CRTRESTRICT */
#if _MSC_FULL_VER >= 13102050
#if !defined(_MSC_VER_GREATER_THEN_13102050)
#define _MSC_VER_GREATER_THEN_13102050
#endif
#endif
#if ( defined(_M_IA64) && defined(_MSC_VER_GREATER_THEN_13102050) ) || _MSC_VER >= 1400
#ifndef _CRTNOALIAS
#define _CRTNOALIAS __declspec(noalias)
#endif /* _CRTNOALIAS */
#ifndef _CRTRESTRICT
#define _CRTRESTRICT __declspec(restrict)
#endif /* _CRTRESTRICT */
#else
#ifndef _CRTNOALIAS
#define _CRTNOALIAS
#endif /* _CRTNOALIAS */
#ifndef _CRTRESTRICT
#define _CRTRESTRICT
#endif /* _CRTRESTRICT */
#endif
/* Define __cdecl for non-Microsoft compilers */
#if ( !defined(_MSC_VER) && !defined(__cdecl) )
#define __cdecl
#endif
#if !defined(__CRTDECL)
#if defined(_M_CEE_PURE)
#define __CRTDECL
#else
#define __CRTDECL __cdecl
#endif
#endif
#define _ARGMAX 100
/* _TRUNCATE */
#if !defined(_TRUNCATE)
#define _TRUNCATE ((size_t)-1)
#endif
/* helper macros for cpp overloads */
#if !defined(RC_INVOKED)
#if defined(__cplusplus) && _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(_ReturnType, _FuncName, _DstType, _Dst) \
extern "C++" \
{ \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Sz]) \
{ \
return _FuncName(_Dst, _Sz); \
} \
}
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1) \
extern "C++" \
{ \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Sz], _TType1 _TArg1) \
{ \
return _FuncName(_Dst, _Sz, _TArg1); \
} \
}
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
extern "C++" \
{ \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2) \
{ \
return _FuncName(_Dst, _Sz, _TArg1, _TArg2); \
} \
}
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
extern "C++" \
{ \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
return _FuncName(_Dst, _Sz, _TArg1, _TArg2, _TArg3); \
} \
}
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_4(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4, _TArg4) \
extern "C++" \
{ \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3, _TType4 _TArg4) \
{ \
return _FuncName(_Dst, _Sz, _TArg1, _TArg2, _TArg3, _TArg4); \
} \
}
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(_ReturnType, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1) \
extern "C++" \
{ \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _DstType (&_Dst)[_Sz], _TType1 _TArg1) \
{ \
return _FuncName(_HArg1, _Dst, _Sz, _TArg1); \
} \
}
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_2(_ReturnType, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
extern "C++" \
{ \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _DstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2) \
{ \
return _FuncName(_HArg1, _Dst, _Sz, _TArg1, _TArg2); \
} \
}
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_3(_ReturnType, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
extern "C++" \
{ \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _DstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
return _FuncName(_HArg1, _Dst, _Sz, _TArg1, _TArg2, _TArg3); \
} \
}
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_2_0(_ReturnType, _FuncName, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst) \
extern "C++" \
{ \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _HType2 _HArg2, _DstType (&_Dst)[_Sz]) \
{ \
return _FuncName(_HArg1, _HArg2, _Dst, _Sz); \
} \
}
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1_ARGLIST(_ReturnType, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1) \
extern "C++" \
{ \
__pragma(warning(push)); \
__pragma(warning(disable: 4793)); \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Sz], _TType1 _TArg1, ...) \
{ \
va_list _ArgList; \
_crt_va_start(_ArgList, _TArg1); \
return _VFuncName(_Dst, _Sz, _TArg1, _ArgList); \
} \
__pragma(warning(pop)); \
}
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2_ARGLIST(_ReturnType, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
extern "C++" \
{ \
__pragma(warning(push)); \
__pragma(warning(disable: 4793)); \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2, ...) \
{ \
va_list _ArgList; \
_crt_va_start(_ArgList, _TArg2); \
return _VFuncName(_Dst, _Sz, _TArg1, _TArg2, _ArgList); \
} \
__pragma(warning(pop)); \
}
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(_ReturnType, _FuncName, _DstType, _Src) \
extern "C++" \
{ \
template <size_t _DriveSize, size_t _DirSize, size_t _NameSize, size_t _ExtSize> \
inline \
_ReturnType __CRTDECL _FuncName(__in const _DstType *_Src, __out_ecount_opt(_DriveSize) _DstType (&_Drive)[_DriveSize], __out_ecount_opt(_DirSize) _DstType (&_Dir)[_DirSize], __out_ecount_opt(_NameSize) _DstType (&_Name)[_NameSize], __out_ecount_opt(_ExtSize) _DstType (&_Ext)[_ExtSize]) \
{ \
return _FuncName(_Src, _Drive, _DriveSize, _Dir, _DirSize, _Name, _NameSize, _Ext, _ExtSize); \
} \
}
#else
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(_ReturnType, _FuncName, _DstType, _Dst)
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_3(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_4(_ReturnType, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4, _TArg4)
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_1(_ReturnType, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_2(_ReturnType, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_1_3(_ReturnType, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_2_0(_ReturnType, _FuncName, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst)
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_1_ARGLIST(_ReturnType, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_2_ARGLIST(_ReturnType, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_SPLITPATH(_ReturnType, _FuncName, _DstType, _Src)
#endif /* _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES */
#endif
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _DstType, _Dst) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _DstType, _Dst)
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _DstType, _Dst, _TType1, _TArg1) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _DstType, _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _DstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_3(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_3_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _DstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_4(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4, _TArg4) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_4_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4, _TArg4)
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_2_0(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_2_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst)
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _VFuncName, _VFuncName##_s, _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _VFuncName##_s, _DstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_SIZE(_DeclSpec, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_SIZE_EX(_DeclSpec, _FuncName, _FuncName##_s, _DstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_3_SIZE(_DeclSpec, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_3_SIZE_EX(_DeclSpec, _FuncName, _FuncName##_s, _DstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_0(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _DstType, _Dst) \
__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _DstType, _Dst) \
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_1(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _DstType, _Dst, _TType1, _TArg1) \
__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _DstType, _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _DstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _DstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_4(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4, _TArg4) \
__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_4_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4, _TArg4)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_1_1(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1) \
__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_1_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_2_0(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst) \
__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_2_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_1_ARGLIST(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1) \
__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_1_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _FuncName##_s, _VFuncName, _VFuncName##_s, _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_SIZE(_DeclSpec, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_SIZE_EX(_DeclSpec, _FuncName, _FuncName##_s, _DstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_SIZE(_DeclSpec, _FuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
__DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_SIZE_EX(_DeclSpec, _FuncName, _FuncName##_s, _DstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#if !defined(RC_INVOKED)
#if defined(__cplusplus) && _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
#define __RETURN_POLICY_SAME(_FunctionCall, _Dst) return (_FunctionCall)
#define __RETURN_POLICY_DST(_FunctionCall, _Dst) return ((_FunctionCall) == 0 ? _Dst : 0)
#define __RETURN_POLICY_VOID(_FunctionCall, _Dst) (_FunctionCall); return
#define __EMPTY_DECLSPEC
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _DstType, _Dst) \
__inline \
_ReturnType __CRTDECL __insecure_##_FuncName(_DstType *_Dst) \
{ \
_DeclSpec _ReturnType __cdecl _FuncName(_DstType *); \
return _FuncName(_Dst); \
} \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_T &_Dst) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst)); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(const _T &_Dst) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst)); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_DstType * &_Dst) \
{ \
return __insecure_##_FuncName(_Dst); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Sz]) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, _Sz), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName<1>(_DstType (&_Dst)[1]) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, 1), _Dst); \
} \
}
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0_CGETS(_ReturnType, _DeclSpec, _FuncName, _DstType, _Dst) \
__inline \
_ReturnType __CRTDECL __insecure_##_FuncName(_DstType *_Dst) \
{ \
_DeclSpec _ReturnType __cdecl _FuncName(_DstType *); \
return _FuncName(_Dst); \
} \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) \
_ReturnType __CRTDECL _FuncName(_T &_Dst) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst)); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) \
_ReturnType __CRTDECL _FuncName(const _T &_Dst) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst)); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) \
_ReturnType __CRTDECL _FuncName(_DstType * &_Dst) \
{ \
return __insecure_##_FuncName(_Dst); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Sz]) \
{ \
size_t _SizeRead = 0; \
errno_t _Err = _FuncName##_s(_Dst + 2, (_Sz - 2) < ((size_t)_Dst[0]) ? (_Sz - 2) : ((size_t)_Dst[0]), &_SizeRead); \
_Dst[1] = (_DstType)(_SizeRead); \
return (_Err == 0 ? _Dst + 2 : 0); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) \
_ReturnType __CRTDECL _FuncName<1>(_DstType (&_Dst)[1]) \
{ \
return __insecure_##_FuncName((_DstType *)_Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) \
_ReturnType __CRTDECL _FuncName<2>(_DstType (&_Dst)[2]) \
{ \
return __insecure_##_FuncName((_DstType *)_Dst); \
} \
}
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1) \
__inline \
_ReturnType __CRTDECL __insecure_##_FuncName(_DstType *_Dst, _TType1 _TArg1) \
{ \
_DeclSpec _ReturnType __cdecl _FuncName(_DstType *, _TType1); \
return _FuncName(_Dst, _TArg1); \
} \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_T &_Dst, _TType1 _TArg1) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(const _T &_Dst, _TType1 _TArg1) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_DstType * &_Dst, _TType1 _TArg1) \
{ \
return __insecure_##_FuncName(_Dst, _TArg1); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_SecureDstType (&_Dst)[_Sz], _TType1 _TArg1) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, _Sz, _TArg1), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, 1, _TArg1), _Dst); \
} \
}
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__inline \
_ReturnType __CRTDECL __insecure_##_FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2) \
{ \
_DeclSpec _ReturnType __cdecl _FuncName(_DstType *, _TType1, _TType2); \
return _FuncName(_Dst, _TArg1, _TArg2); \
} \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_T &_Dst, _TType1 _TArg1, _TType2 _TArg2) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(const _T &_Dst, _TType1 _TArg1, _TType2 _TArg2) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_DstType * &_Dst, _TType1 _TArg1, _TType2 _TArg2) \
{ \
return __insecure_##_FuncName(_Dst, _TArg1, _TArg2); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_SecureDstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, _Sz, _TArg1, _TArg2), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1, _TType2 _TArg2) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, 1, _TArg1, _TArg2), _Dst); \
} \
}
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_3_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
__inline \
_ReturnType __CRTDECL __insecure_##_FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
_DeclSpec _ReturnType __cdecl _FuncName(_DstType *, _TType1, _TType2, _TType3); \
return _FuncName(_Dst, _TArg1, _TArg2, _TArg3); \
} \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_T &_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2, _TArg3); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(const _T &_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2, _TArg3); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_DstType * &_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
return __insecure_##_FuncName(_Dst, _TArg1, _TArg2, _TArg3); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_SecureDstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, _Sz, _TArg1, _TArg2, _TArg3), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, 1, _TArg1, _TArg2, _TArg3), _Dst); \
} \
}
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_4_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4, _TArg4) \
__inline \
_ReturnType __CRTDECL __insecure_##_FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3, _TType4 _TArg4) \
{ \
_DeclSpec _ReturnType __cdecl _FuncName(_DstType *, _TType1, _TType2, _TType3, _TType4); \
return _FuncName(_Dst, _TArg1, _TArg2, _TArg3, _TArg4); \
} \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_T &_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3, _TType4 _TArg4) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2, _TArg3, _TArg4); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(const _T &_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3, _TType4 _TArg4) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2, _TArg3, _TArg4); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_DstType * &_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3, _TType4 _TArg4) \
{ \
return __insecure_##_FuncName(_Dst, _TArg1, _TArg2, _TArg3, _TArg4); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3, _TType4 _TArg4) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, _Sz, _TArg1, _TArg2, _TArg3, _TArg4), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3, _TType4 _TArg4) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, 1, _TArg1, _TArg2, _TArg3, _TArg4), _Dst); \
} \
}
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1) \
__inline \
_ReturnType __CRTDECL __insecure_##_FuncName(_HType1 _HArg1, _DstType *_Dst, _TType1 _TArg1) \
{ \
_DeclSpec _ReturnType __cdecl _FuncName(_HType1, _DstType *, _TType1); \
return _FuncName(_HArg1, _Dst, _TArg1); \
} \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _T &_Dst, _TType1 _TArg1) \
{ \
return __insecure_##_FuncName(_HArg1, static_cast<_DstType *>(_Dst), _TArg1); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_HType1 _HArg1, const _T &_Dst, _TType1 _TArg1) \
{ \
return __insecure_##_FuncName(_HArg1, static_cast<_DstType *>(_Dst), _TArg1); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _DstType * &_Dst, _TType1 _TArg1) \
{ \
return __insecure_##_FuncName(_HArg1, _Dst, _TArg1); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _DstType (&_Dst)[_Sz], _TType1 _TArg1) \
{ \
_ReturnPolicy(_SecureFuncName(_HArg1, _Dst, _Sz, _TArg1), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName<1>(_HType1 _HArg1, _DstType (&_Dst)[1], _TType1 _TArg1) \
{ \
_ReturnPolicy(_SecureFuncName(_HArg1, _Dst, 1, _TArg1), _Dst); \
} \
}
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_2_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst) \
__inline \
_ReturnType __CRTDECL __insecure_##_FuncName(_HType1 _HArg1, _HType2 _HArg2, _DstType *_Dst) \
{ \
_DeclSpec _ReturnType __cdecl _FuncName(_HType1, _HType2, _DstType *); \
return _FuncName(_HArg1, _HArg2, _Dst); \
} \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _HType2 _HArg2, _T &_Dst) \
{ \
return __insecure_##_FuncName(_HArg1, _HArg2, static_cast<_DstType *>(_Dst)); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _HType2 _HArg2, const _T &_Dst) \
{ \
return __insecure_##_FuncName(_HArg1, _HArg2, static_cast<_DstType *>(_Dst)); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _HType2 _HArg2, _DstType * &_Dst) \
{ \
return __insecure_##_FuncName(_HArg1, _HArg2, _Dst); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_HType1 _HArg1, _HType2 _HArg2, _DstType (&_Dst)[_Sz]) \
{ \
_ReturnPolicy(_SecureFuncName(_HArg1, _HArg2, _Dst, _Sz), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName<1>(_HType1 _HArg1, _HType2 _HArg2, _DstType (&_Dst)[1]) \
{ \
_ReturnPolicy(_SecureFuncName(_HArg1, _HArg2, _Dst, 1), _Dst); \
} \
}
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _VFuncName, _SecureVFuncName, _DstType, _Dst, _TType1, _TArg1) \
__inline \
_ReturnType __CRTDECL __insecure_##_VFuncName(_DstType *_Dst, _TType1 _TArg1, va_list _ArgList) \
{ \
_DeclSpec _ReturnType __cdecl _VFuncName(_DstType *, _TType1, va_list); \
return _VFuncName(_Dst, _TArg1, _ArgList); \
} \
extern "C++" \
{ \
__pragma(warning(push)); \
__pragma(warning(disable: 4793)); \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_T &_Dst, _TType1 _TArg1, ...) \
{ \
va_list _ArgList; \
_crt_va_start(_ArgList, _TArg1); \
return __insecure_##_VFuncName(static_cast<_DstType *>(_Dst), _TArg1, _ArgList); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(const _T &_Dst, _TType1 _TArg1, ...) \
{ \
va_list _ArgList; \
_crt_va_start(_ArgList, _TArg1); \
return __insecure_##_VFuncName(static_cast<_DstType *>(_Dst), _TArg1, _ArgList); \
} \
__pragma(warning(pop)); \
\
__pragma(warning(push)); \
__pragma(warning(disable: 4793)); \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_DstType * &_Dst, _TType1 _TArg1, ...) \
{ \
va_list _ArgList; \
_crt_va_start(_ArgList, _TArg1); \
return __insecure_##_VFuncName(_Dst, _TArg1, _ArgList); \
} \
__pragma(warning(pop)); \
\
__pragma(warning(push)); \
__pragma(warning(disable: 4793)); \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_DstType (&_Dst)[_Sz], _TType1 _TArg1, ...) \
{ \
va_list _ArgList; \
_crt_va_start(_ArgList, _TArg1); \
_ReturnPolicy(_SecureVFuncName(_Dst, _Sz, _TArg1, _ArgList), _Dst); \
} \
__pragma(warning(pop)); \
\
__pragma(warning(push)); \
__pragma(warning(disable: 4793)); \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1, ...) \
{ \
va_list _ArgList; \
_crt_va_start(_ArgList, _TArg1); \
_ReturnPolicy(_SecureVFuncName(_Dst, 1, _TArg1, _ArgList), _Dst); \
} \
__pragma(warning(pop)); \
\
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureVFuncName) \
_ReturnType __CRTDECL _VFuncName(_T &_Dst, _TType1 _TArg1, va_list _ArgList) \
{ \
return __insecure_##_VFuncName(static_cast<_DstType *>(_Dst), _TArg1, _ArgList); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureVFuncName) \
_ReturnType __CRTDECL _VFuncName(const _T &_Dst, _TType1 _TArg1, va_list _ArgList) \
{ \
return __insecure_##_VFuncName(static_cast<_DstType *>(_Dst), _TArg1, _ArgList); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureVFuncName) \
_ReturnType __CRTDECL _VFuncName(_DstType *&_Dst, _TType1 _TArg1, va_list _ArgList) \
{ \
return __insecure_##_VFuncName(_Dst, _TArg1, _ArgList); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _VFuncName(_DstType (&_Dst)[_Sz], _TType1 _TArg1, va_list _ArgList) \
{ \
_ReturnPolicy(_SecureVFuncName(_Dst, _Sz, _TArg1, _ArgList), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureVFuncName) \
_ReturnType __CRTDECL _VFuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1, va_list _ArgList) \
{ \
_ReturnPolicy(_SecureVFuncName(_Dst, 1, _TArg1, _ArgList), _Dst); \
} \
}
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _SecureVFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__inline \
_ReturnType __CRTDECL __insecure_##_VFuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, va_list _ArgList) \
{ \
_DeclSpec _ReturnType __cdecl _VFuncName(_DstType *, _TType1, _TType2, va_list); \
return _VFuncName(_Dst, _TArg1, _TArg2, _ArgList); \
} \
extern "C++" \
{ \
__pragma(warning(push)); \
__pragma(warning(disable: 4793)); \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) \
_ReturnType __CRTDECL _FuncName(_T &_Dst, _TType1 _TArg1, _TType2 _TArg2, ...) \
{ \
va_list _ArgList; \
_crt_va_start(_ArgList, _TArg2); \
return __insecure_##_VFuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2, _ArgList); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) \
_ReturnType __CRTDECL _FuncName(const _T &_Dst, _TType1 _TArg1, _TType2 _TArg2, ...) \
{ \
va_list _ArgList; \
_crt_va_start(_ArgList, _TArg2); \
return __insecure_##_VFuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2, _ArgList); \
} \
__pragma(warning(pop)); \
\
__pragma(warning(push)); \
__pragma(warning(disable: 4793)); \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) \
_ReturnType __CRTDECL _FuncName(_DstType * &_Dst, _TType1 _TArg1, _TType2 _TArg2, ...) \
{ \
va_list _ArgList; \
_crt_va_start(_ArgList, _TArg2); \
return __insecure_##_VFuncName(_Dst, _TArg1, _TArg2, _ArgList); \
} \
__pragma(warning(pop)); \
\
__pragma(warning(push)); \
__pragma(warning(disable: 4793)); \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_SecureDstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2, ...) \
{ \
va_list _ArgList; \
_crt_va_start(_ArgList, _TArg2); \
_ReturnPolicy(_SecureVFuncName(_Dst, _Sz, _TArg1, _TArg2, _ArgList), _Dst); \
} \
__pragma(warning(pop)); \
\
__pragma(warning(push)); \
__pragma(warning(disable: 4793)); \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) \
_ReturnType __CRTDECL _FuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1, _TType2 _TArg2, ...) \
{ \
va_list _ArgList; \
_crt_va_start(_ArgList, _TArg2); \
_ReturnPolicy(_SecureVFuncName(_Dst, 1, _TArg1, _TArg2, _ArgList), _Dst); \
} \
__pragma(warning(pop)); \
\
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureVFuncName) \
_ReturnType __CRTDECL _VFuncName(_T &_Dst, _TType1 _TArg1, _TType2 _TArg2, va_list _ArgList) \
{ \
return __insecure_##_VFuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2, _ArgList); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureVFuncName) \
_ReturnType __CRTDECL _VFuncName(const _T &_Dst, _TType1 _TArg1, _TType2 _TArg2, va_list _ArgList) \
{ \
return __insecure_##_VFuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2, _ArgList); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureVFuncName) \
_ReturnType __CRTDECL _VFuncName(_DstType *&_Dst, _TType1 _TArg1, _TType2 _TArg2, va_list _ArgList) \
{ \
return __insecure_##_VFuncName(_Dst, _TArg1, _TArg2, _ArgList); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _VFuncName(_SecureDstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2, va_list _ArgList) \
{ \
_ReturnPolicy(_SecureVFuncName(_Dst, _Sz, _TArg1, _TArg2, _ArgList), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureVFuncName) \
_ReturnType __CRTDECL _VFuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1, _TType2 _TArg2, va_list _ArgList) \
{ \
_ReturnPolicy(_SecureVFuncName(_Dst, 1, _TArg1, _TArg2, _ArgList), _Dst); \
} \
}
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_SIZE_EX(_DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__inline \
size_t __CRTDECL __insecure_##_FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2) \
{ \
_DeclSpec size_t __cdecl _FuncName(_DstType *, _TType1, _TType2); \
return _FuncName(_Dst, _TArg1, _TArg2); \
} \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
size_t __CRTDECL _FuncName(_T &_Dst, _TType1 _TArg1, _TType2 _TArg2) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
size_t __CRTDECL _FuncName(const _T &_Dst, _TType1 _TArg1, _TType2 _TArg2) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
size_t __CRTDECL _FuncName(_DstType * &_Dst, _TType1 _TArg1, _TType2 _TArg2) \
{ \
return __insecure_##_FuncName(_Dst, _TArg1, _TArg2); \
} \
template <size_t _Sz> \
inline \
size_t __CRTDECL _FuncName(_SecureDstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2) \
{ \
size_t _Ret = 0; \
_SecureFuncName(&_Ret, _Dst, _Sz, _TArg1, _TArg2); \
return (_Ret > 0 ? (_Ret - 1) : _Ret); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
size_t __CRTDECL _FuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1, _TType2 _TArg2) \
{ \
size_t _Ret = 0; \
_SecureFuncName(&_Ret, _Dst, 1, _TArg1, _TArg2); \
return (_Ret > 0 ? (_Ret - 1) : _Ret); \
} \
}
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_3_SIZE_EX(_DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
__inline \
size_t __CRTDECL __insecure_##_FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
_DeclSpec size_t __cdecl _FuncName(_DstType *, _TType1, _TType2, _TType3); \
return _FuncName(_Dst, _TArg1, _TArg2, _TArg3); \
} \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
size_t __CRTDECL _FuncName(_T &_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2, _TArg3); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
size_t __CRTDECL _FuncName(const _T &_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2, _TArg3); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
size_t __CRTDECL _FuncName(_DstType * &_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
return __insecure_##_FuncName(_Dst, _TArg1, _TArg2, _TArg3); \
} \
template <size_t _Sz> \
inline \
size_t __CRTDECL _FuncName(_SecureDstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
size_t _Ret = 0; \
_SecureFuncName(&_Ret, _Dst, _Sz, _TArg1, _TArg2, _TArg3); \
return (_Ret > 0 ? (_Ret - 1) : _Ret); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
size_t __CRTDECL _FuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
size_t _Ret = 0; \
_SecureFuncName(&_Ret, _Dst, 1, _TArg1, _TArg2, _TArg3); \
return (_Ret > 0 ? (_Ret - 1) : _Ret); \
} \
}
#define __DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_0_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst) \
__inline \
_ReturnType __CRTDECL __insecure_##_FuncName(_DstType *_Dst)
#define __DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_0_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst) \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_T &_Dst) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst)); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(const _T &_Dst) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst)); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_DstType * &_Dst) \
{ \
return __insecure_##_FuncName(_Dst); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_SecureDstType (&_Dst)[_Sz]) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, _Sz), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName<1>(_DstType (&_Dst)[1]) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, 1), _Dst); \
} \
}
#define __DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_1_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1) \
__inline \
_ReturnType __CRTDECL __insecure_##_FuncName(_DstType *_Dst, _TType1 _TArg1)
#define __DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_1_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1) \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_T &_Dst, _TType1 _TArg1) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(const _T &_Dst, _TType1 _TArg1) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_DstType * &_Dst, _TType1 _TArg1) \
{ \
return __insecure_##_FuncName(_Dst, _TArg1); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_SecureDstType (&_Dst)[_Sz], _TType1 _TArg1) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, _Sz, _TArg1), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, 1, _TArg1), _Dst); \
} \
}
#define __DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_2_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__inline \
_ReturnType __CRTDECL __insecure_##_FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2)
#define __DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_2_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_T &_Dst, _TType1 _TArg1, _TType2 _TArg2) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(const _T &_Dst, _TType1 _TArg1, _TType2 _TArg2) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_DstType * &_Dst, _TType1 _TArg1, _TType2 _TArg2) \
{ \
return __insecure_##_FuncName(_Dst, _TArg1, _TArg2); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_SecureDstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, _Sz, _TArg1, _TArg2), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1, _TType2 _TArg2) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, 1, _TArg1, _TArg2), _Dst); \
} \
}
#define __DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_3_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
__inline \
_ReturnType __CRTDECL __insecure_##_FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3)
#define __DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_3_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
extern "C++" \
{ \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_T &_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2, _TArg3); \
} \
template <typename _T> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(const _T &_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
return __insecure_##_FuncName(static_cast<_DstType *>(_Dst), _TArg1, _TArg2, _TArg3); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName(_DstType * &_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
return __insecure_##_FuncName(_Dst, _TArg1, _TArg2, _TArg3); \
} \
template <size_t _Sz> \
inline \
_ReturnType __CRTDECL _FuncName(_SecureDstType (&_Dst)[_Sz], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, _Sz, _TArg1, _TArg2, _TArg3), _Dst); \
} \
template <> \
inline \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
_ReturnType __CRTDECL _FuncName<1>(_DstType (&_Dst)[1], _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3) \
{ \
_ReturnPolicy(_SecureFuncName(_Dst, 1, _TArg1, _TArg2, _TArg3), _Dst); \
} \
}
#if !defined(RC_INVOKED) && _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _DstType, _Dst) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _DstType, _Dst)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_0_CGETS(_ReturnType, _DeclSpec, _FuncName, _DstType, _Dst) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0_CGETS(_ReturnType, _DeclSpec, _FuncName, _DstType, _Dst)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_3_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_4_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_4_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_1_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_2_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_2_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_1_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _VFuncName, _SecureVFuncName, _DstType, _Dst, _TType1, _TArg1) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _VFuncName, _SecureVFuncName, _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _VFuncName##_s, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_SIZE_EX(_DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_SIZE_EX(_DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_SIZE_EX(_DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
__DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_3_SIZE_EX(_DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#define __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_0_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst) \
__DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_0_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType _DstType, _Dst)
#define __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_0_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst) \
__DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_0_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst)
#define __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_1_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1) \
__DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_1_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType _DstType, _Dst, _TType1, _TArg1)
#define __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_1_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1) \
__DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_1_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1)
#define __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_2_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_2_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_2_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
__DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_2_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
__DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_3_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#define __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
__DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_3_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#else
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _DstType, _Dst) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_0_GETS(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _DstType, _Dst) \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_4_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4, _TArg4) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3, _TType4 _TArg4);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_1_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_HType1 _HArg1, _DstType *_Dst, _TType1 _TArg1);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_2_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_HType1 _HArg1, _HType2 _HArg2, _DstType *_Dst);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_1_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName,_VFuncName, _SecureVFuncName, _DstType, _Dst, _TType1, _TArg1) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, ...); \
_CRT_INSECURE_DEPRECATE(_SecureVFuncName) _DeclSpec _ReturnType __cdecl _VFuncName(_DstType *_Dst, _TType1 _TArg1, va_list _Args);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, ...); \
_CRT_INSECURE_DEPRECATE(_VFuncName##_s) _DeclSpec _ReturnType __cdecl _VFuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, va_list _Args);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, ...); \
_CRT_INSECURE_DEPRECATE(_VFuncName##_s) _DeclSpec _ReturnType __cdecl _VFuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, va_list _Args);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_SIZE_EX(_DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec size_t __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_SIZE_EX(_DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec size_t __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3);
#define __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_0_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
__inline \
_ReturnType __CRTDECL _FuncName(_DstType *_Dst)
#define __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_0_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst)
#define __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_1_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
__inline \
_ReturnType __CRTDECL _FuncName(_DstType *_Dst, _TType1 _TArg1)
#define __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_1_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1)
#define __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_2_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
__inline \
_ReturnType __CRTDECL _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2)
#define __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_2_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
__inline \
_ReturnType __CRTDECL _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3)
#define __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#endif /* _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT */
#else
#define __RETURN_POLICY_SAME(_FunctionCall)
#define __RETURN_POLICY_DST(_FunctionCall)
#define __RETURN_POLICY_VOID(_FunctionCall)
#define __EMPTY_DECLSPEC
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _DstType, _Dst) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst);
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0_CGETS(_ReturnType, _DeclSpec, _FuncName, _DstType, _Dst) \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst);
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1);
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2);
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_3_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3);
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_4_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4, _TArg4) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3, _TType4 _TArg4);
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_1_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_HType1 _HArg1, _DstType *_Dst, _TType1 _TArg1);
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_2_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_HType1 _HArg1, _HType2 _HArg2, _DstType *_Dst);
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_1_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _VFuncName, _SecureVFuncName, _DstType, _Dst, _TType1, _TArg1) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, ...); \
_CRT_INSECURE_DEPRECATE(_SecureVFuncName) _DeclSpec _ReturnType __cdecl _VFuncName(_DstType *_Dst, _TType1 _TArg1, va_list _Args);
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _SecureVFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, ...); \
_CRT_INSECURE_DEPRECATE(_SecureVFuncName) _DeclSpec _ReturnType __cdecl _VFuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, va_list _Args);
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_2_SIZE_EX(_DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec size_t __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2);
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_3_SIZE_EX(_DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec size_t __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _DstType, _Dst) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_0_GETS(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _DstType, _Dst) \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_4_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3, _TType4, _TArg4) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3, _TType4 _TArg4);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_1_1_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _HType1, _HArg1, _DstType, _Dst, _TType1, _TArg1) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_HType1 _HArg1, _DstType *_Dst, _TType1 _TArg1);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_2_0_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _HType1, _HArg1, _HType2, _HArg2, _DstType, _Dst) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_HType1 _HArg1, _HType2 _HArg2, _DstType *_Dst);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_1_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SecureFuncName, _VFuncName, _SecureVFuncName, _DstType, _Dst, _TType1, _TArg1) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, ...); \
_CRT_INSECURE_DEPRECATE(_SecureVFuncName) _DeclSpec _ReturnType __cdecl _VFuncName(_DstType *_Dst, _TType1 _TArg1, va_list _Args);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, ...); \
_CRT_INSECURE_DEPRECATE(_VFuncName##_s) _DeclSpec _ReturnType __cdecl _VFuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, va_list _Args);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_ARGLIST_EX(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _VFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_FuncName##_s) _DeclSpec _ReturnType __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, ...); \
_CRT_INSECURE_DEPRECATE(_VFuncName##_s) _DeclSpec _ReturnType __cdecl _VFuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, va_list _Args);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_2_SIZE_EX(_DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec size_t __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2);
#define __DEFINE_CPP_OVERLOAD_STANDARD_NFUNC_0_3_SIZE_EX(_DeclSpec, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) _DeclSpec size_t __cdecl _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3);
#define __DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_0_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
__inline \
_ReturnType __CRTDECL _FuncName(_DstType *_Dst)
#define __DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_0_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst)
#define __DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_1_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
__inline \
_ReturnType __CRTDECL _FuncName(_DstType *_Dst, _TType1 _TArg1)
#define __DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_1_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1)
#define __DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_2_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
__inline \
_ReturnType __CRTDECL _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2)
#define __DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_2_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DECLARE_CPP_OVERLOAD_INLINE_FUNC_0_3_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
__inline \
_ReturnType __CRTDECL _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3)
#define __DEFINE_CPP_OVERLOAD_INLINE_FUNC_0_3_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#define __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_0_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
__inline \
_ReturnType __CRTDECL _FuncName(_DstType *_Dst)
#define __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_0_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst)
#define __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_1_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
__inline \
_ReturnType __CRTDECL _FuncName(_DstType *_Dst, _TType1 _TArg1)
#define __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_1_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1)
#define __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_2_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
__inline \
_ReturnType __CRTDECL _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2)
#define __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_2_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2)
#define __DECLARE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3) \
_CRT_INSECURE_DEPRECATE(_SecureFuncName) \
__inline \
_ReturnType __CRTDECL _FuncName(_DstType *_Dst, _TType1 _TArg1, _TType2 _TArg2, _TType3 _TArg3)
#define __DEFINE_CPP_OVERLOAD_INLINE_NFUNC_0_3_EX(_ReturnType, _ReturnPolicy, _FuncName, _SecureFuncName, _SecureDstType, _DstType, _Dst, _TType1, _TArg1, _TType2, _TArg2, _TType3, _TArg3)
#endif /* _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES */
#endif
struct threadlocaleinfostruct;
struct threadmbcinfostruct;
typedef struct threadlocaleinfostruct * pthreadlocinfo;
typedef struct threadmbcinfostruct * pthreadmbcinfo;
struct __lc_time_data;
typedef struct localeinfo_struct
{
pthreadlocinfo locinfo;
pthreadmbcinfo mbcinfo;
} _locale_tstruct, *_locale_t;
#ifndef _TAGLC_ID_DEFINED
typedef struct tagLC_ID {
unsigned short wLanguage;
unsigned short wCountry;
unsigned short wCodePage;
} LC_ID, *LPLC_ID;
#define _TAGLC_ID_DEFINED
#endif /* _TAGLC_ID_DEFINED */
#ifndef _THREADLOCALEINFO
typedef struct threadlocaleinfostruct {
int refcount;
unsigned int lc_codepage;
unsigned int lc_collate_cp;
unsigned long lc_handle[6]; /* LCID */
LC_ID lc_id[6];
struct {
char *locale;
wchar_t *wlocale;
int *refcount;
int *wrefcount;
} lc_category[6];
int lc_clike;
int mb_cur_max;
int * lconv_intl_refcount;
int * lconv_num_refcount;
int * lconv_mon_refcount;
struct lconv * lconv;
int * ctype1_refcount;
unsigned short * ctype1;
const unsigned short * pctype;
const unsigned char * pclmap;
const unsigned char * pcumap;
struct __lc_time_data * lc_time_curr;
} threadlocinfo;
#define _THREADLOCALEINFO
#endif
#ifdef __cplusplus
}
#endif
#if defined(_PREFAST_) && defined(_PFT_SHOULD_CHECK_RETURN)
#define __checkReturn_opt __checkReturn
#else
#define __checkReturn_opt
#endif
#if defined(_PREFAST_) && defined(_PFT_SHOULD_CHECK_RETURN_WAT)
#define __checkReturn_wat __checkReturn
#else
#define __checkReturn_wat
#endif
#if !defined(__midl) && !defined(MIDL_PASS) && defined(_PREFAST_)
#define __crt_typefix(ctype) __declspec("SAL_typefix(" __CRT_STRINGIZE(ctype) ")")
#else
#define __crt_typefix(ctype)
#endif
#if (defined(__midl))
/* suppress tchar inlines */
#ifndef _NO_INLINING
#define _NO_INLINING
#endif
#endif
#ifndef _CRT_UNUSED
#define _CRT_UNUSED(x) (void)x
#endif
#ifdef _MSC_VER
#pragma pack(pop)
#endif /* _MSC_VER */
#endif /* _INC_CRTDEFS */
| [
"roman_yakovenko@dc5859f9-2512-0410-ae5c-dd123cda1f76"
]
| [
[
[
1,
2122
]
]
]
|
b79e60a0432b82f513d719f61b338bac4b697e99 | 9c62af23e0a1faea5aaa8dd328ba1d82688823a5 | /rl/branches/persistence2/engine/core/src/nulldriver/NullSound.cpp | 8eb3953ac345cce05545f4a20917f9ac11e2c1f6 | [
"ClArtistic",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
]
| permissive | jacmoe/dsa-hl-svn | 55b05b6f28b0b8b216eac7b0f9eedf650d116f85 | 97798e1f54df9d5785fb206c7165cd011c611560 | refs/heads/master | 2021-04-22T12:07:43.389214 | 2009-11-27T22:01:03 | 2009-11-27T22:01:03 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 4,728 | cpp | /* This source file is part of Rastullahs Lockenpracht.
* Copyright (C) 2003-2008 Team Pantheon. http://www.team-pantheon.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Clarified Artistic License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Clarified Artistic License for more details.
*
* You should have received a copy of the Clarified Artistic License
* along with this program; if not you can get it here
* http://www.jpaulmorrison.com/fbp/artistic2.htm.
*/
#include "stdinc.h"
#include "NullSound.h"
#include "NullDriver.h"
#include "SoundManager.h"
#include "SoundResource.h"
using namespace Ogre;
Ogre::String rl::NullSound::msMovableType = "NullSound";
namespace rl {
/**
* @param name Der Name des Sounds.
* @author JoSch
* @date 07-04-2005
*/
NullSound::NullSound(const SoundResourcePtr &soundres, SoundDriver* creator):
Sound(soundres, creator)
{
}
/**
* @author JoSch
* @date 07-04-2005
*/
NullSound::~NullSound()
{
unload();
}
/**
* @author JoSch
* @date 07-12-2005
*/
void NullSound::load() throw (RuntimeException)
{
}
/**
* @author JoSch
* @date 07-22-2005
*/
void NullSound::unload() throw (RuntimeException)
{
}
/**
* @return TRUE wenn der Sound gueltig ist.
* @author JoSch
* @date 07-12-2005
*/
bool NullSound::isValid() const throw (RuntimeException)
{
return true;
}
/**
* @return Die gesamte Spiellänge des Sounds
* @author JoSch
* @date 03-18-2005
*/
float NullSound::getLength() const
{
return 0.0;
}
void NullSoundPtr::destroy()
{
SharedPtr<NullSound>::destroy();
}
/**
* @author JoSch
* @date 07-23-2005
*/
void NullSound::play(bool destroyWhenDone)
{
if (destroyWhenDone)
{
// We're not going to play anything, so we can self-destroy right away...
mCreator->destroySound(this);
}
}
/**
* @author JoSch
* @date 03-11-2005
* @return Den Objekttypen
*/
const String& NullSound::getMovableType() const
{
return msMovableType;
}
/**
* @return Die aktuelle Richtung der Soundquelle
* @author JoSch
* @date 07-23-2004
*/
const Quaternion NullSound::getDirection() const
{
return mDirection;
}
/**
* @param direction Die neue Richtung der Soundquelle.
* @author JoSch
* @date 07-23-2004
*/
void NullSound::setDirection (const Quaternion& direction)
{
mDirection = direction;
}
/**
* @return Spielt die Soundquelle noch?
* @author JoSch
* @date 07-04-2005
*/
const bool NullSound::isPlaying() const
{
return false;
}
/**
* @return Die aktuelle Position der Soundquelle
* @author JoSch
* @date 07-04-2005
*/
const Vector3 NullSound::getPosition() const
{
return mPosition;
}
/**
* @param position Die neue Position der Soundquelle.
* @author JoSch
* @date 07-04-2005
*/
void NullSound::setPosition(const Vector3& position)
{
mPosition = position;
}
/**
* @return Die aktuelle Geschwindigkeit der Soundquelle
* @author JoSch
* @date 07-04-2005
*/
const Vector3 NullSound::getVelocity() const
{
return mVelocity;
}
/**
* @param velocity Die neue Geschwindigkeit der Soundquelle.
* @author JoSch
* @date 07-04-2005
*/
void NullSound::setVelocity(const Vector3& velocity)
{
mVelocity = velocity;
}
/**
* @return Die aktuelle Lautstaerke der Soundquelle
* @author JoSch
* @date 07-04-2005
*/
const Ogre::Real NullSound::getVolume() const
{
return mVolume;
}
/**
* @param gain Die neue Lautstarke der Soundquelle.
* @author JoSch
* @date 07-04-2005
*/
void NullSound::setVolume(const Ogre::Real gain)
{
mVolume = gain;
}
/**
* @param pausing TRUE laesst den Sound unterbrechen.
* @author JoSch
* @date 07-04-2005
*/
void NullSound::pause(bool pausing)
{
}
/**
* @author JoSch
* @date 07-23-2004
*/
void NullSound::stop()
{
}
/**
* @return TRUE wenn der Sound unterbrochen wurde.
* @author JoSch
* @date 07-04-2005
*/
bool NullSound::isPaused()
{
return true;
}
/**
* @author JoSch
* @date 14-03-2007
* @version 1.0
* @param priority The new priority of this sound
*/
void NullSound::setPriority(const int priority)
{
mPriority = priority;
}
/**
* @author JoSch
* @date 14-03-2007
* @version 1.0
* @return The new priority of this sound
*/
const int NullSound::getPriority() const
{
return mPriority;
}
} // Namespace
| [
"timm@4c79e8ff-cfd4-0310-af45-a38c79f83013"
]
| [
[
[
1,
255
]
]
]
|
7c4780f57e8ac53d8a493bb68a28fb058c39fea5 | 15732b8e4190ae526dcf99e9ffcee5171ed9bd7e | /GeneratedFiles/Release/moc_listview.cpp | 9d2516ca3ecc7dcf6a278d7b7a6c0d72c59e3ee5 | []
| no_license | clovermwliu/whutnetsim | d95c07f77330af8cefe50a04b19a2d5cca23e0ae | 924f2625898c4f00147e473a05704f7b91dac0c4 | refs/heads/master | 2021-01-10T13:10:00.678815 | 2010-04-14T08:38:01 | 2010-04-14T08:38:01 | 48,568,805 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,267 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'listview.h'
**
** Created: Wed Feb 3 11:15:19 2010
** by: The Qt Meta Object Compiler version 59 (Qt 4.3.2)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../INC/listview.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'listview.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 59
#error "This file was generated using the moc from 4.3.2. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
static const uint qt_meta_data_listview[] = {
// content:
1, // revision
0, // classname
0, 0, // classinfo
1, 10, // methods
0, 0, // properties
0, 0, // enums/sets
// signals: signature, parameters, type, tag, flags
10, 9, 9, 9, 0x05,
0 // eod
};
static const char qt_meta_stringdata_listview[] = {
"listview\0\0currentfile(QString)\0"
};
const QMetaObject listview::staticMetaObject = {
{ &QListView::staticMetaObject, qt_meta_stringdata_listview,
qt_meta_data_listview, 0 }
};
const QMetaObject *listview::metaObject() const
{
return &staticMetaObject;
}
void *listview::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_listview))
return static_cast<void*>(const_cast< listview*>(this));
return QListView::qt_metacast(_clname);
}
int listview::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QListView::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: currentfile((*reinterpret_cast< QString(*)>(_a[1]))); break;
}
_id -= 1;
}
return _id;
}
// SIGNAL 0
void listview::currentfile(QString _t1)
{
void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
| [
"pengelmer@f37e807c-cba8-11de-937e-2741d7931076"
]
| [
[
[
1,
76
]
]
]
|
ca2026da2c7c048d563c7b5546bbce450334d28b | 5ff30d64df43c7438bbbcfda528b09bb8fec9e6b | /tests/unit/graphics/WindowApplication.h | b63e599b15bfe373503788558dc49952127300af | []
| no_license | lvtx/gamekernel | c80cdb4655f6d4930a7d035a5448b469ac9ae924 | a84d9c268590a294a298a4c825d2dfe35e6eca21 | refs/heads/master | 2016-09-06T18:11:42.702216 | 2011-09-27T07:22:08 | 2011-09-27T07:22:08 | 38,255,025 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 795 | h | #pragma once
#define WINDOWS_LEAN_AND_MEAN
#include <windows.h>
/**
* @class WindowApplication
*
* A skeleton class to test graphics features.
*
*/
class WindowApplication
{
public:
static WindowApplication* Instance;
void Setup( TCHAR* windowTitle, int positionX, int positionY, int width, int height );
void Run( int duration = 0 );
void OnMessage( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
HWND GetWindowHandle();
protected:
virtual bool init();
virtual void work();
virtual void onMessage( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
virtual void fini();
protected:
HWND handle_;
TCHAR* windowTitle_;
int positionX_;
int positionY_;
int width_;
int height_;
};
| [
"darkface@localhost"
]
| [
[
[
1,
43
]
]
]
|
1f8ba95a23b20d5518cc36d508cfed7934998248 | 12d2d19ae9e12973a7d25b97b5bc530b82dd9519 | /deliciousServer/deliciousServer.cpp | 2729a03873292b694fe39feea82602aff667e7f9 | []
| no_license | gaoxiaojun/delicacymap | fe82b228e89d3fad48262e03bd097a9041c2a252 | aceabb664bbd6f7b87b0c9b8ffdad55bc6310c68 | refs/heads/master | 2021-01-10T11:11:51.412815 | 2010-05-05T02:36:14 | 2010-05-05T02:36:14 | 47,736,729 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,969 | cpp | // deliciousServer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "tcpserver.h"
#include "Messenger.h"
#include "naked_conn.h"
#include "deliciousDataAdapter.h"
#include <string>
#include <exception>
#include <iostream>
#include <pantheios/backends/bec.file.h>
#include <boost/array.hpp>
#include <boost/thread.hpp>
#include <boost/foreach.hpp>
#include <boost/program_options.hpp>
using namespace std;
using namespace boost::asio;
using namespace boost::program_options;
extern "C"
const char PANTHEIOS_FE_PROCESS_IDENTITY[] = "deliciousServer";
static const int MonitorPort = 24000;
boost::asio::io_service io;
rclib::network::TCPServer<naked_conn> *serverd;
bool InitializeComponents(const string& dbpath);
int main(int argc, char* argv[])
{
GOOGLE_PROTOBUF_VERIFY_VERSION;
options_description desc("Allowed options for delicious server:");
desc.add_options()
("help", "Output this message.")
("db", value<string>()->default_value("delicacyDB.db3"), "Opens sqlite database at given location.")
("logpath", value<string>()->default_value("delicious.log"), "Write run log to given path.");
variables_map vm;
store(parse_command_line(argc, argv, desc), vm);
notify(vm);
if (vm.count("help")) {
cout << desc << "\n";
return 1;
}
//////////////////////////////////////////////////////////////////////////
pantheios_be_file_setFilePath(vm["logpath"].as<string>().c_str());
//////////////////////////////////////////////////////////////////////////
pantheios::log_NOTICE("Server launched.");
if (!InitializeComponents(vm["db"].as<string>()))
{
pantheios::log_NOTICE("Initialize Faile. Terminating...");
return -1;
}
rclib::network::Messenger::GetInstance()->start();
serverd->start();
pantheios::log_NOTICE("Server Start.");
boost::array<boost::thread, 4> threadpool;
BOOST_FOREACH(boost::thread& t, threadpool)
t = boost::thread(boost::bind(&io_service::run, &io));
io.run();
BOOST_FOREACH(boost::thread& t, threadpool)
t.join();
pantheios::log_NOTICE("Server Stoped normally.");
return 0;
}
bool InitializeComponents(const string& dbpath)
{
pantheios::log_NOTICE("Begin Initialize.");
try
{
serverd = new rclib::network::TCPServer<naked_conn>(io, MonitorPort);
pantheios::log_INFORMATIONAL("Network daemon initialized.");
deliciousDataAdapter::Initialize(dbpath);
pantheios::log_INFORMATIONAL("Database initialized.");
rclib::network::Messenger::Initialize(io);
pantheios::log_INFORMATIONAL("Messenger initialized.");
pantheios::log_NOTICE("Initialization Finished Successfully.");
return true;
}
catch (exception& e)
{
pantheios::log_CRITICAL(e.what());
return false;
}
}
| [
"colprog@d4fe8cd8-f54c-11dd-8c4e-4bbb75a408b7"
]
| [
[
[
1,
99
]
]
]
|
a45b308661394d6e4f45fbfebff1367f5179869f | 4b0f51aeecddecf3f57a29ffa7a184ae48f1dc61 | /CleanProject/ParticleUniverse/include/ParticleAffectors/ParticleUniverseLinearForceAffector.h | 1c73e5e9616625967737abde6033628937273730 | []
| no_license | bahao247/apeengine2 | 56560dbf6d262364fbc0f9f96ba4231e5e4ed301 | f2617b2a42bdf2907c6d56e334c0d027fb62062d | refs/heads/master | 2021-01-10T14:04:02.319337 | 2009-08-26T08:23:33 | 2009-08-26T08:23:33 | 45,979,392 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,532 | h | /*
-----------------------------------------------------------------------------
This source file is part of the Particle Universe product.
Copyright (c) 2006-2008 Henry van Merode
Usage of this program is free for non-commercial use and licensed under the
the terms of the GNU Lesser General Public License.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt.
-----------------------------------------------------------------------------
*/
#ifndef __PU_LINEAR_FORCE_AFFECTOR_H__
#define __PU_LINEAR_FORCE_AFFECTOR_H__
#include "ParticleUniversePrerequisites.h"
#include "ParticleUniverseForceAffector.h"
namespace ParticleUniverse
{
/** Adds a force to particles.
*/
class _ParticleUniverseExport LinearForceAffector : public ForceAffector
{
public:
LinearForceAffector(void) :
ForceAffector()
{
mAffectorType = "LinearForce";
};
virtual ~LinearForceAffector(void) {};
/**
*/
virtual void copyAttributesTo (ParticleAffector* affector);
/**
*/
virtual void _preProcessParticles(ParticleTechnique* particleTechnique, Ogre::Real timeElapsed);
/**
*/
virtual void _affect(ParticleTechnique* particleTechnique, Particle* particle, Ogre::Real timeElapsed);
protected:
};
}
#endif
| [
"pablosn@06488772-1f9a-11de-8b5c-13accb87f508"
]
| [
[
[
1,
53
]
]
]
|
a33efe49959854a4939d410c0126a7393abb780c | 011359e589f99ae5fe8271962d447165e9ff7768 | /src/interface/Xbox360/Splash.cpp | 2e95039ef5ababc5516af1f2176b653b4ae4e397 | []
| no_license | PS3emulators/fba-next-slim | 4c753375fd68863c53830bb367c61737393f9777 | d082dea48c378bddd5e2a686fe8c19beb06db8e1 | refs/heads/master | 2021-01-17T23:05:29.479865 | 2011-12-01T18:16:02 | 2011-12-01T18:16:02 | 2,899,840 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 474 | cpp |
#include "burner.h"
#include "splash.h"
extern BOOL IsCurrentlyInGame;
HRESULT CSplashScene::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
{
GetChildById( L"XuiButtonContinue", &m_Continue);
return S_OK;
}
HRESULT CSplashScene::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
{
if ( hObjPressed == m_Continue)
{
IsCurrentlyInGame = true;
bHandled = TRUE;
return S_OK;
}
} | [
"[email protected]"
]
| [
[
[
1,
32
]
]
]
|
a432e19b29f6793de260565d2b42b4e2e7090e8d | 7575692fd3800ec48e7c941cdd40210d02ca96d0 | /advanced-cpp-pa1/advanced-cpp-pa1/intArray_t.cpp | 38601f70be0f26759e668a2499c51216d1e7c6f7 | []
| no_license | husamMaruf/advanced-programming-2011 | bf577a8cc51d53599ed032c22ae31fc15db217fb | db285ae560495bd051400f0e372a2eec2434afe1 | refs/heads/master | 2021-01-10T10:12:46.760433 | 2011-05-21T17:00:12 | 2011-05-21T17:00:12 | 36,380,809 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,543 | cpp | #include "stdafx.h"
#include "intArray_t.h"
using namespace std;
intArray_t::intArray_t() {
intArray = new int*[CAPACITY_EXPAND_FACTOR];
cap = CAPACITY_EXPAND_FACTOR;
length = 0;
}
intArray_t::intArray_t(const int& initCapacity) {
intArray = new int*[initCapacity];
cap = initCapacity;
length = 0;
}
intArray_t::~intArray_t() {
delete[] intArray;
}
void intArray_t::expand(const int& addedCapacity) {
cap += addedCapacity;
int** newIntArray = new int*[cap];
for (int i=0; i<length; i++) {
newIntArray[i] = intArray[i];
}
delete[] intArray;
intArray = newIntArray;
}
void intArray_t::insert(int* element) {
if (length == cap) {
expand(CAPACITY_EXPAND_FACTOR);
}
intArray[length] = element;
length++;
}
int intArray_t::append(const int& index, int* element) {
return addElement(index, element, false);
}
int intArray_t::prepend(const int& index, int* element) {
return addElement(index, element, true);
}
// helper function for append and prepend (array has to contains at least 1 element)
int intArray_t::addElement(const int& index, int* element, bool isPrepend) {
if (index < 0 || index > length-1) {
return 0;
}
if (length == cap) {
expand(CAPACITY_EXPAND_FACTOR);
}
int location = isPrepend ? index : index + 1;
for (int i=length-1; i>=location; i--) {
intArray[i+1] = intArray[i];
}
intArray[location] = element;
length += 1;
return 1;
}
int* intArray_t::find(const int& value) const {
for (int i=0; i<length; i++) {
if (*intArray[i] == value) {
return intArray[i];
}
}
return 0;
}
int* intArray_t::remove(const int& value) {
int i;
for (i=0; i < length && *(intArray[i]) != value; i++);
if (i == length) return NULL;
int* element = intArray[i];
for (; i+1 < length; i++) {
intArray[i] = intArray[i+1];
}
length--;
return element;
}
void intArray_t::removeAll() {
length = 0;
}
int intArray_t::removeAndDelete(const int& value) {
int* element = remove(value);
if (element) {
delete element;
return 1;
}
return 0;
}
void intArray_t::removeAndDeleteAll() {
for (int i=0; i < length; i++) {
delete intArray[i];
}
length = 0;
}
ostream& intArray_t::printToStream(ostream& os) const {
os << "[";
if (length > 0) {
os << *intArray[0];
for (int i=1; i<length; i++) {
os << ", " << *intArray[i];
}
}
os << "]";
return os;
}
ostream &operator<<(ostream& os, const intArray_t& intArray) {
return intArray.printToStream(os);
} | [
"[email protected]",
"dankilman@a7c0e201-94a5-d3f3-62b2-47f0ba67a830"
]
| [
[
[
1,
1
],
[
4,
5
],
[
11,
13
],
[
18,
22
],
[
30,
40
],
[
44,
44
],
[
47,
47
],
[
49,
49
],
[
64,
65
],
[
72,
72
],
[
74,
105
]
],
[
[
2,
3
],
[
6,
10
],
[
14,
17
],
[
23,
29
],
[
41,
43
],
[
45,
46
],
[
48,
48
],
[
50,
63
],
[
66,
71
],
[
73,
73
],
[
106,
120
]
]
]
|
6066581e8d77e2a5e409d4777df7de57dec925f9 | 138a353006eb1376668037fcdfbafc05450aa413 | /source/ogre/OgreNewt/boost/mpl/map/aux_/empty_impl.hpp | bc277256e125f664faaacf3f1caa870c5d62f631 | []
| no_license | sonicma7/choreopower | 107ed0a5f2eb5fa9e47378702469b77554e44746 | 1480a8f9512531665695b46dcfdde3f689888053 | refs/heads/master | 2020-05-16T20:53:11.590126 | 2009-11-18T03:10:12 | 2009-11-18T03:10:12 | 32,246,184 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 889 | hpp |
#ifndef BOOST_MPL_MAP_AUX_EMPTY_IMPL_HPP_INCLUDED
#define BOOST_MPL_MAP_AUX_EMPTY_IMPL_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2003-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Source: /cvsroot/ogre/ogreaddons/ogrenewt/OgreNewt_Main/inc/boost/mpl/map/aux_/empty_impl.hpp,v $
// $Date: 2006/04/17 23:49:40 $
// $Revision: 1.1 $
#include <boost/mpl/empty_fwd.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/map/aux_/tag.hpp>
namespace boost { namespace mpl {
template<>
struct empty_impl< aux::map_tag >
{
template< typename Map > struct apply
: not_< typename Map::size >
{
};
};
}}
#endif // BOOST_MPL_MAP_AUX_EMPTY_IMPL_HPP_INCLUDED
| [
"Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e"
]
| [
[
[
1,
34
]
]
]
|
569a258360a44119c8a220af74b21321c4e4ba9f | 9f00cc73bdc643215425e6bc43ea9c6ef3094d39 | /OOP/Project-Lines/OrangeRedBall.h | ad4b2781564c21b009184666967ea81449c2d109 | []
| no_license | AndreyShamis/oopos | c0700e1d9d889655a52ad2bc58731934e968b1dd | 0114233944c4724f242fd38ac443a925faf81762 | refs/heads/master | 2021-01-25T04:01:48.005423 | 2011-07-16T14:23:12 | 2011-07-16T14:23:12 | 32,789,875 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 252 | h | #pragma once
#include "OrangeBall.h"
#include "RedBall.h"
class OrangeRedBall : public OrangeBall, public RedBall
{
public:
OrangeRedBall(const float &X,const float &Y, int natuX, int natuY);
OrangeRedBall(){;};
~OrangeRedBall(void);
};
| [
"[email protected]@c8aee422-7d7c-7b79-c2f1-0e09d0793d10"
]
| [
[
[
1,
11
]
]
]
|
2362fa79305abb333aaec9bd5debf1421adc7c68 | 8bdca3c7a80b5e92000f5a49af50c3565df210bf | /MarioBros/MarioBros/Sprite.cpp | 5a6add210b003b5b70eb2b1633fa344bccbfc3c6 | []
| no_license | NguyenMinhTri/mario-directx-laptringgame2d | d8e5bffd78ea321a0d51980ea4e72675390ce0c1 | 28becda2fbfb13a8c04358a50ce2f1f7b23db247 | refs/heads/master | 2021-01-10T15:52:48.275384 | 2011-11-29T03:34:06 | 2011-11-29T03:34:06 | 44,036,200 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,414 | cpp | #include "Sprite.h"
#include "Graphic.h"
#include "Animation.h"
Sprite::Sprite(){};
Sprite::Sprite(Graphic* g,char* path)
{
spriteHandler=g->spriteDX;
D3DXIMAGE_INFO imageInfo;
D3DXGetImageInfoFromFile(path,&imageInfo);
width=imageInfo.Width;
height=imageInfo.Height;
D3DXGetImageInfoFromFile(path,&imageInfo);
D3DXCreateTextureFromFileEx(g->device,
path,
imageInfo.Width,
imageInfo.Height,
1, //Mipmap level
D3DPOOL_DEFAULT,
D3DFMT_UNKNOWN,
D3DPOOL_DEFAULT,
D3DX_DEFAULT,
D3DX_DEFAULT,
D3DCOLOR_XRGB(255,0,255),
&imageInfo,
NULL,
&image);
}
void Sprite::Draw(int x,int y, float xScaleRatio, float yScaleRatio,D3DXVECTOR2 vRotatteCenter,float angle,D3DCOLOR color,RECT rSrc,float deep)
{
D3DXMATRIX mTransform;
D3DXMatrixTransformation2D(&mTransform,NULL,0,&D3DXVECTOR2(xScaleRatio,yScaleRatio),&vRotatteCenter,angle,&D3DXVECTOR2((float)x,(float)y));
spriteHandler->SetTransform(&mTransform);
spriteHandler->Draw(image,&rSrc,NULL,&D3DXVECTOR3(0,0,deep),color);
}
void Sprite::Draw(int x,int y, float xScaleRatio, float yScaleRatio,float deep)
{
D3DXMATRIX mTransform;
D3DXMatrixTransformation2D(&mTransform,NULL,0,&D3DXVECTOR2(xScaleRatio,yScaleRatio),&D3DXVECTOR2(0,0),0,&D3DXVECTOR2((float)x,(float)y));
spriteHandler->SetTransform(&mTransform);
spriteHandler->Draw(image,NULL,NULL,&D3DXVECTOR3(0,0,deep),D3DCOLOR_XRGB(255,255,255));
}
void Sprite::Draw(int x,int y, float xScaleRatio,float yScaleRatio, RECT rSrc,float deep)
{
D3DXMATRIX mTransform;
D3DXMatrixTransformation2D(&mTransform,NULL,0,&D3DXVECTOR2(xScaleRatio,yScaleRatio),&D3DXVECTOR2(0,0),0,&D3DXVECTOR2((float)x,(float)y));
spriteHandler->SetTransform(&mTransform);
spriteHandler->Draw(image,&rSrc,NULL,&D3DXVECTOR3(0,0,deep),D3DCOLOR_XRGB(255,255,255));
}
void Sprite::Draw(int x,int y, float xScaleRatio, float yScaleRatio,char numImage,char frameIndex,float deep)
{
RECT rectSource;
rectSource.left=width/numImage*frameIndex;
rectSource.top=0;
rectSource.right=rectSource.left+width/numImage;
rectSource.bottom=height;
D3DXMATRIX mTransform;
D3DXMatrixTransformation2D(&mTransform,NULL,0,&D3DXVECTOR2(xScaleRatio,yScaleRatio),&D3DXVECTOR2(0,0),0,&D3DXVECTOR2((float)x,(float)y));
spriteHandler->SetTransform(&mTransform);
spriteHandler->Draw(image,&rectSource,NULL,&D3DXVECTOR3(0,0,deep),D3DCOLOR_XRGB(255,255,255));
} | [
"[email protected]"
]
| [
[
[
1,
64
]
]
]
|
da3d49f01be0784728f868d546e8ee59e25179ce | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SEFoundation/SESceneGraph/SEParticles.cpp | fea36ef31251c76ee1a7657f653bfaf3daf438ca | []
| no_license | pizibing/swingengine | d8d9208c00ec2944817e1aab51287a3c38103bea | e7109d7b3e28c4421c173712eaf872771550669e | refs/heads/master | 2021-01-16T18:29:10.689858 | 2011-06-23T04:27:46 | 2011-06-23T04:27:46 | 33,969,301 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 10,185 | cpp | // Swing Engine Version 1 Source Code
// Most of techniques in the engine are mainly based on David Eberly's
// Wild Magic 4 open-source code.The author of Swing Engine learned a lot
// from Eberly's experience of architecture and algorithm.
// Several sub-systems are totally new,and others are re-implimented or
// re-organized based on Wild Magic 4's sub-systems.
// Copyright (c) 2007-2010. All Rights Reserved
//
// Eberly's permission:
// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or (at
// your option) any later version. The license is available for reading at
// the location:
// http://www.gnu.org/copyleft/lgpl.html
#include "SEFoundationPCH.h"
#include "SEParticles.h"
#include "SECamera.h"
#include "SECuller.h"
#include "SELight.h"
#include "SEVector2Array.h"
using namespace Swing;
SE_IMPLEMENT_RTTI(Swing, SEParticles, SETriMesh);
SE_IMPLEMENT_STREAM(SEParticles);
//SE_REGISTER_STREAM(SEParticles);
//----------------------------------------------------------------------------
SEParticles::SEParticles(const SEAttributes& rAttr, SEVector3fArray*
pLocations, SEFloatArray* pSizes)
:
Locations(pLocations),
Sizes(pSizes)
{
// 分配模型空间顶点存储,每个粒子使用4个顶点构成一个quad广告牌.
int iLCount = Locations->GetCount();
int iVCount = 4*iLCount;
VBuffer = SE_NEW SEVertexBuffer(rAttr, iVCount);
// 为这些quad广告牌设置2D纹理坐标.
int i, j;
for( int iUnit = 0; iUnit < rAttr.GetMaxTCoords(); iUnit++ )
{
if( rAttr.HasTCoord(iUnit) && rAttr.GetTCoordChannels(iUnit) == 2 )
{
for( i = 0, j = 0; i < iLCount; i++ )
{
VBuffer->TCoord2(iUnit, j++) = SEVector2f(0.0f, 1.0f);
VBuffer->TCoord2(iUnit, j++) = SEVector2f(0.0f, 0.0f);
VBuffer->TCoord2(iUnit, j++) = SEVector2f(1.0f, 0.0f);
VBuffer->TCoord2(iUnit, j++) = SEVector2f(1.0f, 1.0f);
}
}
}
// 为这些quad广告牌创建IB.
int iICount = 6*iLCount;
IBuffer = SE_NEW SEIndexBuffer(iICount);
int* aiIndex = IBuffer->GetData();
for( i = 0, j = 0; i < iLCount; i++ )
{
int iFI = 4*i, iFIp1 = iFI+1, iFIp2 = iFI+2, iFIp3 = iFI+3;
aiIndex[j++] = iFI;
aiIndex[j++] = iFIp1;
aiIndex[j++] = iFIp3;
aiIndex[j++] = iFIp1;
aiIndex[j++] = iFIp2;
aiIndex[j++] = iFIp3;
}
// 根据全部粒子的模型空间位置计算出一个包含这些位置的BV.
ModelBound->ComputeFromData(Locations);
SizeAdjust = 1.0f;
m_iActiveCount = iLCount;
}
//----------------------------------------------------------------------------
SEParticles::SEParticles()
{
SizeAdjust = 0.0f;
m_iActiveCount = 0;
}
//----------------------------------------------------------------------------
SEParticles::~SEParticles()
{
}
//----------------------------------------------------------------------------
void SEParticles::SetActiveCount(int iActiveCount)
{
int iLCount = Locations->GetCount();
if( 0 <= iActiveCount && iActiveCount <= iLCount )
{
m_iActiveCount = iActiveCount;
}
else
{
m_iActiveCount = iLCount;
}
IBuffer->SetIndexCount(6*m_iActiveCount);
IBuffer->Release();
int iFourActiveCount = 4*m_iActiveCount;
VBuffer->SetVertexCount(iFourActiveCount);
VBuffer->Release();
}
//----------------------------------------------------------------------------
void SEParticles::GenerateParticles(const SECamera* pCamera)
{
int i, j;
// 把camera的轴向量变换到粒子的模型空间.
SEVector3f vec3fUpR = pCamera->GetUVector() + pCamera->GetRVector();
vec3fUpR = World.GetRotate() * vec3fUpR;
SEVector3f vec3fUmR = pCamera->GetUVector() - pCamera->GetRVector();
vec3fUmR = World.GetRotate() * vec3fUmR;
// 所有法线向量指向观察者.
if( VBuffer->GetAttributes().HasNormal() )
{
SEVector3f vec3fDir = World.GetRotate()*(-pCamera->GetDVector());
for( j = 0; j < 4*m_iActiveCount; j++ )
{
VBuffer->Normal3(j) = vec3fDir;
}
}
// 生成粒子,每个都是由两个三角形组成的quad.
SEVector3f* aLocation = Locations->GetData();
float* afSize = Sizes->GetData();
for( i = 0, j = 0; i < m_iActiveCount; i++ )
{
SEVector3f& rCenter = aLocation[i];
float fTrueSize = SizeAdjust*afSize[i];
SEVector3f vec3fScaledUpR = fTrueSize*vec3fUpR;
SEVector3f vec3fScaledUmR = fTrueSize*vec3fUmR;
VBuffer->Position3(j++) = rCenter - vec3fScaledUpR;
VBuffer->Position3(j++) = rCenter + vec3fScaledUmR;
VBuffer->Position3(j++) = rCenter + vec3fScaledUpR;
VBuffer->Position3(j++) = rCenter - vec3fScaledUmR;
}
UpdateMS(true);
}
//----------------------------------------------------------------------------
void SEParticles::GetUnculledSet(SECuller& rCuller, bool bNoCull)
{
GenerateParticles(rCuller.GetCamera());
SETriMesh::GetUnculledSet(rCuller, bNoCull);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// name and unique id
//----------------------------------------------------------------------------
SEObject* SEParticles::GetObjectByName(const std::string& rName)
{
SEObject* pFound = SETriMesh::GetObjectByName(rName);
if( pFound )
{
return pFound;
}
if( Locations )
{
pFound = Locations->GetObjectByName(rName);
if( pFound )
{
return pFound;
}
}
if( Sizes )
{
pFound = Sizes->GetObjectByName(rName);
if( pFound )
{
return pFound;
}
}
return 0;
}
//----------------------------------------------------------------------------
void SEParticles::GetAllObjectsByName(const std::string& rName,
std::vector<SEObject*>& rObjects)
{
SETriMesh::GetAllObjectsByName(rName, rObjects);
if( Locations )
{
Locations->GetAllObjectsByName(rName, rObjects);
}
if( Sizes )
{
Sizes->GetAllObjectsByName(rName, rObjects);
}
}
//----------------------------------------------------------------------------
SEObject* SEParticles::GetObjectByID(unsigned int uiID)
{
SEObject* pFound = SETriMesh::GetObjectByID(uiID);
if( pFound )
{
return pFound;
}
if( Locations )
{
pFound = Locations->GetObjectByID(uiID);
if( pFound )
{
return pFound;
}
}
if( Sizes )
{
pFound = Sizes->GetObjectByID(uiID);
if( pFound )
{
return pFound;
}
}
return 0;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// streaming
//----------------------------------------------------------------------------
void SEParticles::Load(SEStream& rStream, SEStream::SELink* pLink)
{
SE_BEGIN_DEBUG_STREAM_LOAD;
SETriMesh::Load(rStream, pLink);
// native data
rStream.Read(SizeAdjust);
rStream.Read(m_iActiveCount);
// link data
SEObject* pObject;
rStream.Read(pObject); // Locations
pLink->Add(pObject);
rStream.Read(pObject); // Sizes
pLink->Add(pObject);
SE_END_DEBUG_STREAM_LOAD(SEParticles);
}
//----------------------------------------------------------------------------
void SEParticles::Link(SEStream& rStream, SEStream::SELink* pLink)
{
SETriMesh::Link(rStream, pLink);
SEObject* pLinkID = pLink->GetLinkID();
Locations = (SEVector3fArray*)rStream.GetFromMap(pLinkID);
pLinkID = pLink->GetLinkID();
Sizes = (SEFloatArray*)rStream.GetFromMap(pLinkID);
}
//----------------------------------------------------------------------------
bool SEParticles::Register(SEStream& rStream) const
{
if( !SETriMesh::Register(rStream) )
{
return false;
}
if( Locations )
{
Locations->Register(rStream);
}
if( Sizes )
{
Sizes->Register(rStream);
}
return true;
}
//----------------------------------------------------------------------------
void SEParticles::Save(SEStream& rStream) const
{
SE_BEGIN_DEBUG_STREAM_SAVE;
SETriMesh::Save(rStream);
// native data
rStream.Write(SizeAdjust);
rStream.Write(m_iActiveCount);
// link data
rStream.Write(Locations);
rStream.Write(Sizes);
SE_END_DEBUG_STREAM_SAVE(SEParticles);
}
//----------------------------------------------------------------------------
int SEParticles::GetDiskUsed(const SEStreamVersion& rVersion) const
{
return SETriMesh::GetDiskUsed(rVersion) +
sizeof(SizeAdjust) +
sizeof(m_iActiveCount) +
SE_PTRSIZE(Locations) +
SE_PTRSIZE(Sizes);
}
//----------------------------------------------------------------------------
SEStringTree* SEParticles::SaveStrings(const char*)
{
SEStringTree* pTree = SE_NEW SEStringTree;
// strings
pTree->Append(Format(&TYPE, GetName().c_str()));
pTree->Append(Format("size adjust =", SizeAdjust));
pTree->Append(Format("active count =", m_iActiveCount));
// children
pTree->Append(SETriMesh::SaveStrings());
pTree->Append(Locations->SaveStrings());
pTree->Append(Sizes->SaveStrings());
return pTree;
}
//----------------------------------------------------------------------------
| [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
]
| [
[
[
1,
338
]
]
]
|
baef55399144baa0d3b3855b087ef95fb5796ac1 | 22d9640edca14b31280fae414f188739a82733e4 | /Code/VTK/include/vtk-5.2/vtkDataRepresentation.h | 00e246a4006fb6b4f24a7a6ea95cc86d29416893 | []
| no_license | tack1/Casam | ad0a98febdb566c411adfe6983fcf63442b5eed5 | 3914de9d34c830d4a23a785768579bea80342f41 | refs/heads/master | 2020-04-06T03:45:40.734355 | 2009-06-10T14:54:07 | 2009-06-10T14:54:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,710 | h | /*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkDataRepresentation.h,v $
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/
// .NAME vtkDataRepresentation - The superclass for all representations
//
// .SECTION Description
// vtkDataRepresentation the superclass for representations of data objects.
// This class itself may be instantiated and used as a representation
// that simply holds a connection to a pipeline.
//
// If there are multiple representations present in a view, you should use
// a subclass of vtkDataRepresentation. The representation is
// responsible for taking the input pipeline connection and converting it
// to an object usable by a view. In the most common case, the representation
// will contain the pipeline necessary to convert a data object into an actor
// or set of actors.
//
// The representation has a concept of a selection. If the user performs a
// selection operation on the view, the view forwards this on to its
// representations. The representation is responsible for displaying that
// selection in an appropriate way.
//
// Representation selections may also be linked. The representation shares
// the selection by converting it into a view-independent format, then
// setting the selection on its vtkSelectionLink. Other representations
// sharing the same selection link instance will get the same selection
// from the selection link when the view is updated. The application is
// responsible for linking representations as appropriate by setting the
// same vtkSelectionLink on each linked representation.
#ifndef __vtkDataRepresentation_h
#define __vtkDataRepresentation_h
#include "vtkObject.h"
class vtkAlgorithmOutput;
class vtkDataObject;
class vtkSelection;
class vtkSelectionLink;
class vtkView;
class VTK_VIEWS_EXPORT vtkDataRepresentation : public vtkObject
{
public:
static vtkDataRepresentation *New();
vtkTypeRevisionMacro(vtkDataRepresentation, vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// A convenience method that calls SetInputConnection on the producer's
// connection.
void SetInput(vtkDataObject* input);
// Description:
// Sets the input pipeline connection to this representation.
// This method should be overridden by subclasses to connect to the
// internal pipeline.
virtual void SetInputConnection(vtkAlgorithmOutput* conn);
vtkGetObjectMacro(InputConnection, vtkAlgorithmOutput);
// Description:
// Handle a selection a view. Subclasses should not generally override this.
// This function calls ConvertSelection() to (possibly) convert the selection
// into something appropriate for linked representations.
// This function then calls UpdateSelection() with the result of the
// conversion.
void Select(vtkView* view, vtkSelection* selection);
// Description:
// Copies the selection into the representation's linked selection
// and triggers a SelectionChanged event.
void UpdateSelection(vtkSelection* selection);
// Description:
// The selection linking object.
// Set the same selection link on multiple representations to link views.
// Subclasses should override SetSelectionLink to additionally connect
// the selection link into the internal selection pipeline.
vtkGetObjectMacro(SelectionLink, vtkSelectionLink);
virtual void SetSelectionLink(vtkSelectionLink* link);
protected:
vtkDataRepresentation();
~vtkDataRepresentation();
// Decription:
// Adds the representation to the view. This is called from
// vtkView::AddRepresentation(). Subclasses should override this method.
virtual bool AddToView(vtkView* vtkNotUsed(view)) { return true; }
// Decription:
// Removes the representation to the view. This is called from
// vtkView::RemoveRepresentation(). Subclasses should override this method.
virtual bool RemoveFromView(vtkView* vtkNotUsed(view)) { return true; }
// Description:
// Convert the selection to a type appropriate for sharing with other
// representations through vtkSelectionLink, possibly using the view.
// For the superclass, we just return the same selection.
// Subclasses may do something more fancy, like convert the selection
// from a frustrum to a list of pedigree ids. If the selection cannot
// be applied to this representation, return NULL.
virtual vtkSelection* ConvertSelection(vtkView* view, vtkSelection* selection);
// The input connection.
vtkAlgorithmOutput* InputConnection;
// The linked selection.
vtkSelectionLink* SelectionLink;
//BTX
friend class vtkView;
//ETX
private:
vtkDataRepresentation(const vtkDataRepresentation&); // Not implemented.
void operator=(const vtkDataRepresentation&); // Not implemented.
};
#endif
| [
"nnsmit@9b22acdf-97ab-464f-81e2-08fcc4a6931f"
]
| [
[
[
1,
136
]
]
]
|
e3bd95d33a037166381e1faf6b97821f4f5795d8 | f9001b4fb694d0997597a2ed74c050c8c558752a | /src/tooltip.h | b7b785eb5345101868ca603d12864b1befc3d338 | []
| no_license | dex/voronoi | 77c382f80a130c7239c96016b0d914bb15926fb9 | 878d9e6c645e6347698cb011b149491c12c46081 | refs/heads/master | 2016-09-06T19:13:28.140349 | 2010-09-17T08:52:33 | 2010-09-17T08:52:33 | 3,948,158 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 214 | h | #ifndef TOOLTIP_H
#define TOOLTIP_H
#include <qtooltip.h>
class DynamicTip : public QToolTip
{
public:
DynamicTip(QWidget *parent);
protected:
void maybeTip(const QPoint &);
};
#endif
| [
"[email protected]"
]
| [
[
[
1,
15
]
]
]
|
5627ae2157bd513a4de826248a4ddcba1c8fcb27 | 5155ce0bfd77ae28dbf671deef6692220ac71aba | /main/src/dll/config.cpp | 2b5eb9d07e6ffa6061931eff4615aac8ee4da940 | []
| no_license | OldRepoPreservation/taksi | 1ffcfbb0a100520ba4a050f571a15389ee9e9098 | 631c9080c14cf80d028b841ba41f8e884d252c8a | refs/heads/master | 2021-07-08T16:26:24.168833 | 2011-03-13T22:00:57 | 2011-03-13T22:00:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 22,667 | cpp | //
// config.cpp
//
#include "../stdafx.h"
#include "TaksiDll.h"
#include <ctype.h> // isspace()
#include "../common/CWaveDevice.h"
#ifndef __PLACEMENT_NEW_INLINE
#define __PLACEMENT_NEW_INLINE
inline void*__cdecl operator new(size_t, void*_P)
{return (_P); }
#if _MSC_VER >= 1200 // VS6
inline void __cdecl operator delete(void*, void*)
{return; }
#endif
#endif
const char* CTaksiConfig::sm_Props[TAKSI_CFGPROP_QTY+1] =
{
#define ConfigProp(a,b,c) #a,
#include "../ConfigProps.tbl"
#undef ConfigProp
NULL,
};
static bool Str_GetQuoted( TCHAR* pszDest, int iLenMax, const char* pszSrc )
{
// NOTE: Quoted string might contain UTF8 chars? so might have protected '"' ??
char* pszStartQuote = strchr( const_cast<char*>(pszSrc), '\"');
if (pszStartQuote == NULL)
return false;
char* pszEndQuote = strchr( pszStartQuote + 1, '\"' );
if (pszEndQuote == NULL)
return false;
int iLen = (int)( pszEndQuote - pszStartQuote ) - 1;
if ( iLen > iLenMax-1 )
iLen = iLenMax-1;
#ifdef _UNICODE
// convert to unicode.
iLen = ::MultiByteToWideChar( CP_UTF8, 0, pszStartQuote + 1, iLen, pszDest, iLen );
#else
strncpy( pszDest, pszStartQuote + 1, iLen );
#endif
pszDest[iLen] = '\0';
return true;
}
static int Str_SetQuoted( char* pszDest, int iLenMax, const TCHAR* pszSrc )
{
#ifdef _UNICODE
// convert from unicode.
return _snprintf(pszDest, iLenMax, "\"%S\"", pszSrc);
#else
return _snprintf(pszDest, iLenMax, "\"%s\"", pszSrc);
#endif
}
int Str_MakeFilePath( TCHAR* pszPath, int iMaxCount, const TCHAR* pszDir, const TCHAR* pszName )
{
return _sntprintf( pszPath, iMaxCount-1,
_T("%s%s"),
pszDir, pszName );
}
//*****************************************************
const char* CTaksiConfigCustom::sm_Props[TAKSI_CUSTOM_QTY+1] = // TAKSI_CUSTOM_TYPE
{
"FrameRate",
"FrameWeight",
"Pattern", // TAKSI_CUSTOM_Pattern
NULL,
};
int CTaksiConfigCustom::PropGet( int eProp, char* pszValue, int iSizeMax ) const
{
// TAKSI_CUSTOM_TYPE
switch ( eProp )
{
case TAKSI_CUSTOM_FrameRate:
return _snprintf(pszValue, iSizeMax, "%g", m_fFrameRate);
case TAKSI_CUSTOM_FrameWeight:
return _snprintf(pszValue, iSizeMax, "%g", m_fFrameWeight);
case TAKSI_CUSTOM_Pattern:
return Str_SetQuoted( pszValue, iSizeMax, m_szPattern );
default:
DEBUG_ERR(("CTaksiConfigCustom::PropGet bad code %d" LOG_CR, eProp ));
ASSERT(0);
break;
}
return -1;
}
bool CTaksiConfigCustom::PropSet( int eProp, const char* pszValue )
{
// TAKSI_CUSTOM_TYPE
switch ( eProp )
{
case TAKSI_CUSTOM_FrameRate:
m_fFrameRate = (float) atof(pszValue);
break;
case TAKSI_CUSTOM_FrameWeight:
m_fFrameWeight = (float) atof(pszValue);
break;
case TAKSI_CUSTOM_Pattern:
if (! Str_GetQuoted( m_szPattern, COUNTOF(m_szPattern), pszValue ))
return false;
_tcslwr( m_szPattern );
break;
default:
DEBUG_ERR(("CTaksiConfigCustom::PropSet bad code %d" LOG_CR, eProp ));
ASSERT(0);
return false;
}
#if 0 // def _DEBUG
char szTmp[_MAX_PATH*2];
if ( PropGet(eProp,szTmp,sizeof(szTmp)) < 0 )
{
strcpy( szTmp, "<NA>" );
}
LOG_MSG(( "PropSet[%s] '%s'='%s'" LOG_CR, m_szAppId, sm_Props[eProp], szTmp ));
#endif
return true;
}
//*****************************************************************************
void CTaksiConfigData::InitConfig()
{
m_szCaptureDir[0] = '\0';
m_bDebugLog = false;
m_szFileNamePostfix[0] = '\0';
// Video Format
m_fFrameRateTarget=10;
m_VideoCodec.InitCodec();
m_bVideoCodecMsg = false;
m_bVideoHalfSize = true;
m_AudioFormat.InitFormatEmpty();
m_iAudioDevice = WAVE_DEVICE_NONE;
m_wHotKey[TAKSI_HOTKEY_ConfigOpen]=0x0;
m_wHotKey[TAKSI_HOTKEY_HookModeToggle]=0x75;
m_wHotKey[TAKSI_HOTKEY_IndicatorToggle]=0x74;
m_wHotKey[TAKSI_HOTKEY_RecordBegin]=0x7b;
m_wHotKey[TAKSI_HOTKEY_RecordPause]=0;
m_wHotKey[TAKSI_HOTKEY_RecordStop]=0x7b;
m_wHotKey[TAKSI_HOTKEY_Screenshot]=0x77;
m_wHotKey[TAKSI_HOTKEY_SmallScreenshot]=0x76;
m_bUseDirectInput = true;
m_bUseKeyboard = true;
memset( m_abUseGAPI, true, sizeof(m_abUseGAPI)); // set all to true.
m_abUseGAPI[TAKSI_GAPI_DESKTOP] = false;
m_bGDIFrame = true;
m_bUseOverheadCompensation = false;
m_bGDICursor = false;
lstrcpy( m_szImageFormatExt, _T("png") ); // vs png,jpeg or bmp
m_bShowIndicator = true;
m_ptMasterWindow.x = 0;
m_ptMasterWindow.y = 0;
m_bMasterTopMost = false;
DEBUG_MSG(("CTaksiConfig::InitConfig" LOG_CR ));
}
void CTaksiConfigData::CopyConfig( const CTaksiConfigData& config )
{
_tcsncpy( m_szCaptureDir, config.m_szCaptureDir, COUNTOF(m_szCaptureDir)-1);
m_bDebugLog = config.m_bDebugLog;
_tcsncpy( m_szFileNamePostfix, config.m_szFileNamePostfix, COUNTOF(m_szFileNamePostfix)-1 );
m_fFrameRateTarget = config.m_fFrameRateTarget;
m_VideoCodec.CopyCodec( config.m_VideoCodec );
m_bVideoHalfSize = config.m_bVideoHalfSize;
m_bVideoCodecMsg = config.m_bVideoCodecMsg;
m_iAudioDevice = config.m_iAudioDevice; // audio input device. WAVE_MAPPER = -1, WAVE_DEVICE_NONE = -2. CWaveRecorder
m_AudioFormat.SetFormat( config.m_AudioFormat );
memcpy( m_wHotKey, config.m_wHotKey, sizeof(m_wHotKey));
m_bUseDirectInput = config.m_bUseDirectInput;
m_bUseKeyboard = config.m_bUseKeyboard;
memcpy( m_abUseGAPI, config.m_abUseGAPI, sizeof(m_abUseGAPI)); // hook GDI mode at all?
m_bGDIFrame = config.m_bGDIFrame; // record the frame of GDI windows or not ?
m_bUseOverheadCompensation = config.m_bUseOverheadCompensation;
m_bGDICursor = config.m_bGDICursor;
// CAN NOT be set from CGuiConfig directly
m_bShowIndicator = config.m_bShowIndicator;
m_ptMasterWindow = config.m_ptMasterWindow; // previous position of the master EXE window.
m_bMasterTopMost = config.m_bMasterTopMost;
// CANT COPY m_pCustomList for interproces access ??
DEBUG_MSG(("CTaksiConfig::CopyConfig '%s'" LOG_CR, m_szCaptureDir ));
}
bool CTaksiConfigData::SetHotKey( TAKSI_HOTKEY_TYPE eHotKey, WORD wHotKey )
{
// Signal to unhook from IDirect3DDeviceN methods
// wHotKey = LOBYTE(virtual key code) + HIBYTE(HOTKEYF_ALT)
if ( eHotKey < 0 || eHotKey >= TAKSI_HOTKEY_QTY )
return false;
if ( m_wHotKey[eHotKey] == wHotKey )
return false;
m_wHotKey[eHotKey] = wHotKey;
return true;
}
WORD CTaksiConfigData::GetHotKey( TAKSI_HOTKEY_TYPE eHotKey ) const
{
// wHotKey = LOBYTE(virtual key code) + HIBYTE(HOTKEYF_ALT)
if ( eHotKey < 0 || eHotKey >= TAKSI_HOTKEY_QTY )
return 0;
return m_wHotKey[eHotKey];
}
HRESULT CTaksiConfigData::FixCaptureDir()
{
// RETURN:
// <0 = bad name.
// S_FALSE = no change.
// S_OK = changed!
int iLen = lstrlen(m_szCaptureDir);
if (iLen<=0)
{
// If capture directory is still unknown at this point
// set it to the current APP directory then.
if ( ::GetModuleFileName(NULL,m_szCaptureDir, sizeof(m_szCaptureDir)-1 ) <= 0 )
{
return HRes_GetLastErrorDef( HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND));
}
// strip off file name
TCHAR* pTitle = GetFileTitlePtr(m_szCaptureDir);
if(pTitle==NULL)
return HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND);
*pTitle = '\0';
return S_OK; // changed
}
// make sure it ends with backslash.
if ( ! FILE_IsDirSep( m_szCaptureDir[iLen-1] ))
{
lstrcat(m_szCaptureDir, _T("\\"));
return S_OK; // changed
}
// make sure it actually exists! try to create it if not.
HRESULT hRes = CreateDirectoryX( m_szCaptureDir );
if ( FAILED(hRes))
{
return hRes;
}
return S_FALSE; // no change.
}
//************************************************************
CTaksiConfigCustom* CTaksiConfig::CustomConfig_Alloc() // static
{
// NOTE: This should be in process shared memory ?
CTaksiConfigCustom* pConfig = (CTaksiConfigCustom*) ::HeapAlloc(
::GetProcessHeap(),
HEAP_ZERO_MEMORY, sizeof(CTaksiConfigCustom));
return new((void*) pConfig ) CTaksiConfigCustom(); // init the struct properly
}
void CTaksiConfig::CustomConfig_Delete( CTaksiConfigCustom* pConfig ) // static
{
if ( pConfig == NULL )
return;
::HeapFree( ::GetProcessHeap(), 0, pConfig);
}
CTaksiConfigCustom* CTaksiConfig::CustomConfig_FindPattern( const TCHAR* pszProcessFile ) const
{
// must always be all lower case. _tcslwr
for (CTaksiConfigCustom* p=m_pCustomList; p!=NULL; p=p->m_pNext )
{
// try to match the pattern with processfile
if ( _tcsstr(pszProcessFile, p->m_szPattern))
return p;
}
return NULL;
}
CTaksiConfigCustom* CTaksiConfig::CustomConfig_FindAppId( const TCHAR* pszAppId ) const
{
// Looks up a custom config in a list. If not found return NULL
for (CTaksiConfigCustom* p=m_pCustomList; p!=NULL; p=p->m_pNext )
{
if ( ! lstrcmp(p->m_szAppId, pszAppId))
return p;
}
return NULL;
}
CTaksiConfigCustom* CTaksiConfig::CustomConfig_Lookup( const TCHAR* pszAppId, bool bCreate )
{
// Looks up a custom config in a list. If not found, creates one
// and inserts at the beginning of the list.
//
CTaksiConfigCustom* p = CustomConfig_FindAppId(pszAppId);
if (p)
return p;
if ( ! bCreate)
return NULL;
// not found. Therefore, insert a new one
p = CustomConfig_Alloc();
if (p == NULL)
return NULL;
_tcsncpy(p->m_szAppId, pszAppId, COUNTOF(p->m_szAppId)-1);
p->m_pNext = m_pCustomList;
m_pCustomList = p;
return p;
}
void CTaksiConfig::CustomConfig_DeleteAppId(const TCHAR* pszAppId)
{
// Deletes a custom config from the list and frees its memory.
// If not found, nothing is done.
//
CTaksiConfigCustom* pPrev = NULL;
CTaksiConfigCustom* pCur = m_pCustomList;
while (pCur != NULL)
{
CTaksiConfigCustom* pNext = pCur->m_pNext;
if ( pszAppId == NULL || ! lstrcmp(pCur->m_szAppId, pszAppId))
{
if ( pPrev == NULL )
m_pCustomList = pNext;
else
pPrev->m_pNext = pNext;
CustomConfig_Delete(pCur);
}
else
{
pPrev = pCur;
}
pCur = pNext;
}
}
//************************************************************
CTaksiConfig::CTaksiConfig()
: m_pCustomList(NULL)
{
PropsInit();
InitConfig();
}
CTaksiConfig::~CTaksiConfig()
{
CustomConfig_DeleteAppId(NULL); // Free ALL memory taken by custom configs
m_VideoCodec.DestroyCodec(); // cleanup VFW resources.
}
static const char* GetBoolStr( bool bVal )
{
return bVal? "1" : "0";
}
int CTaksiConfig::PropGet( int eProp, char* pszValue, int iSizeMax ) const
{
// TAKSI_CFGPROP_TYPE
switch (eProp)
{
case TAKSI_CFGPROP_DebugLog:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_bDebugLog));
case TAKSI_CFGPROP_CaptureDir:
return Str_SetQuoted(pszValue, iSizeMax, m_szCaptureDir );
case TAKSI_CFGPROP_FileNamePostfix:
return Str_SetQuoted(pszValue, iSizeMax, m_szFileNamePostfix );
case TAKSI_CFGPROP_ImageFormatExt:
return Str_SetQuoted(pszValue, iSizeMax, m_szImageFormatExt );
case TAKSI_CFGPROP_MovieFrameRateTarget:
return _snprintf(pszValue, iSizeMax, "%g", m_fFrameRateTarget);
case TAKSI_CFGPROP_VKey_ConfigOpen:
case TAKSI_CFGPROP_VKey_HookModeToggle:
case TAKSI_CFGPROP_VKey_IndicatorToggle:
case TAKSI_CFGPROP_VKey_RecordBegin:
case TAKSI_CFGPROP_VKey_RecordPause:
case TAKSI_CFGPROP_VKey_RecordStop:
case TAKSI_CFGPROP_VKey_Screenshot:
case TAKSI_CFGPROP_VKey_SmallScreenshot:
{
int iKey = TAKSI_HOTKEY_ConfigOpen + ( eProp - TAKSI_CFGPROP_VKey_ConfigOpen );
return _snprintf(pszValue, iSizeMax, "%d", m_wHotKey[iKey] );
}
case TAKSI_CFGPROP_KeyboardUseDirectInput:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_bUseDirectInput));
case TAKSI_CFGPROP_VideoHalfSize:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_bVideoHalfSize));
case TAKSI_CFGPROP_VideoCodecMsg:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_bVideoCodecMsg));
case TAKSI_CFGPROP_VideoCodecInfo:
return m_VideoCodec.GetStr(pszValue, iSizeMax);
case TAKSI_CFGPROP_AudioFormat:
return Mem_ConvertToString( pszValue, iSizeMax, (BYTE*) m_AudioFormat.get_WF(), m_AudioFormat.get_FormatSize());
case TAKSI_CFGPROP_AudioDevice:
return _snprintf(pszValue, iSizeMax, "%d", m_iAudioDevice );
case TAKSI_CFGPROP_ShowIndicator:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_bShowIndicator));
case TAKSI_CFGPROP_PosMasterWindow:
return _snprintf(pszValue, iSizeMax, "%d,%d", m_ptMasterWindow.x, m_ptMasterWindow.y );
case TAKSI_CFGPROP_PosMasterTopMost:
return _snprintf(pszValue, iSizeMax, "%d", m_bMasterTopMost );
case TAKSI_CFGPROP_GDIFrame:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_bGDIFrame));
case TAKSI_CFGPROP_GDICursor:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_bGDICursor));
case TAKSI_CFGPROP_GDIDesktop:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_abUseGAPI[TAKSI_GAPI_DESKTOP]));
case TAKSI_CFGPROP_UseGDI:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_abUseGAPI[TAKSI_GAPI_GDI]));
case TAKSI_CFGPROP_UseOGL:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_abUseGAPI[TAKSI_GAPI_OGL]));
#ifdef USE_DIRECTX8
case TAKSI_CFGPROP_UseDX8:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_abUseGAPI[TAKSI_GAPI_DX8]));
#endif
#ifdef USE_DIRECTX9
case TAKSI_CFGPROP_UseDX9:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_abUseGAPI[TAKSI_GAPI_DX9]));
#endif
case TAKSI_CFGPROP_UseOverheadCompensation:
return _snprintf(pszValue, iSizeMax, GetBoolStr(m_bUseOverheadCompensation));
default:
DEBUG_ERR(("CTaksiConfig::PropGet bad code %d" LOG_CR, eProp ));
ASSERT(0);
break;
}
return -1;
}
static bool GetStrBool( const char* pszVal )
{
return atoi(pszVal)? true : false;
}
bool CTaksiConfig::PropSet( int eProp, const char* pszValue )
{
// TAKSI_CFGPROP_TYPE
switch (eProp)
{
case TAKSI_CFGPROP_DebugLog:
m_bDebugLog = GetStrBool(pszValue);
break;
case TAKSI_CFGPROP_CaptureDir:
if (! Str_GetQuoted( m_szCaptureDir, COUNTOF(m_szCaptureDir), pszValue))
return false;
break;
case TAKSI_CFGPROP_FileNamePostfix:
if (! Str_GetQuoted( m_szFileNamePostfix, COUNTOF(m_szFileNamePostfix), pszValue))
return false;
break;
case TAKSI_CFGPROP_ImageFormatExt:
if (! Str_GetQuoted( m_szImageFormatExt, COUNTOF(m_szImageFormatExt), pszValue))
return false;
break;
case TAKSI_CFGPROP_MovieFrameRateTarget:
m_fFrameRateTarget = (float) atof(pszValue);
break;
case TAKSI_CFGPROP_PosMasterWindow:
sscanf( pszValue, "%d,%d", &m_ptMasterWindow.x, &m_ptMasterWindow.y );
break;
case TAKSI_CFGPROP_PosMasterTopMost:
m_bMasterTopMost = GetStrBool(pszValue);
break;
case TAKSI_CFGPROP_VKey_ConfigOpen:
case TAKSI_CFGPROP_VKey_HookModeToggle:
case TAKSI_CFGPROP_VKey_IndicatorToggle:
case TAKSI_CFGPROP_VKey_RecordBegin:
case TAKSI_CFGPROP_VKey_RecordPause:
case TAKSI_CFGPROP_VKey_RecordStop:
case TAKSI_CFGPROP_VKey_Screenshot:
case TAKSI_CFGPROP_VKey_SmallScreenshot:
{
int iKey = TAKSI_HOTKEY_ConfigOpen + ( eProp - TAKSI_CFGPROP_VKey_ConfigOpen );
ASSERT( iKey >= 0 && iKey < TAKSI_HOTKEY_QTY );
char* pszEnd;
m_wHotKey[iKey] = (WORD) strtol(pszValue,&pszEnd,0);
}
break;
case TAKSI_CFGPROP_KeyboardUseDirectInput:
m_bUseDirectInput = GetStrBool(pszValue);
break;
case TAKSI_CFGPROP_VideoHalfSize:
m_bVideoHalfSize = GetStrBool(pszValue);
break;
case TAKSI_CFGPROP_VideoCodecMsg:
m_bVideoCodecMsg = GetStrBool(pszValue);
break;
case TAKSI_CFGPROP_VideoCodecInfo:
if ( ! m_VideoCodec.put_Str(pszValue))
return false;
break;
case TAKSI_CFGPROP_AudioFormat:
{
BYTE bTmp[1024];
ZeroMemory( &bTmp, sizeof(bTmp));
int iSize = Mem_ReadFromString( bTmp, sizeof(bTmp)-1, pszValue );
if ( iSize < sizeof(PCMWAVEFORMAT))
{
//ASSERT( iSize >= sizeof(PCMWAVEFORMAT));
return false;
}
if ( ! m_AudioFormat.SetFormatBytes( bTmp, iSize ))
{
//ASSERT(0);
return false;
}
}
break;
case TAKSI_CFGPROP_AudioDevice:
m_iAudioDevice = atoi(pszValue);
break;
case TAKSI_CFGPROP_ShowIndicator:
m_bShowIndicator = GetStrBool(pszValue);
break;
case TAKSI_CFGPROP_GDIFrame:
m_bGDIFrame = GetStrBool(pszValue);
break;
case TAKSI_CFGPROP_GDICursor:
m_bGDICursor = GetStrBool(pszValue);
break;
case TAKSI_CFGPROP_GDIDesktop:
m_abUseGAPI[TAKSI_GAPI_DESKTOP] = GetStrBool(pszValue);
break;
case TAKSI_CFGPROP_UseGDI:
m_abUseGAPI[TAKSI_GAPI_GDI] = GetStrBool(pszValue);
break;
case TAKSI_CFGPROP_UseOGL:
m_abUseGAPI[TAKSI_GAPI_OGL] = GetStrBool(pszValue);
break;
#ifdef USE_DIRECTX8
case TAKSI_CFGPROP_UseDX8:
m_abUseGAPI[TAKSI_GAPI_DX8] = GetStrBool(pszValue);
break;
#endif
#ifdef USE_DIRECTX9
case TAKSI_CFGPROP_UseDX9:
m_abUseGAPI[TAKSI_GAPI_DX9] = GetStrBool(pszValue);
break;
#endif
case TAKSI_CFGPROP_UseOverheadCompensation:
m_bUseOverheadCompensation = GetStrBool(pszValue);
break;
default:
DEBUG_ERR(("CTaksiConfig::PropSet bad code %d" LOG_CR, eProp ));
ASSERT(0);
return false;
}
#if 0 // def _DEBUG
char szTmp[_MAX_PATH*2];
if ( PropGet(eProp,szTmp,sizeof(szTmp)) < 0 )
{
strcpy( szTmp, "<NA>" );
}
LOG_MSG(( "PropSet '%s'='%s'" LOG_CR, sm_Props[eProp], szTmp));
#endif
return true;
}
//***************************************************************************
bool CTaksiConfig::ReadIniFile()
{
// Read an INI file in standard INI file format.
// Returns true if successful.
TCHAR szIniFileName[_MAX_PATH];
Str_MakeFilePath( szIniFileName, COUNTOF(szIniFileName),
sg_Shared.m_szIniDir, _T(TAKSI_INI_FILE) );
#ifdef _UNICODE
// convert from UNICODE. fopen() is multibyte only.
FILE* pFile = NULL; ASSERT(0);
#else
FILE* pFile = fopen(szIniFileName, _T("rt"));
#endif
if (pFile == NULL)
{
// ASSUME constructor has already set this to all defaults.
return false;
}
LOG_MSG(( "Reading INI file '%s'" LOG_CR, szIniFileName ));
CIniObject* pObj = NULL;
while (true)
{
char szBuffer[_MAX_PATH*2];
fgets(szBuffer, sizeof(szBuffer)-1, pFile);
if (feof(pFile))
break;
// skip/trim comments
char* pszComment = strstr(szBuffer, ";");
if (pszComment != NULL)
pszComment[0] = '\0';
// parse the line
char* pszName = Str_SkipSpace(szBuffer); // skip leading spaces.
if ( *pszName == '\0' )
continue;
if ( *pszName == '[' )
{
if ( ! strnicmp( pszName, "[" TAKSI_SECTION "]", 7 ))
{
pObj = this;
}
else if ( ! strnicmp( pszName, "[" TAKSI_CUSTOM_SECTION " ", sizeof(TAKSI_CUSTOM_SECTION)+1 ))
{
TCHAR szSection[ _MAX_PATH ];
#ifdef _UNICODE
ASSERT(0);
#else
strncpy( szSection, pszName+sizeof(TAKSI_CUSTOM_SECTION)+1, sizeof(szSection));
#endif
TCHAR* pszEnd = _tcschr(szSection, ']');
if (pszEnd)
*pszEnd = '\0';
pObj = CustomConfig_Lookup(szSection,true);
}
else
{
pObj = NULL;
LOG_MSG(("INI Bad Section %s" LOG_CR, pszName ));
}
continue;
}
if ( pObj == NULL ) // skip
continue;
char* pszEq = strstr(pszName, "=");
if (pszEq == NULL)
continue;
pszEq[0] = '\0';
char* pszValue = Str_SkipSpace( pszEq + 1 ); // skip leading spaces.
if ( ! pObj->PropSetName( pszName, pszValue ))
{
LOG_MSG(("INI Bad Prop %s" LOG_CR, pszName ));
}
}
fclose(pFile);
FixCaptureDir();
return true;
}
bool CTaksiConfig::WriteIniFile()
{
// RETURN: true = success
// false = cant save!
//
char* pFileOld = NULL;
DWORD nSizeOld = 0;
TCHAR szIniFileName[_MAX_PATH];
Str_MakeFilePath( szIniFileName, COUNTOF(szIniFileName),
sg_Shared.m_szIniDir, _T(TAKSI_INI_FILE) );
// first read all lines
CNTHandle FileOld( ::CreateFile( szIniFileName,
GENERIC_READ, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ));
if ( FileOld.IsValidHandle())
{
nSizeOld = ::GetFileSize(FileOld, NULL);
pFileOld = (char*) ::HeapAlloc( g_Proc.m_hHeap, HEAP_ZERO_MEMORY, nSizeOld);
if (pFileOld == NULL)
return false;
DWORD dwBytesRead = 0;
::ReadFile(FileOld, pFileOld, nSizeOld, &dwBytesRead, NULL);
if (dwBytesRead != nSizeOld)
{
::HeapFree( g_Proc.m_hHeap, 0, pFileOld );
return false;
}
FileOld.CloseHandle();
}
// create new file
FILE* pFile = fopen( TAKSI_INI_FILE, "wt");
if ( pFile == NULL )
return false;
// loop over every line from the old file, and overwrite it in the new file
// if necessary. Otherwise - copy the old line.
CIniObject* pObj = NULL;
char* pszLine = pFileOld;
if (pFileOld)
while (true)
{
if ( pszLine >= pFileOld + nSizeOld )
break;
if ( *pszLine == '[' )
{
if ( pObj ) // finish previous section.
{
pObj->PropsWrite(pFile);
}
if ( ! strnicmp( pszLine, "[" TAKSI_SECTION "]", sizeof(TAKSI_SECTION)+1 ))
{
pObj = this;
}
else if ( ! strnicmp( pszLine, "[" TAKSI_CUSTOM_SECTION " ", sizeof(TAKSI_CUSTOM_SECTION)+1 ))
{
TCHAR szSection[ _MAX_PATH ];
#ifdef _UNICODE
ASSERT(0);
#else
strncpy( szSection, pszLine+14, sizeof(szSection));
#endif
TCHAR* pszEnd = _tcschr(szSection, ']');
if (pszEnd)
*pszEnd = '\0';
pObj = CustomConfig_FindAppId(szSection);
}
else
{
pObj = NULL;
}
}
char* pszEndLine = strchr(pszLine, '\n' ); // INI_CR
if (pszEndLine)
{
// covers \n or \r\n
char* pszTmp = pszEndLine;
for ( ; pszTmp >= pszLine && Str_IsSpace(*pszTmp); pszTmp-- )
pszTmp[0] = '\0';
pszEndLine++;
}
// it's a custom setting.
bool bReplaced;
if (pObj)
{
bReplaced = pObj->PropWriteName( pFile, pszLine );
}
else
{
bReplaced = false;
}
if (!bReplaced)
{
// take the old line as it was, might be blank or comment.
fprintf(pFile, "%s" INI_CR, pszLine);
}
if (pszEndLine == NULL)
break;
pszLine = pszEndLine;
}
// release buffer
if(pFileOld)
{
::HeapFree( g_Proc.m_hHeap, 0, pFileOld );
}
if ( pObj ) // finish previous section.
{
pObj->PropsWrite(pFile);
}
// if wasn't written, make sure we write it.
if (!m_dwWrittenMask)
{
fprintf( pFile, "[" TAKSI_SECTION "]" INI_CR );
PropsWrite(pFile);
}
PropsInit();
// same goes for NEW custom configs
CTaksiConfigCustom* p = m_pCustomList;
while (p != NULL)
{
if ( ! p->m_dwWrittenMask )
{
fprintf( pFile, "[" TAKSI_CUSTOM_SECTION " %s]" INI_CR, p->m_szAppId );
p->PropsWrite(pFile);
}
p->PropsInit();
p = p->m_pNext;
}
fclose(pFile);
return true;
}
| [
"[email protected]",
"prowler7@8bb48286-aa14-0410-aaaf-826319861694"
]
| [
[
[
1,
157
],
[
159,
189
],
[
191,
418
],
[
421,
537
],
[
541,
813
]
],
[
[
158,
158
],
[
190,
190
],
[
419,
420
],
[
538,
540
]
]
]
|
4db023ba939831ee00e17d92f2082ea8c7d96f5b | 6253ab92ce2e85b4db9393aa630bde24655bd9b4 | /Utilities/UDPLogger/main.cpp | 6cbe8c58c890e52d3b858f55b6be2a8b629523d7 | []
| no_license | Aand1/cornell-urban-challenge | 94fd4df18fd4b6cc6e12d30ed8eed280826d4aed | 779daae8703fe68e7c6256932883de32a309a119 | refs/heads/master | 2021-01-18T11:57:48.267384 | 2008-10-01T06:43:18 | 2008-10-01T06:43:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,844 | cpp | #include "..\..\common\Ibeo\IbeoClient.h"
#include "..\..\common\poseinterface\poseclient.h"
#include "..\..\common\Ibeo\IbeoSyncClient.h"
#include "..\..\common\LidarClusterInterface\LidarClusterClient.h"
#include "GenericUDPLoggingClient.h"
#include "time.h"
__int64 prog_begin_ts;
string GenerateLogFileName(){
// figure out how to name a log file if it needs to be used...
char buf[200], buf2[200];
struct tm *newTime;
time_t szClock;
time( &szClock );
newTime = localtime( &szClock );
strftime(buf,150,"%Y-%m-%d %I %M %S%p",newTime);
#ifdef LOG_VELODYNE
char tag[] = "-velo";
#else
char tag[] = "";
#endif
if(GetDiskFreeSpaceExA("Z:\\",NULL,NULL,NULL)!=FALSE)
sprintf(buf2,"Z:\\logs\\udp_log %s%s.dat",buf,tag);
else if(GetDiskFreeSpaceExA("E:\\",NULL,NULL,NULL)!=FALSE)
sprintf(buf2,"E:\\logs\\udp_log %s%s.dat",buf,tag);
else
sprintf(buf2,"C:\\logs\\udp_log %s%s.dat",buf,tag);
return string(buf2);
}
vector<GenericUDPLoggingClient*> loggers;
PacketLogger *logger = NULL;
void AddLogger(int port, string multicastIP,string name,int subnet=-1){
GenericUDPLoggingClient * c = new GenericUDPLoggingClient(port,multicastIP.c_str(),logger,name.c_str(),subnet);
loggers.push_back(c);
}
void main(){
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
prog_begin_ts = getTime();
string lfn = GenerateLogFileName();
#ifndef UDP_LOGGER_MONITOR_MODE
logger = new PacketLogger(lfn.c_str(),prog_begin_ts);
if(!logger->IsOpen()){
printf("Logger couldn't open log file [%s]\nExiting.\n",lfn.c_str());
delete logger;
system("pause");
return;
}
#endif
AddLogger(92,"239.132.1.4","LN200");
AddLogger(30006,"239.132.1.6", "Actuation");
AddLogger(30008,"232.132.1.8", "CamSync");
AddLogger(30009,"239.132.1.9", "IbeoSync");
AddLogger(30010,"239.132.1.10", "PwrSupply");
AddLogger(3679,"239.132.1.11", "StopLine");
AddLogger(30012,"239.132.1.12", "Delphi");
AddLogger(30016,"239.132.1.16", "SICK");
//AddLogger(30020,"239.132.1.20", "Gimbal Pos");
AddLogger(4839,"239.132.1.33", "Pose");
AddLogger(30034,"239.132.1.34", "LocalMap");
AddLogger(30035,"239.132.1.35", "SceneEst");
AddLogger(30036,"239.132.1.36", "MobilEye");
AddLogger(30037,"239.132.1.37", "RoadFit");
AddLogger(30038,"239.132.1.38", "SickEdge");
AddLogger(30039,"239.132.1.39", "SickClstrs");
AddLogger(30040,"239.132.1.40", "MESS");
AddLogger(30041,"239.132.1.41", "Clusters");
AddLogger(30060,"239.132.1.60", "Ibeo");
AddLogger(30061,"239.132.1.61", "OccupGrid");
AddLogger(30065,"239.132.1.65", "VeloRoad");
AddLogger(30098,"239.132.1.98", "CameraWide");
AddLogger(30099,"239.132.1.99", "Camera");
AddLogger(30100,"239.132.1.100","HealthMon");
AddLogger(30101,"239.132.1.101","ArbCmdChan");
//AddLogger(30105,"239.132.1.105","GimbalCmds");
AddLogger(30237,"239.132.1.237","ArbOutChan");
AddLogger(30238,"239.132.1.238","ArbInfChan");
AddLogger(30123,"224.0.2.7", "ArbPosChan");
AddLogger(30123,"224.0.2.8", "OpRoadChan");
AddLogger(30123,"224.0.2.10", "ArbVehSpd");
#ifdef LOG_VELODYNE
AddLogger(2368,"","Velodyne",3);
AddLogger(30,"255.255.255.255","Timeserver");
#endif
printf("Logging to [%s]...\n",lfn.c_str());
printf("Press [space]+[e] to quit\n");
unsigned int cnt=0;
while(!(GetKeyState('E')&0x80) || !(GetKeyState(' ')&0x80)){
Sleep(100);
cnt++;
if(cnt==20){
cnt = 0;
system("cls");
if(logger==NULL){
SetConsoleTextAttribute(hStdout, FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY|BACKGROUND_BLUE);
}
printf("%10s pckts/sec %kB/sec pckt len \n","Name");
printf("========================================================================\n");
if(logger==NULL){
SetConsoleTextAttribute(hStdout,0x7);
}
for(unsigned int i=0;i<loggers.size();i++)
loggers[i]->PrintStats(hStdout);
if(logger!=NULL){
SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN|FOREGROUND_INTENSITY);
printf("Logging to [%s]...\n",lfn.c_str());
SetConsoleTextAttribute(hStdout,0x7);
}
printf("Press [space]+[e] to quit\n");
if(logger==NULL){
SetConsoleTextAttribute(hStdout, FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY|BACKGROUND_BLUE);
printf("------------------ MONITOR MODE (NO LOGGING TO HD) ---------------------",27);
SetConsoleTextAttribute(hStdout,0x7);
}
}
}
for(unsigned int i=0;i<loggers.size();i++){
loggers[i]->StopLogging();
delete loggers[i];
}
Sleep(100);
if(logger!=NULL)
delete logger;
} | [
"anathan@5031bdca-8e6f-11dd-8a4e-8714b3728bc5"
]
| [
[
[
1,
148
]
]
]
|
5cb7f6894c189985740178be63819a378a7a363f | c491b519b17841bc832f2434f82915c76fbfd41e | /Etudes/Master_1/Semestre_2/Visualisation_Scientifique/tp/tp02/Point2D.h | 235f5ab0ee79ca2d7c99d5e098b506ec96f53d42 | []
| no_license | placidz/placidz | 2300486ee11edb53432491c5c168b3b15d71627a | 6a87678db258c677fc71b2e53e3df56c7c1ffa5b | refs/heads/master | 2021-01-01T05:31:34.944296 | 2010-04-30T01:06:51 | 2010-04-30T01:06:51 | 32,144,797 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 546 | h | #ifndef POINT2D_H
#define POINT2D_H
#include <iostream>
#include <vector>
using namespace std;
class Point2D
{
public:
int x;
int y;
Point2D(void);
Point2D(int _x, int _y);
~Point2D(void);
void Set(int _x, int _y);
int trouvePosDansListe(vector<Point2D>listePt);
bool estPtIntersection(vector<Point2D>lstOrig);
Point2D& operator=(const Point2D&);
bool operator ==(const Point2D&);
bool operator !=(const Point2D&);
};
#endif
| [
"florian.blanc.fr@50db6110-248a-11df-92e6-556e66e75246"
]
| [
[
[
1,
28
]
]
]
|
89ce2a80e3aef7f93d43a788493b32148138c14f | b8fe0ddfa6869de08ba9cd434e3cf11e57d59085 | /ouan-tests/OgreSceneLoader/CameraControllerFirstPerson.cpp | cb9e257f92e848ae7e4ed4772ec23b695e220c29 | []
| no_license | juanjmostazo/ouan-tests | c89933891ed4f6ad48f48d03df1f22ba0f3ff392 | eaa73fb482b264d555071f3726510ed73bef22ea | refs/heads/master | 2021-01-10T20:18:35.918470 | 2010-06-20T15:45:00 | 2010-06-20T15:45:00 | 38,101,212 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,117 | cpp | #include "CameraControllerFirstPerson.h"
CameraControllerFirstPerson::CameraControllerFirstPerson()
{
}
CameraControllerFirstPerson::~CameraControllerFirstPerson()
{
}
void CameraControllerFirstPerson::initialise(Ogre::SceneManager * pSceneManager)
{
// Create the camera's top node (which will only handle position).
this->cameraNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
// Create the camera's yaw node as a child of camera's top node.
this->cameraYawNode = this->cameraNode->createChildSceneNode();
// Create the camera's pitch node as a child of camera's yaw node.
this->cameraPitchNode = this->cameraYawNode->createChildSceneNode();
// Create the camera's roll node as a child of camera's pitch node
// and attach the camera to it.
this->cameraRollNode = this->cameraPitchNode->createChildSceneNode();
//Create the camera's offset node as a child of camera's roll node
this->cameraOffsetNode = this->cameraRollNode->createChildSceneNode();
}
void CameraControllerFirstPerson::setCamera(Ogre::Camera* camera)
{
//TODO FIX THIS CRAP
this->camera=camera;
this->cameraNode->setPosition(camera->getPosition());
this->cameraYawNode->yaw(camera->getOrientation().getYaw());
this->cameraPitchNode->pitch(camera->getOrientation().getPitch());
this->cameraRollNode->roll(camera->getOrientation().getRoll());
this->cameraOffsetNode->setPosition(-camera->getPosition());
this->cameraOffsetNode->setOrientation(-camera->getOrientation());
this->cameraOffsetNode->attachObject(camera);
}
void CameraControllerFirstPerson::processMouseInput(const OIS::MouseEvent& e)
{
Ogre::Real pitchAngle;
Ogre::Real pitchAngleSign;
float mRotX=-e.state.X.rel*0.3;
float mRotY=-e.state.Y.rel*0.3;
// Yaws the camera according to the mouse relative movement.
cameraYawNode->yaw(Ogre::Angle(mRotX));
// Pitches the camera according to the mouse relative movement.
cameraPitchNode->pitch(Ogre::Angle(mRotY));
// Angle of rotation around the X-axis.
pitchAngle = (2 * Ogre::Degree(Ogre::Math::ACos(this->cameraPitchNode->getOrientation().w)).valueDegrees());
// Just to determine the sign of the angle we pick up above, the
// value itself does not interest us.
pitchAngleSign = cameraPitchNode->getOrientation().x;
// Limit the pitch between -90 degress and +90 degrees, Quake3-style.
if (pitchAngle > 90.0f)
{
if (pitchAngleSign > 0)
// Set orientation to 90 degrees on X-axis.
cameraPitchNode->setOrientation(Ogre::Quaternion(Ogre::Math::Sqrt(0.5f),
Ogre::Math::Sqrt(0.5f), 0, 0));
else if (pitchAngleSign < 0)
// Sets orientation to -90 degrees on X-axis.
cameraPitchNode->setOrientation(Ogre::Quaternion(Ogre::Math::Sqrt(0.5f),
-Ogre::Math::Sqrt(0.5f), 0, 0));
}
}
void CameraControllerFirstPerson::processKeyboardInput(SimpleInputManager* pSimpleInputManager,const float elapsedSeconds,float moveScale,float rotateScale)
{
OIS::Keyboard* m_keyboard;
m_keyboard=pSimpleInputManager->m_keyboard;
Ogre::Vector3 translateVector= Ogre::Vector3(0,0,0);
moveScale=moveScale*elapsedSeconds;
rotateScale=rotateScale*elapsedSeconds;
// Move camera upwards along to world's Y-axis.
if(m_keyboard->isKeyDown(OIS::KC_PGUP))
//this->translateVector.y = this->moveScale;
cameraNode->setPosition(this->cameraNode->getPosition() + Ogre::Vector3(0, moveScale, 0));
// Move camera downwards along to world's Y-axis.
if(m_keyboard->isKeyDown(OIS::KC_PGDOWN))
//this->translateVector.y = -(this->moveScale);
cameraNode->setPosition(this->cameraNode->getPosition() - Ogre::Vector3(0, moveScale, 0));
// Move camera forward.
if(m_keyboard->isKeyDown(OIS::KC_UP))
translateVector.z = -(moveScale);
// Move camera backward.
if(m_keyboard->isKeyDown(OIS::KC_DOWN))
translateVector.z = moveScale;
// Move camera left.
if(m_keyboard->isKeyDown(OIS::KC_LEFT))
translateVector.x = -(moveScale);
// Move camera right.
if(m_keyboard->isKeyDown(OIS::KC_RIGHT))
translateVector.x = moveScale;
// Rotate camera left.
if(m_keyboard->isKeyDown(OIS::KC_Q))
cameraYawNode->yaw(Ogre::Angle(rotateScale));
// Rotate camera right.
if(m_keyboard->isKeyDown(OIS::KC_D))
cameraYawNode->yaw(Ogre::Angle(-(rotateScale)));
// Strip all yaw rotation on the camera.
if(m_keyboard->isKeyDown(OIS::KC_A))
cameraYawNode->setOrientation(Ogre::Quaternion::IDENTITY);
// Rotate camera upwards.
if(m_keyboard->isKeyDown(OIS::KC_Z))
cameraPitchNode->pitch(Ogre::Angle(rotateScale));
// Rotate camera downwards.
if(m_keyboard->isKeyDown(OIS::KC_S))
cameraPitchNode->pitch(Ogre::Angle(-(rotateScale)));
// Strip all pitch rotation on the camera.
if(m_keyboard->isKeyDown(OIS::KC_E))
cameraPitchNode->setOrientation(Ogre::Quaternion::IDENTITY);
// Tilt camera on the left.
if(m_keyboard->isKeyDown(OIS::KC_L))
cameraRollNode->roll(Ogre::Angle(-(rotateScale)));
// Tilt camera on the right.
if(m_keyboard->isKeyDown(OIS::KC_M))
cameraRollNode->roll(Ogre::Angle(rotateScale));
// Strip all tilt applied to the camera.
if(m_keyboard->isKeyDown(OIS::KC_P))
cameraRollNode->setOrientation(Ogre::Quaternion::IDENTITY);
// Strip all rotation to the camera.
if(m_keyboard->isKeyDown(OIS::KC_O))
{
cameraYawNode->setOrientation(Ogre::Quaternion::IDENTITY);
cameraPitchNode->setOrientation(Ogre::Quaternion::IDENTITY);
cameraRollNode->setOrientation(Ogre::Quaternion::IDENTITY);
}
// Translates the camera according to the translate vector which is
// controlled by the keyboard arrows.
//
// NOTE: We multiply the mTranslateVector by the cameraPitchNode's
// orientation quaternion and the cameraYawNode's orientation
// quaternion to translate the camera accoding to the camera's
// orientation around the Y-axis and the X-axis.
cameraNode->translate(cameraYawNode->getOrientation() *
cameraPitchNode->getOrientation() *
translateVector,
Ogre::SceneNode::TS_LOCAL);
}
| [
"ithiliel@6899d1ce-2719-11df-8847-f3d5e5ef3dde"
]
| [
[
[
1,
174
]
]
]
|
eebd7a88691b5966e4e9fe217b7f16b0d4d90393 | 1d2705c9be9ee0f974c224eb794f2f8a9e9a3d50 | /jpeg_streaming_server.exe/jpeg_source_t.cpp | 74c356a12b804f3d19d07c802b46efd6d0a2ddb0 | []
| no_license | llvllrbreeze/alcorapp | dfe2551f36d346d73d998f59d602c5de46ef60f7 | 3ad24edd52c19f0896228f55539aa8bbbb011aac | refs/heads/master | 2021-01-10T07:36:01.058011 | 2008-12-16T12:51:50 | 2008-12-16T12:51:50 | 47,865,136 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,099 | cpp | #include "jpeg_source_t.hpp"
//jpeg_source_t::jpeg_source_t() {
// m_bee.open("config/bumblebeeB.ini");
//
// m_encoder.reset(all::core::rgb_tag, all::core::planar_tag, m_bee.ncols(), m_bee.nrows());
//
// m_jpeg_quality = 100;
//}
//
//
//void jpeg_source_t::set_quality(int quality) {
// m_jpeg_quality = quality;
//}
//
//int jpeg_source_t::get_data(all::core::uint8_ptr* data) {
// printf("start get data\n");
// printf("grabbing color image\n");
// m_bee.grab();
// all::core::uint8_sarr image = m_bee.get_color_buffer(all::core::left_img, true);
// printf("encoding image\n");
// all::core::jpeg_data_t jpeg_data = m_encoder.encode(image, m_jpeg_quality);
// printf("copying image\n");
// all::core::uint8_ptr return_data = new all::core::uint8_t[jpeg_data.size];
// memcpy(return_data, jpeg_data.data.get(), jpeg_data.size);
//
// *data = return_data;
//
// return jpeg_data.size;
//}
jpeg_source_t::jpeg_source_t() {
m_bee.open("config/bumblebeeB.ini");
m_encoder.reset(all::core::rgb_tag, all::core::planar_tag, m_bee.height(), m_bee.width());
m_jpeg_quality = 100;
}
void jpeg_source_t::set_quality(int quality) {
m_jpeg_quality = quality;
}
int jpeg_source_t::get_data(all::core::uint8_ptr* data) {
//printf("start get data\n");
//m_bee.lock();
//printf("grabbing color image\n");
all::core::jpeg_data_t jpeg_data;
all::core::uint8_sarr image = m_bee.get_color_buffer(all::core::right_img, true);
//printf("encoding image\n");
jpeg_data = m_encoder.encode(image, m_jpeg_quality);
//m_bee.unlock();
//printf("copying image\n");
printf("CRC: %x\n", jpeg_data.crc);
printf("size: %i\n", jpeg_data.size);
size_t buffer_size = jpeg_data.size + sizeof(jpeg_data.crc);
all::core::uint8_ptr return_data = new all::core::uint8_t[buffer_size];
all::core::uint8_ptr write_ptr = return_data;
memcpy(write_ptr, &(jpeg_data.crc), sizeof(jpeg_data.crc));
write_ptr+=sizeof(jpeg_data.crc);
memcpy(write_ptr, jpeg_data.data.get(), jpeg_data.size);
*data = return_data;
return buffer_size;
} | [
"stefano.marra@1ffd000b-a628-0410-9a29-793f135cad17",
"andrea.carbone@1ffd000b-a628-0410-9a29-793f135cad17"
]
| [
[
[
1,
32
],
[
34,
74
]
],
[
[
33,
33
]
]
]
|
85f42a50d27f9ff8ef2ee7add99a2632ef0e762c | 2ca3ad74c1b5416b2748353d23710eed63539bb0 | /Pilot/Lokapala_Frame/Raptor/DecisionBI.h | dd361b0515407e43b519f268b52fc49d91089e87 | []
| no_license | sjp38/lokapala | 5ced19e534bd7067aeace0b38ee80b87dfc7faed | dfa51d28845815cfccd39941c802faaec9233a6e | refs/heads/master | 2021-01-15T16:10:23.884841 | 2009-06-03T14:56:50 | 2009-06-03T14:56:50 | 32,124,140 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 298 | h | /**@file DecisionBI.h
* @brief DCM의 Button Interface 정의
* @author siva
*/
#ifndef DECISION_BI_H
#define DECISION_BI_H
/**@ingroup GroupDCM
* @class CDecisionBI
* @brief DCM의 Button Interface.
* @remarks 인터페이스일 뿐이다.
*/
class CDecisionBI
{
};
#endif | [
"nilakantha38@b9e76448-5c52-0410-ae0e-a5aea8c5d16c"
]
| [
[
[
1,
17
]
]
]
|
8daa669217ad86a15c3ccc3b646e225d68e0c379 | 3ea33f3b6b61d71216d9e81993a7b6ab0898323b | /ExternalLibs/raknet/include/NatPunchthroughServer.h | 6a3dd2aa0557748b21c6ab45ee36c423e225827c | []
| no_license | drivehappy/tlmp | fd1510f48ffea4020a277f28a1c4525dffb0397e | 223c07c6a6b83e4242a5e8002885e23d0456f649 | refs/heads/master | 2021-01-10T20:45:15.629061 | 2011-07-07T00:43:00 | 2011-07-07T00:43:00 | 32,191,389 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,582 | h | /// \file
/// \brief Contains the NAT-punchthrough plugin for the server.
///
/// This file is part of RakNet Copyright 2003 Jenkins Software LLC
///
/// Usage of RakNet is subject to the appropriate license agreement.
#include "NativeFeatureIncludes.h"
#if _RAKNET_SUPPORT_NatPunchthroughServer==1
#ifndef __NAT_PUNCHTHROUGH_SERVER_H
#define __NAT_PUNCHTHROUGH_SERVER_H
#include "RakNetTypes.h"
#include "Export.h"
#include "PluginInterface2.h"
#include "PacketPriority.h"
#include "SocketIncludes.h"
#include "DS_OrderedList.h"
#include "RakString.h"
class RakPeerInterface;
struct Packet;
#if _RAKNET_SUPPORT_PacketLogger==1
class PacketLogger;
#endif
/// \defgroup NAT_PUNCHTHROUGH_GROUP NatPunchthrough
/// \brief Connect systems despite both systems being behind a router
/// \details
/// \ingroup PLUGINS_GROUP
/// \ingroup NAT_PUNCHTHROUGH_GROUP
struct NatPunchthroughServerDebugInterface
{
NatPunchthroughServerDebugInterface() {}
virtual ~NatPunchthroughServerDebugInterface() {}
virtual void OnServerMessage(const char *msg)=0;
};
/// \ingroup NAT_PUNCHTHROUGH_GROUP
struct NatPunchthroughServerDebugInterface_Printf : public NatPunchthroughServerDebugInterface
{
virtual void OnServerMessage(const char *msg);
};
#if _RAKNET_SUPPORT_PacketLogger==1
/// \ingroup NAT_PUNCHTHROUGH_GROUP
struct NatPunchthroughServerDebugInterface_PacketLogger : public NatPunchthroughServerDebugInterface
{
// Set to non-zero to write to the packetlogger!
PacketLogger *pl;
NatPunchthroughServerDebugInterface_PacketLogger() {pl=0;}
~NatPunchthroughServerDebugInterface_PacketLogger() {}
virtual void OnServerMessage(const char *msg);
};
#endif
/// \brief Server code for NATPunchthrough
/// \details Maintain connection to NatPunchthroughServer to process incoming connection attempts through NatPunchthroughClient<BR>
/// Server maintains two sockets clients can connect to so as to estimate the next port choice<BR>
/// Server tells other client about port estimate, current public port to the server, and a time to start connection attempts
/// \sa NatTypeDetectionClient
/// See also http://www.jenkinssoftware.com/raknet/manual/natpunchthrough.html
/// \ingroup NAT_PUNCHTHROUGH_GROUP
class RAK_DLL_EXPORT NatPunchthroughServer : public PluginInterface2
{
public:
// Constructor
NatPunchthroughServer();
// Destructor
virtual ~NatPunchthroughServer();
/// Sets a callback to be called with debug messages
/// \param[in] i Pointer to an interface. The pointer is stored, so don't delete it while in progress. Pass 0 to clear.
void SetDebugInterface(NatPunchthroughServerDebugInterface *i);
/// \internal For plugin handling
virtual void Update(void);
/// \internal For plugin handling
virtual PluginReceiveResult OnReceive(Packet *packet);
/// \internal For plugin handling
virtual void OnClosedConnection(SystemAddress systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason );
virtual void OnNewConnection(SystemAddress systemAddress, RakNetGUID rakNetGUID, bool isIncoming);
// Each connected user has a ready state. Ready means ready for nat punchthrough.
struct User;
struct ConnectionAttempt
{
ConnectionAttempt() {sender=0; recipient=0; startTime=0; attemptPhase=NAT_ATTEMPT_PHASE_NOT_STARTED;}
User *sender, *recipient;
uint16_t sessionId;
RakNetTime startTime;
enum
{
NAT_ATTEMPT_PHASE_NOT_STARTED,
NAT_ATTEMPT_PHASE_GETTING_RECENT_PORTS,
} attemptPhase;
};
struct User
{
RakNetGUID guid;
SystemAddress systemAddress;
unsigned short mostRecentPort;
bool isReady;
DataStructures::List<ConnectionAttempt *> connectionAttempts;
bool HasConnectionAttemptToUser(User *user);
void DerefConnectionAttempt(ConnectionAttempt *ca);
void DeleteConnectionAttempt(ConnectionAttempt *ca);
void LogConnectionAttempts(RakNet::RakString &rs);
};
RakNetTime lastUpdate;
static int NatPunchthroughUserComp( const RakNetGUID &key, User * const &data );
protected:
void OnNATPunchthroughRequest(Packet *packet);
DataStructures::OrderedList<RakNetGUID, User*, NatPunchthroughServer::NatPunchthroughUserComp> users;
void OnGetMostRecentPort(Packet *packet);
void OnClientReady(Packet *packet);
void SendTimestamps(void);
void StartPendingPunchthrough(void);
void StartPunchthroughForUser(User*user);
uint16_t sessionId;
NatPunchthroughServerDebugInterface *natPunchthroughServerDebugInterface;
};
#endif
#endif // _RAKNET_SUPPORT_*
| [
"drivehappy@7af81de8-dd64-11de-95c9-073ad895b44c"
]
| [
[
[
1,
136
]
]
]
|
d803f39b2bd39cc091fcde653a1aed4014d8941e | ce262ae496ab3eeebfcbb337da86d34eb689c07b | /SEFoundation/SEShaders/SEPixelShader.h | 83e0467d729f8628bcb4793613e973a37e2a789a | []
| no_license | pizibing/swingengine | d8d9208c00ec2944817e1aab51287a3c38103bea | e7109d7b3e28c4421c173712eaf872771550669e | refs/heads/master | 2021-01-16T18:29:10.689858 | 2011-06-23T04:27:46 | 2011-06-23T04:27:46 | 33,969,301 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,735 | h | // Swing Engine Version 1 Source Code
// Most of techniques in the engine are mainly based on David Eberly's
// Wild Magic 4 open-source code.The author of Swing Engine learned a lot
// from Eberly's experience of architecture and algorithm.
// Several sub-systems are totally new,and others are re-implimented or
// re-organized based on Wild Magic 4's sub-systems.
// Copyright (c) 2007-2010. All Rights Reserved
//
// Eberly's permission:
// Geometric Tools, Inc.
// http://www.geometrictools.com
// Copyright (c) 1998-2006. All Rights Reserved
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or (at
// your option) any later version. The license is available for reading at
// the location:
// http://www.gnu.org/copyleft/lgpl.html
#ifndef Swing_PixelShader_H
#define Swing_PixelShader_H
#include "SEFoundationLIB.h"
#include "SEPlatforms.h"
#include "SEShader.h"
#include "SEPixelProgram.h"
namespace Swing
{
//----------------------------------------------------------------------------
// Description:
// Author:Sun Che
// Date:20080701
//----------------------------------------------------------------------------
class SE_FOUNDATION_API SEPixelShader : public SEShader
{
SE_DECLARE_RTTI;
SE_DECLARE_NAME_ID;
SE_DECLARE_STREAM;
public:
SEPixelShader(const std::string& rShaderName);
virtual ~SEPixelShader(void);
SEPixelProgram* GetProgram(void) const;
protected:
SEPixelShader(void);
};
typedef SESmartPointer<SEPixelShader> SEPixelShaderPtr;
}
#endif
| [
"[email protected]@876e9856-8d94-11de-b760-4d83c623b0ac"
]
| [
[
[
1,
57
]
]
]
|
e7485c74c1f562cd3646422b17892c5578754353 | f9fd733174ef8a8bd07ff9be849431dfc46e541f | /NumberLib/NumbersLib/AbstractFilteredNumber.h | 32446543d34a80514d4c721a2358a3649b5c97f1 | []
| no_license | Jargyle214/specialnumbers | 8b33369c2bfb75b324cb70539c5daee19f7bce84 | 107b4c3022e5febed38136fa09023f66931df77e | refs/heads/master | 2021-01-10T16:33:58.894648 | 2008-09-21T18:56:04 | 2008-09-21T18:56:04 | 55,395,227 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,592 | h | #ifndef _ABSTRACT_FILTERED_NUMBER_H_
#define _ABSTRACT_FILTERED_NUMBER_H_
#include "UpdateableNumber.h"
namespace luma
{
namespace numbers
{
/**
*/
template <class T, unsigned int sampleCount, unsigned int maxOrder>
class AbstractFilteredNumber : public UpdateableNumber<T>
{
public:
/**
Gets the value of this AbstractFilteredNumber of the given order.
*/
virtual T getValue(unsigned int order) const = 0;
/**
Gets the value of this AbstractFilteredNumber of order 0.
*/
virtual T getValue() const;
};
template <class T, unsigned int sampleCount, unsigned int maxOrder>
T AbstractFilteredNumber<T, sampleCount, maxOrder>::getValue() const
{
return getValue(0);
}
/**
This specialisation is provided for completeness' sake and should
generally not be used. It is nothing more than a wrapper for the value;
the elapsedTime is ignored.
*/
template <class T, unsigned int sampleCount>
class AbstractFilteredNumber<T, sampleCount, 0> : public UpdateableNumber<T>
{
private:
T mCurrentValue;
T mInitialValue;
public:
AbstractFilteredNumber(T initialValue);
/**
Sets the current value of this AbstractFilteredNumber.
The elapsedTime variable is ignored.
*/
virtual void setValue(T x, float elapsedTime = 1.0f);
/**
Only m = 0 will give anything other than the
initialValue.
*/
virtual T getValue(unsigned int order) const;
/**
Returns the value of this AsbtractFilteredNumber (always of order 0).
*/
virtual T getValue() const;
/**
The elapsed time is ignored.
*/
virtual void forceValue(T x, float elapsedTime = 1.0f);
};
template <class T, unsigned int sampleCount>
AbstractFilteredNumber<T, sampleCount, 0>::AbstractFilteredNumber(T initialValue):
mInitialValue(initialValue),
mCurrentValue(initialValue)
{
}
template <class T, unsigned int sampleCount>
void AbstractFilteredNumber<T, sampleCount, 0>::setValue(T x, float /*ignore parameter*/)
{
mCurrentValue = x;
}
template <class T, unsigned int sampleCount>
void AbstractFilteredNumber<T, sampleCount, 0>::forceValue(T x, float /*ignore parameter*/)
{
mCurrentValue = x;
}
template <class T, unsigned int sampleCount>
T AbstractFilteredNumber<T, sampleCount, 0>::getValue() const
{
return getValue(0);
}
template <class T, unsigned int sampleCount>
T AbstractFilteredNumber<T, sampleCount, 0>::getValue(unsigned int order) const
{
if(order == 0)
{
return mCurrentValue;
}
return mInitialValue;
}
}} //namespace
#endif //_ABSTRACT_FILTERED_NUMBER_H_ | [
"herman.tulleken@efac63d9-b148-0410-ace2-6f69ea89f809"
]
| [
[
[
1,
114
]
]
]
|
2e8e3b65ec9e9ad078a121a98c057f40bbec742a | 90c0655f3ad1e3ce9f0822eda11bd6be58a29f57 | /src/include/Simulador.h | 619e2bd277e189757844c85979ef5cbc1394536e | []
| no_license | rocanaan/proj-aguiar-2011 | 46cb8f68f6701bd7f499f21687ce8d0e3d6d111a | fcb13adcca01c1472c53caffe22c0f3ebafe9a10 | refs/heads/master | 2021-01-01T16:39:05.692522 | 2011-07-05T03:31:41 | 2011-07-05T03:31:41 | 34,010,824 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 3,511 | h | #ifndef SIMULADOR_H_
#define SIMULADOR_H_
#include <vector>
#include <queue>
#include <deque>
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include "Cliente.h"
#include "Evento.h"
#include "GeradorTempoExponencial.h"
using namespace std;
class Simulador{
private:
/*
Fila de prioridade para podermos ordenar os eventos a partir de seu tempo de acontecimento
*/
priority_queue<Evento, vector<Evento>, greater<Evento> > filaEventos;
queue<Cliente> fila1;
/*
Foi utillizado deque para podermos mover um cliente de volta para a frente da fila 2 sem dificuldades
*/
deque<Cliente> fila2;
GeradorTempoExponencial* gerador;
double tempo_atual;
Cliente cliente_em_servico;
bool servidor_vazio;
int id_proximo_cliente;
double taxa_chegada;
double taxa_servico;
double cliente_W1;
double cliente_W2;
int total_clientes_servidos_uma_vez;
int total_clientes_servidos_duas_vezes;
/*
Variaveis que auxiliarão no cálculo do numero medio de clientes em cada regiao do sistema,
acumulando o produto N * tempo, onde N é o número de pessoas em cada região do sistema.
Nq1 = Número de pessoas na fila de espera para receber o primeiro serviço
Nq2 = Número de pessoas na fila de espera para receber o segundo serviço
N1 = Número total de pessoas no sistema que ainda não receberam o primeiro serviço completo
N2 = Número total de pessoas no sistema que já foram servidas uma vez, mas ainda não completaram o segundo serviço
OBS em um dado instante: Ni = Nqi + 1, se houver um cliente vindo da fila i no servidor
Ni = Nqi, caso contrário
*/
double Nq1_parcial;
double Nq2_parcial;
double N1_parcial;
double N2_parcial;
/*
Acumuladores das informacoes dos clientes
*/
double acumulaW1;
double acumulaT1;
double acumulaW2;
double acumulaT2;
double acumula_quadradoW1;
double acumula_quadradoW2;
vector<double> E_Nq1;
vector<double> E_Nq2;
vector<double> E_N1;
vector<double> E_N2;
vector<double> E_W1;
vector<double> E_T1;
vector<double> E_W2;
vector<double> E_T2;
vector<double> V_W1;
vector<double> V_W2;
public:
Simulador();
Simulador(double ptaxa_chegada, double ptaxa_servico, bool deterministico, bool dois_por_vez, bool interrupcao_forcada, int semente);
~Simulador();
void Roda(int num_total_clientes, int rodada_atual, bool debug, bool deterministico, bool determina_transiente, bool dois_por_vez, string nome_pasta, bool guardar_estatisticas,bool interrupcao_forcada, bool mostrar_resultados);
void CalculaResultados(int n, int servidos1, double t, int rodada, bool mostrar_resultados, string nome_pasta, bool guardar_estatisticas);
void LimpaResultadosParciais();
void Setup(int semente, bool deterministico);
void GeraDadosGrafico(int rodada, double pN1, double pN2, double pNq1, double pNq2, double pW1, double pW2, double pT1, double pT2, double pV_W1, double pV_W2, string nome_pasta);
Evento RemoveTerminoServico();
vector<double> GetE_Nq1();
vector<double> GetE_Nq2();
vector<double> GetE_N1();
vector<double> GetE_N2();
vector<double> GetE_W1();
vector<double> GetE_T1();
vector<double> GetE_W2();
vector<double> GetE_T2();
vector<double> GetV_W1();
vector<double> GetV_W2();
};
#endif /*SIMULADOR_H_*/
| [
"rocanaan@cedf45fa-8354-0ca4-fa20-ed59a3261951",
"[email protected]@cedf45fa-8354-0ca4-fa20-ed59a3261951",
"[email protected]@cedf45fa-8354-0ca4-fa20-ed59a3261951"
]
| [
[
[
1,
4
]
],
[
[
5,
11
],
[
13,
38
],
[
44,
50
],
[
59,
59
],
[
65,
65
],
[
67,
87
],
[
89,
100
]
],
[
[
12,
12
],
[
39,
43
],
[
51,
58
],
[
60,
64
],
[
66,
66
],
[
88,
88
],
[
101,
101
]
]
]
|
e6ffd671369c1a29b1630b769ae1e9783170a253 | be2e23022d2eadb59a3ac3932180a1d9c9dee9c2 | /GameServer/MapGroupThread.h | 2b8b6a7c7548fe80236df433cb754a269124d989 | []
| no_license | cronoszeu/revresyksgpr | 78fa60d375718ef789042c452cca1c77c8fa098e | 5a8f637e78f7d9e3e52acdd7abee63404de27e78 | refs/heads/master | 2020-04-16T17:33:10.793895 | 2010-06-16T12:52:45 | 2010-06-16T12:52:45 | 35,539,807 | 0 | 2 | null | null | null | null | GB18030 | C++ | false | false | 756 | h | #pragma once
#include "ThreadBase.h"
//#include "MapGroupKernel.h"
class IMessagePort;
class CMapGroupThread : public CThreadBase
{
public:
CMapGroupThread(IMessagePort* pPort);
virtual ~CMapGroupThread();
public: // overload
virtual bool CreateThread(bool bRun = true); // false: 暂不运行,用 ResumeThread() 运行
/////////////////////////////////////////////////////////////////////
protected: // 派生用
//overrideable
virtual void OnInit();
virtual bool OnProcess(); // 不需要返回DWORD
virtual void OnDestroy();
protected: // 核心对象及接口
clock_t m_tNextClock;
// CMapGroupKernel m_cMapGroupKernel;
IMapGroup* m_pMapGroup;
IMessagePort* m_pMsgPort;
HANDLE m_hMutexThread;
};
| [
"rpgsky.com@cc92e6ba-efcf-11de-bf31-4dec8810c1c1"
]
| [
[
[
1,
32
]
]
]
|
026b07f87b01ab7c0653fc5bd58f53bf352e4aec | 555ce7f1e44349316e240485dca6f7cd4496ea9c | /DirectShowFilters/TsReader/source/FileReader.cpp | fe2d7208c1301ec68100d3fe6faa8f609bca8849 | []
| no_license | Yura80/MediaPortal-1 | c71ce5abf68c70852d261bed300302718ae2e0f3 | 5aae402f5aa19c9c3091c6d4442b457916a89053 | refs/heads/master | 2021-04-15T09:01:37.267793 | 2011-11-25T20:02:53 | 2011-11-25T20:11:02 | 2,851,405 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,635 | cpp | /**
* FileReader.cpp
* Copyright (C) 2005 nate
* Copyright (C) 2006 bear
*
* This file is part of TSFileSource, a directshow push source filter that
* provides an MPEG transport stream output.
*
* TSFileSource 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.
*
* TSFileSource is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TSFileSource; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* nate can be reached on the forums at
* http://forums.dvbowners.com/
*/
#include "StdAfx.h"
#include "FileReader.h"
// For more details for memory leak detection see the alloctracing.h header
#include "..\..\alloctracing.h"
extern void LogDebug(const char *fmt, ...) ;
FileReader::FileReader() :
m_hFile(INVALID_HANDLE_VALUE),
m_pFileName(0),
m_bReadOnly(FALSE),
m_fileSize(0),
m_infoFileSize(0),
m_fileStartPos(0),
m_hInfoFile(INVALID_HANDLE_VALUE),
m_bDelay(FALSE),
m_llBufferPointer(0),
m_bDebugOutput(FALSE)
{
}
FileReader::~FileReader()
{
CloseFile();
if (m_pFileName)
delete m_pFileName;
}
HRESULT FileReader::GetFileName(LPOLESTR *lpszFileName)
{
*lpszFileName = m_pFileName;
return S_OK;
}
HRESULT FileReader::SetFileName(LPCOLESTR pszFileName)
{
// Is this a valid filename supplied
//CheckPointer(pszFileName,E_POINTER);
if(wcslen(pszFileName) > MAX_PATH)
return ERROR_FILENAME_EXCED_RANGE;
// Take a copy of the filename
if (m_pFileName)
{
delete[] m_pFileName;
m_pFileName = NULL;
}
m_pFileName = new WCHAR[1+lstrlenW(pszFileName)];
if (m_pFileName == NULL)
return E_OUTOFMEMORY;
wcscpy(m_pFileName, pszFileName);
return S_OK;
}
//
// OpenFile
//
// Opens the file ready for streaming
//
HRESULT FileReader::OpenFile()
{
WCHAR *pFileName = NULL;
int Tmo=5 ;
// Is the file already opened
if (m_hFile != INVALID_HANDLE_VALUE)
{
LogDebug("FileReader::OpenFile() file already open");
return NOERROR;
}
// Has a filename been set yet
if (m_pFileName == NULL)
{
LogDebug("FileReader::OpenFile() no filename");
return ERROR_INVALID_NAME;
}
// BoostThread Boost;
// Convert the UNICODE filename if necessary
//#if defined(WIN32) && !defined(UNICODE)
// char convert[MAX_PATH];
//
// if(!WideCharToMultiByte(CP_ACP,0,m_pFileName,-1,convert,MAX_PATH,0,0))
// return ERROR_INVALID_NAME;
//
// pFileName = convert;
//#else
pFileName = m_pFileName;
//#endif
do
{
// do not try to open a tsbuffer file without SHARE_WRITE so skip this try if we have a buffer file
if (wcsstr(pFileName, L".ts.tsbuffer") == NULL)
{
// Try to open the file
m_hFile = ::CreateFileW(pFileName, // The filename
(DWORD) GENERIC_READ, // File access
(DWORD) FILE_SHARE_READ, // Share access
NULL, // Security
(DWORD) OPEN_EXISTING, // Open flags
(DWORD) 0, // More flags
NULL); // Template
m_bReadOnly = FALSE;
if (m_hFile != INVALID_HANDLE_VALUE) break ;
}
//Test incase file is being recorded to
m_hFile = ::CreateFileW(pFileName, // The filename
(DWORD) GENERIC_READ, // File access
(DWORD) (FILE_SHARE_READ |
FILE_SHARE_WRITE), // Share access
NULL, // Security
(DWORD) OPEN_EXISTING, // Open flags
// (DWORD) 0,
(DWORD) FILE_ATTRIBUTE_NORMAL, // More flags
// FILE_ATTRIBUTE_NORMAL |
// FILE_FLAG_RANDOM_ACCESS, // More flags
// FILE_FLAG_SEQUENTIAL_SCAN, // More flags
NULL); // Template
m_bReadOnly = TRUE;
if (m_hFile != INVALID_HANDLE_VALUE) break ;
Sleep(20) ;
}
while(--Tmo) ;
if (Tmo)
{
if (Tmo<4) // 1 failed + 1 succeded is quasi-normal, more is a bit suspicious ( disk drive too slow or problem ? )
LogDebug("FileReader::OpenFile(), %d tries to succeed opening %ws.", 6-Tmo, pFileName);
}
else
{
DWORD dwErr = GetLastError();
LogDebug("FileReader::OpenFile(), open file %ws failed. Error code %d", pFileName, dwErr);
return HRESULT_FROM_WIN32(dwErr);
}
//LogDebug("FileReader::OpenFile() handle %i %ws", m_hFile, pFileName );
WCHAR infoName[512];
wcscpy(infoName, pFileName);
wcscat(infoName, L".info");
m_hInfoFile = ::CreateFileW(infoName, // The filename
(DWORD) GENERIC_READ, // File access
(DWORD) (FILE_SHARE_READ |
FILE_SHARE_WRITE), // Share access
NULL, // Security
(DWORD) OPEN_EXISTING, // Open flags
// (DWORD) 0,
(DWORD) FILE_ATTRIBUTE_NORMAL, // More flags
// FILE_FLAG_SEQUENTIAL_SCAN, // More flags
// FILE_ATTRIBUTE_NORMAL |
// FILE_FLAG_RANDOM_ACCESS, // More flags
NULL);
//LogDebug("FileReader::OpenFile() info file handle %i", m_hInfoFile);
SetFilePointer(0, FILE_BEGIN);
m_llBufferPointer = 0;
return S_OK;
} // Open
//
// CloseFile
//
// Closes any dump file we have opened
//
HRESULT FileReader::CloseFile()
{
// Must lock this section to prevent problems related to
// closing the file while still receiving data in Receive()
if (m_hFile == INVALID_HANDLE_VALUE)
{
LogDebug("FileReader::CloseFile() no open file");
return S_OK;
}
//LogDebug("FileReader::CloseFile() handle %i %ws", m_hFile, m_pFileName);
//LogDebug("FileReader::CloseFile() info file handle %i", m_hInfoFile);
// BoostThread Boost;
::CloseHandle(m_hFile);
m_hFile = INVALID_HANDLE_VALUE; // Invalidate the file
if (m_hInfoFile != INVALID_HANDLE_VALUE)
::CloseHandle(m_hInfoFile);
m_hInfoFile = INVALID_HANDLE_VALUE; // Invalidate the file
m_llBufferPointer = 0;
return NOERROR;
} // CloseFile
BOOL FileReader::IsFileInvalid()
{
return (m_hFile == INVALID_HANDLE_VALUE);
}
HRESULT FileReader::GetFileSize(__int64 *pStartPosition, __int64 *pLength)
{
//CheckPointer(pStartPosition,E_POINTER);
//CheckPointer(pLength,E_POINTER);
// BoostThread Boost;
GetStartPosition(pStartPosition);
//Do not get file size if static file or first time
if (m_bReadOnly || !m_fileSize) {
if (m_hInfoFile != INVALID_HANDLE_VALUE)
{
__int64 length = -1;
DWORD read = 0;
LARGE_INTEGER li;
li.QuadPart = 0;
::SetFilePointer(m_hInfoFile, li.LowPart, &li.HighPart, FILE_BEGIN);
::ReadFile(m_hInfoFile, (PVOID)&length, (DWORD)sizeof(__int64), &read, NULL);
if(length > -1)
{
m_fileSize = length;
*pLength = length;
return S_OK;
}
}
DWORD dwSizeLow;
DWORD dwSizeHigh;
dwSizeLow = ::GetFileSize(m_hFile, &dwSizeHigh);
if ((dwSizeLow == 0xFFFFFFFF) && (GetLastError() != NO_ERROR ))
{
return E_FAIL;
}
LARGE_INTEGER li;
li.LowPart = dwSizeLow;
li.HighPart = dwSizeHigh;
m_fileSize = li.QuadPart;
}
*pLength = m_fileSize;
return S_OK;
}
HRESULT FileReader::GetInfoFileSize(__int64 *lpllsize)
{
//Do not get file size if static file or first time
if (m_bReadOnly || !m_infoFileSize) {
DWORD dwSizeLow;
DWORD dwSizeHigh;
// BoostThread Boost;
dwSizeLow = ::GetFileSize(m_hInfoFile, &dwSizeHigh);
if ((dwSizeLow == 0xFFFFFFFF) && (GetLastError() != NO_ERROR ))
{
return E_FAIL;
}
LARGE_INTEGER li;
li.LowPart = dwSizeLow;
li.HighPart = dwSizeHigh;
m_infoFileSize = li.QuadPart;
}
*lpllsize = m_infoFileSize;
return S_OK;
}
HRESULT FileReader::GetStartPosition(__int64 *lpllpos)
{
//Do not get file size if static file unless first time
if (m_bReadOnly || !m_fileStartPos) {
if (m_hInfoFile != INVALID_HANDLE_VALUE)
{
// BoostThread Boost;
__int64 size = 0;
GetInfoFileSize(&size);
//Check if timeshift info file
if (size > sizeof(__int64))
{
//Get the file start pointer
__int64 length = -1;
DWORD read = 0;
LARGE_INTEGER li;
li.QuadPart = sizeof(__int64);
::SetFilePointer(m_hInfoFile, li.LowPart, &li.HighPart, FILE_BEGIN);
::ReadFile(m_hInfoFile, (PVOID)&length, (DWORD)sizeof(__int64), &read, NULL);
if(length > -1)
{
m_fileStartPos = length;
*lpllpos = length;
return S_OK;
}
}
}
m_fileStartPos = 0;
}
*lpllpos = m_fileStartPos;
return S_OK;
}
DWORD FileReader::SetFilePointer(__int64 llDistanceToMove, DWORD dwMoveMethod)
{
// BoostThread Boost;
LARGE_INTEGER li;
if (dwMoveMethod == FILE_END && m_hInfoFile != INVALID_HANDLE_VALUE)
{
__int64 startPos = 0;
GetStartPosition(&startPos);
if (startPos > 0)
{
__int64 start;
__int64 fileSize = 0;
GetFileSize(&start, &fileSize);
__int64 filePos = (__int64)((__int64)fileSize + (__int64)llDistanceToMove + (__int64)startPos);
if (filePos >= fileSize)
li.QuadPart = (__int64)((__int64)startPos + (__int64)llDistanceToMove);
else
li.QuadPart = filePos;
return ::SetFilePointer(m_hFile, li.LowPart, &li.HighPart, FILE_BEGIN);
}
__int64 start = 0;
__int64 length = 0;
GetFileSize(&start, &length);
length = (__int64)((__int64)length + (__int64)llDistanceToMove);
li.QuadPart = length;
dwMoveMethod = FILE_BEGIN;
}
else
{
__int64 startPos = 0;
GetStartPosition(&startPos);
if (startPos > 0)
{
__int64 start;
__int64 fileSize = 0;
GetFileSize(&start, &fileSize);
__int64 filePos = (__int64)((__int64)startPos + (__int64)llDistanceToMove);
if (filePos >= fileSize)
li.QuadPart = (__int64)((__int64)filePos - (__int64)fileSize);
else
li.QuadPart = filePos;
return ::SetFilePointer(m_hFile, li.LowPart, &li.HighPart, dwMoveMethod);
}
li.QuadPart = llDistanceToMove;
}
return ::SetFilePointer(m_hFile, li.LowPart, &li.HighPart, dwMoveMethod);
}
__int64 FileReader::GetFilePointer()
{
// BoostThread Boost;
LARGE_INTEGER li;
li.QuadPart = 0;
li.LowPart = ::SetFilePointer(m_hFile, 0, &li.HighPart, FILE_CURRENT);
__int64 start;
__int64 length = 0;
GetFileSize(&start, &length);
__int64 startPos = 0;
GetStartPosition(&startPos);
if (startPos > 0)
{
if(startPos > (__int64)li.QuadPart)
li.QuadPart = (__int64)(length - startPos + (__int64)li.QuadPart);
else
li.QuadPart = (__int64)((__int64)li.QuadPart - startPos);
}
return li.QuadPart;
}
HRESULT FileReader::Read(PBYTE pbData, ULONG lDataLength, ULONG *dwReadBytes)
{
HRESULT hr;
// If the file has already been closed, don't continue
if (m_hFile == INVALID_HANDLE_VALUE)
{
LogDebug("FileReader::Read() no open file");
return E_FAIL;
}
// BoostThread Boost;
//Get File Position
LARGE_INTEGER li;
li.QuadPart = 0;
li.LowPart = ::SetFilePointer(m_hFile, 0, &li.HighPart, FILE_CURRENT);
DWORD dwErr = ::GetLastError();
if ((DWORD)li.LowPart == (DWORD)0xFFFFFFFF && dwErr)
{
LogDebug("FileReader::Read() seek failed");
return E_FAIL;
}
__int64 m_filecurrent = li.QuadPart;
if (m_hInfoFile != INVALID_HANDLE_VALUE)
{
__int64 startPos = 0;
GetStartPosition(&startPos);
if (startPos > 0)
{
__int64 start;
__int64 length = 0;
GetFileSize(&start, &length);
if (length < (__int64)(m_filecurrent + (__int64)lDataLength) && m_filecurrent > startPos)
{
hr = ::ReadFile(m_hFile, (PVOID)pbData, (DWORD)max(0,(length - m_filecurrent)), dwReadBytes, NULL);
if (!hr)
return E_FAIL;
LARGE_INTEGER li;
li.QuadPart = 0;
hr = ::SetFilePointer(m_hFile, li.LowPart, &li.HighPart, FILE_BEGIN);
DWORD dwErr = ::GetLastError();
if ((DWORD)hr == (DWORD)0xFFFFFFFF && dwErr)
{
return E_FAIL;
}
ULONG dwRead = 0;
hr = ::ReadFile(m_hFile,
(PVOID)(pbData + (DWORD)max(0,(length - m_filecurrent))),
(DWORD)max(0,((__int64)lDataLength -(__int64)(length - m_filecurrent))),
&dwRead,
NULL);
*dwReadBytes = *dwReadBytes + dwRead;
}
else if (startPos < (__int64)(m_filecurrent + (__int64)lDataLength) && m_filecurrent < startPos)
hr = ::ReadFile(m_hFile, (PVOID)pbData, (DWORD)max(0,(startPos - m_filecurrent)), dwReadBytes, NULL);
else
hr = ::ReadFile(m_hFile, (PVOID)pbData, (DWORD)lDataLength, dwReadBytes, NULL);
if (!hr)
return S_FALSE;
if (*dwReadBytes < (ULONG)lDataLength)
{
return E_FAIL;
}
return S_OK;
}
__int64 start = 0;
__int64 length = 0;
GetFileSize(&start, &length);
if (length < (__int64)(m_filecurrent + (__int64)lDataLength))
hr = ::ReadFile(m_hFile, (PVOID)pbData, (DWORD)max(0,(length - m_filecurrent)), dwReadBytes, NULL);
else
hr = ::ReadFile(m_hFile, (PVOID)pbData, (DWORD)lDataLength, dwReadBytes, NULL);
}
else
hr = ::ReadFile(m_hFile, (PVOID)pbData, (DWORD)lDataLength, dwReadBytes, NULL);//Read file data into buffer
if (!hr)
{
LogDebug("FileReader::Read() read failed - error = %d", HRESULT_FROM_WIN32(GetLastError()));
return E_FAIL;
}
if (*dwReadBytes < (ULONG)lDataLength)
{
LogDebug("FileReader::Read() read to less bytes");
return S_FALSE;
}
return S_OK;
}
HRESULT FileReader::Read(PBYTE pbData, ULONG lDataLength, ULONG *dwReadBytes, __int64 llDistanceToMove, DWORD dwMoveMethod)
{
// BoostThread Boost;
//If end method then we want llDistanceToMove to be the end of the buffer that we read.
if (dwMoveMethod == FILE_END)
llDistanceToMove = 0 - llDistanceToMove - lDataLength;
SetFilePointer(llDistanceToMove, dwMoveMethod);
return Read(pbData, lDataLength, dwReadBytes);
}
HRESULT FileReader::get_ReadOnly(WORD *ReadOnly)
{
*ReadOnly = m_bReadOnly;
return S_OK;
}
HRESULT FileReader::get_DelayMode(WORD *DelayMode)
{
*DelayMode = m_bDelay;
return S_OK;
}
HRESULT FileReader::set_DelayMode(WORD DelayMode)
{
m_bDelay = DelayMode;
return S_OK;
}
HRESULT FileReader::get_ReaderMode(WORD *ReaderMode)
{
*ReaderMode = FALSE;
return S_OK;
}
void FileReader::SetDebugOutput(BOOL bDebugOutput)
{
m_bDebugOutput = bDebugOutput;
}
DWORD FileReader::setFilePointer(__int64 llDistanceToMove, DWORD dwMoveMethod)
{
//Get the file information
__int64 fileStart, fileEnd, fileLength;
GetFileSize(&fileStart, &fileLength);
fileEnd = fileLength;
if (dwMoveMethod == FILE_BEGIN)
return SetFilePointer((__int64)min(fileEnd, llDistanceToMove), FILE_BEGIN);
else
return SetFilePointer((__int64)max((__int64)-fileLength, llDistanceToMove), FILE_END);
}
__int64 FileReader::getFilePointer()
{
return GetFilePointer();
}
__int64 FileReader::getBufferPointer()
{
return m_llBufferPointer;
}
void FileReader::setBufferPointer()
{
m_llBufferPointer = GetFilePointer();
}
__int64 FileReader::GetFileSize()
{
__int64 pStartPosition =0;
__int64 pLength=0;
GetFileSize(&pStartPosition, &pLength);
return pLength;
} | [
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]"
]
| [
[
[
1,
25
],
[
27,
27
],
[
32,
48
],
[
52,
56
],
[
59,
62
],
[
65,
65
],
[
68,
68
],
[
70,
70
],
[
79,
79
],
[
81,
81
],
[
83,
92
],
[
94,
122
],
[
136,
136
],
[
141,
144
],
[
148,
150
],
[
154,
155
],
[
165,
165
],
[
174,
174
],
[
177,
180
],
[
183,
183
],
[
187,
187
],
[
190,
190
],
[
192,
193
],
[
196,
218
],
[
222,
309
],
[
312,
529
],
[
531,
617
]
],
[
[
26,
26
],
[
28,
31
],
[
49,
51
],
[
57,
58
],
[
63,
64
],
[
66,
67
],
[
69,
69
],
[
71,
78
],
[
80,
80
],
[
82,
82
],
[
125,
135
],
[
137,
139
],
[
145,
147
],
[
151,
153
],
[
175,
176
],
[
181,
182
],
[
184,
186
],
[
188,
189
],
[
191,
191
],
[
194,
195
],
[
219,
221
],
[
310,
311
],
[
530,
530
]
],
[
[
93,
93
],
[
123,
124
],
[
140,
140
],
[
156,
164
],
[
166,
168
],
[
170,
173
]
],
[
[
169,
169
]
]
]
|
97a0fa15a835156468e27574e363a310695e1425 | bf9e82f027caeff04cca5c16b327f33e59bfaf7a | /fce360/fceux/xbox/config_reader.h | 8ab2b5140d046c2855163eec881dce004a1f3724 | []
| no_license | Miitumrow27/fce360 | 654de5d31223564a16299cfb84a2a4a7031791c3 | fe388a88c18ea4c460f5aecb9c26bf6f13544e79 | refs/heads/master | 2020-05-05T02:01:05.998655 | 2011-01-24T20:05:22 | 2011-01-24T20:05:22 | 40,433,229 | 0 | 0 | null | null | null | null | WINDOWS-1250 | C++ | false | false | 3,534 | h | #include <stdio.h>
#include <stdlib.h>
#include <string>
#include <map>
#include <xtl.h>
#include "simpleIni.h"
#define E_CONFIG_SECTION_NOT_FOUND 0x1000
#define E_CONFIG_KEY_NOT_FOUND 0x1005
#define E_FILE_NOT_FOUND 0x2000
class Config{
private:
//Array contenant la configuration
typedef std::map<std::string, std::string> Config_k_v_map;
typedef std::map<std::string, Config_k_v_map> Sections_map;
//Config_k_v_map mapConfig;
Sections_map m_config;
public:
HRESULT Find(std::string section, std::string key, std::string & value){
Sections_map::iterator it;
//recherche
it=m_config.find(section);
//Pas trouvé
if(it == m_config.end())
{
return E_CONFIG_SECTION_NOT_FOUND;
}
else
{
//copie la valeur
//value = it->second;
Config_k_v_map mapConfig = it->second;
Config_k_v_map::iterator cit;
cit=mapConfig.find(key);
//pas trouvé
if(cit == mapConfig.end())
{
return E_CONFIG_SECTION_NOT_FOUND;
}
else
{
value = cit->second;
}
return S_OK;
}
};
HRESULT Find(std::string section, std::string key, unsigned long & value){
if(key.length()){
std::string buffer;
if(SUCCEEDED(Find(section, key,buffer)))
{
value = atoi (buffer.c_str());
return S_OK;
}
return E_CONFIG_SECTION_NOT_FOUND;
}
else
return E_FAIL;
};
HRESULT Set(std::string section, std::string key, std::string value){
if(section.length())
{
if(key.length()){
Config_k_v_map mapConfig;
if(m_config.find(section.c_str()) != m_config.end())
mapConfig = m_config.find(section.c_str())->second;
mapConfig[key]=value;
m_config[section]=mapConfig;
return S_OK;
}
}
return E_FAIL;
};
HRESULT Set(std::string section, std::string key, unsigned long value){
char buffer [33];//32+1
sprintf(buffer,"%d",value);
return Set(section,key,buffer);
};
HRESULT Find(std::string section, std::string key, int & value){
return Find(section, key,(unsigned long &)value);
};
HRESULT Save(std::string filename){
//parse each line
CSimpleIniA ini;
SI_Error rc;
Sections_map::iterator jit;
for ( jit=m_config.begin() ; jit != m_config.end(); jit++ )
{
Config_k_v_map mapConfig = jit->second;
Config_k_v_map::iterator it;
//sauvegarde tous les membres
for ( it=mapConfig.begin() ; it != mapConfig.end(); it++ )
{
//save each line
rc = ini.SetValue(jit->first.c_str(), (*it).first.c_str(), (*it).second.c_str());
if(rc<0)
return rc;
}
}
rc = ini.SaveFile(filename.c_str());
if(rc<0)
return E_FILE_NOT_FOUND;
return S_OK;
};
HRESULT Load(std::string filename){
//parse each line
CSimpleIniA ini;
if (ini.LoadFile(filename.c_str()) < 0)
{
return E_FILE_NOT_FOUND;
}
CSimpleIniA::TNamesDepend::const_iterator it;
CSimpleIniA::TNamesDepend names;
ini.GetAllSections(names);
for(it = names.begin(); it != names.end(); ++it)
{
const CSimpleIniA::TKeyVal * kval = ini.GetSection(it->pItem);
if(kval==NULL)
return E_FAIL;
Config_k_v_map mapConfig;
//iterate all keys
CSimpleIniA::TKeyVal::const_iterator i;
for (i = kval->begin(); i != kval->end(); ++i)
{
const char * key = i->first.pItem;
const char * val = i->second;
mapConfig[key]=val;
}
m_config[it->pItem]=mapConfig;
}
return S_OK;
};
};
| [
"Ced2911@1f2d827f-b39e-40f8-2521-43ba25b7e373"
]
| [
[
[
1,
160
]
]
]
|
fbec40f63303403b4ae0e1b2a3ee92168611efad | 0f8559dad8e89d112362f9770a4551149d4e738f | /Wall_Destruction/Havok/Source/Physics/Vehicle/Transmission/hkpVehicleTransmission.h | bea8d171920e09a43654730004f2940a7b098e25 | []
| no_license | TheProjecter/olafurabertaymsc | 9360ad4c988d921e55b8cef9b8dcf1959e92d814 | 456d4d87699342c5459534a7992f04669e75d2e1 | refs/heads/master | 2021-01-10T15:15:49.289873 | 2010-09-20T12:58:48 | 2010-09-20T12:58:48 | 45,933,002 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,496 | h | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2009 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HKVEHICLE_TRANSMISSION_hkVehicleTRANSMISSION_XML_H
#define HKVEHICLE_TRANSMISSION_hkVehicleTRANSMISSION_XML_H
#include <Common/Base/hkBase.h>
class hkpVehicleInstance;
/// The hkpVehicleTransmission of a vehicle is responsible for calculating all the
/// information associated with the gear system of a vehicle, including the
/// vehicle's current gear, and whether it is reversing. It also deals with the
/// torque and rpm transmission between the vehicle engine and the different wheels.
/// This component usually collaborates with the hkpVehicleEngine, the
/// hkpVehicleDriverInput and the hkpVehicleInstance in order to calculate its new
/// state.
class hkpVehicleTransmission : public hkReferencedObject
{
public:
HK_DECLARE_CLASS_ALLOCATOR(HK_MEMORY_CLASS_VEHICLE);
HK_DECLARE_REFLECTION();
/// Container for data output by the transmission calculations.
struct TransmissionOutput
{
public:
HK_DECLARE_NONVIRTUAL_CLASS_ALLOCATOR( HK_MEMORY_CLASS_VEHICLE, hkpVehicleTransmission::TransmissionOutput );
/// The RPM transferred through the transmission.
hkReal m_transmissionRPM;
/// The torque transferred through the transmission.
hkReal m_mainTransmittedTorque;
/// The torqued transmitted to each wheel.
hkReal* m_wheelsTransmittedTorque;
/// The number of wheels.
hkInt8 m_numWheelsTramsmittedTorque;
/// Indicates if the vehicle is actually reversing at the moment.
hkBool m_isReversing;
/// The gear currently in. This variable is also stored in the vehicle.
hkInt8 m_currentGear;
/// Set true to use the clutch delay, ie to wait a short time before changing gear.
hkBool m_delayed;
/// The clutch delay specifies how long to wait before changing gear.
hkReal m_clutchDelayCountdown;
};
//
// Methods
//
/// Calculates information about the effects of transmission on the vehicle.
virtual void calcTransmission(const hkReal deltaTime, const hkpVehicleInstance* vehicle, TransmissionOutput& transmissionOut) = 0;
public:
hkpVehicleTransmission(hkFinishLoadedObjectFlag flag) : hkReferencedObject(flag) {}
protected:
hkpVehicleTransmission() {}
};
#endif // HKVEHICLE_TRANSMISSION_hkVehicleTRANSMISSION_XML_H
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20091222)
*
* Confidential Information of Havok. (C) Copyright 1999-2009
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at www.havok.com/tryhavok.
*
*/
| [
"[email protected]"
]
| [
[
[
1,
91
]
]
]
|
e766a70ce4368ac0f477b3b50c387a0406b76860 | 8346a9e40ff890a56ec1a0b29e63ab6d2069a218 | /WebConfigCPP/Test/CaptureScreen.cpp | 6e3237d34459b597070bb978c2849ffbacfdd033 | [
"MIT"
]
| permissive | dave-mcclurg/web-config | 3f68c0ee14335396b66b17625c229e2d971b66f9 | 4174d087ca609725dd77a36fc16facd51c922400 | refs/heads/master | 2021-01-20T11:20:17.265829 | 2010-01-04T01:26:19 | 2010-01-04T01:26:19 | 32,268,994 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,257 | cpp | #include "CaptureScreen.h"
using namespace std;
#define Width(r) (r.right - r.left + 1)
#define Height(r) (r.bottom - r.top + 1)
static void WriteBMPFile(HBITMAP bitmap, const char* filename, HDC hDC)
{
BITMAP bmp;
PBITMAPINFO pbmi;
WORD cClrBits;
HANDLE hf; // file handle
BITMAPFILEHEADER hdr; // bitmap file-header
PBITMAPINFOHEADER pbih; // bitmap info-header
LPBYTE lpBits; // memory pointer
DWORD dwTotal; // total count of bytes
DWORD cb; // incremental count of bytes
BYTE *hp; // byte pointer
DWORD dwTmp;
// create the bitmapinfo header information
if (!GetObject(bitmap, sizeof(BITMAP), (LPVOID)&bmp))
{
//AfxMessageBox("Could not retrieve bitmap info");
return;
}
// Convert the color format to a count of bits.
cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel);
if (cClrBits == 1)
cClrBits = 1;
else if (cClrBits <= 4)
cClrBits = 4;
else if (cClrBits <= 8)
cClrBits = 8;
else if (cClrBits <= 16)
cClrBits = 16;
else if (cClrBits <= 24)
cClrBits = 24;
else cClrBits = 32;
// Allocate memory for the BITMAPINFO structure.
if (cClrBits != 24)
pbmi = (PBITMAPINFO) LocalAlloc(LPTR,
sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * (1<< cClrBits));
else
pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER));
// Initialize the fields in the BITMAPINFO structure.
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biWidth = bmp.bmWidth;
pbmi->bmiHeader.biHeight = bmp.bmHeight;
pbmi->bmiHeader.biPlanes = bmp.bmPlanes;
pbmi->bmiHeader.biBitCount = bmp.bmBitsPixel;
if (cClrBits < 24)
pbmi->bmiHeader.biClrUsed = (1<<cClrBits);
// If the bitmap is not compressed, set the BI_RGB flag.
pbmi->bmiHeader.biCompression = BI_RGB;
// Compute the number of bytes in the array of color
// indices and store the result in biSizeImage.
pbmi->bmiHeader.biSizeImage = (pbmi->bmiHeader.biWidth + 7) /8 * pbmi->bmiHeader.biHeight * cClrBits;
// Set biClrImportant to 0, indicating that all of the
// device colors are important.
pbmi->bmiHeader.biClrImportant = 0;
// now open file and save the data
pbih = (PBITMAPINFOHEADER) pbmi;
lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);
if (!lpBits) {
//AfxMessageBox("writeBMP::Could not allocate memory");
return;
}
// Retrieve the color table (RGBQUAD array) and the bits
if (!GetDIBits(hDC, HBITMAP(bitmap), 0, (WORD) pbih->biHeight, lpBits, pbmi,
DIB_RGB_COLORS)) {
//AfxMessageBox("writeBMP::GetDIB error");
return;
}
// Create the .BMP file.
hf = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, (DWORD) 0,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
(HANDLE) NULL);
if (hf == INVALID_HANDLE_VALUE){
//AfxMessageBox("Could not create file for writing");
return;
}
hdr.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M"
// Compute the size of the entire file.
hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) +
pbih->biSize + pbih->biClrUsed
* sizeof(RGBQUAD) + pbih->biSizeImage);
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;
// Compute the offset to the array of color indices.
hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) +
pbih->biSize + pbih->biClrUsed
* sizeof (RGBQUAD);
// Copy the BITMAPFILEHEADER into the .BMP file.
if (!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER),
(LPDWORD) &dwTmp, NULL)) {
//AfxMessageBox("Could not write in to file");
return;
}
// Copy the BITMAPINFOHEADER and RGBQUAD array into the file.
if (!WriteFile(hf, (LPVOID) pbih, sizeof(BITMAPINFOHEADER)
+ pbih->biClrUsed * sizeof (RGBQUAD),
(LPDWORD) &dwTmp, ( NULL))){
//AfxMessageBox("Could not write in to file");
return;
}
// Copy the array of color indices into the .BMP file.
dwTotal = cb = pbih->biSizeImage;
hp = lpBits;
if (!WriteFile(hf, (LPSTR) hp, (int) cb, (LPDWORD) &dwTmp,NULL)){
//AfxMessageBox("Could not write in to file");
return;
}
// Close the .BMP file.
if (!CloseHandle(hf)){
//AfxMessageBox("Could not close file");
return;
}
// Free memory.
GlobalFree((HGLOBAL)lpBits);
}
void CaptureScreen(HWND hDesktopWnd, string bmpFilename)
{
RECT rectClient;
RECT rectWindow;
GetClientRect(hDesktopWnd, &rectClient);
GetWindowRect(hDesktopWnd, &rectWindow);
int x = (Width(rectWindow) - Width(rectClient)) / 2;
int y = (Height(rectWindow) - Height(rectClient)) - x;
HDC hDesktopDC = ::GetDC(hDesktopWnd);
HDC hCaptureDC = ::CreateCompatibleDC(hDesktopDC);
int xSrc = -x;
int ySrc = -y;
int nScreenWidth = Width(rectWindow);
int nScreenHeight = Height(rectWindow);
HBITMAP hCaptureBitmap = ::CreateCompatibleBitmap(hDesktopDC, nScreenWidth, nScreenHeight);
SelectObject(hCaptureDC, hCaptureBitmap);
BitBlt(hCaptureDC,
0,
0,
nScreenWidth,
nScreenHeight,
hDesktopDC,
xSrc,
ySrc,
SRCCOPY | CAPTUREBLT);
WriteBMPFile(hCaptureBitmap, bmpFilename.c_str(), hCaptureDC);
::ReleaseDC(hDesktopWnd,hDesktopDC);
::DeleteDC(hCaptureDC);
::DeleteObject(hCaptureBitmap);
}
| [
"dave.mcclurg@d4c24e94-de21-11de-aa1f-bbd297b2055c"
]
| [
[
[
1,
178
]
]
]
|
8b2736c5987323bf6e7fea567bce9a5038a4e21b | 989aa92c9dab9a90373c8f28aa996c7714a758eb | /HydraIRC/Common.cpp | 2df9819bedb3dec9559b6a4491ed67a3971a97f9 | []
| no_license | john-peterson/hydrairc | 5139ce002e2537d4bd8fbdcebfec6853168f23bc | f04b7f4abf0de0d2536aef93bd32bea5c4764445 | refs/heads/master | 2021-01-16T20:14:03.793977 | 2010-04-03T02:10:39 | 2010-04-03T02:10:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,122 | cpp | /*
HydraIRC
Copyright (C) 2002-2006 Dominic Clifton aka Hydra
HydraIRC limited-use source license
1) You can:
1.1) Use the source to create improvements and bug-fixes to send to the
author to be incorporated in the main program.
1.2) Use it for review/educational purposes.
2) You can NOT:
2.1) Use the source to create derivative works. (That is, you can't release
your own version of HydraIRC with your changes in it)
2.2) Compile your own version and sell it.
2.3) Distribute unmodified, modified source or compiled versions of HydraIRC
without first obtaining permission from the author. (I want one place
for people to come to get HydraIRC from)
2.4) Use any of the code or other part of HydraIRC in anything other than
HydraIRC.
3) All code submitted to the project:
3.1) Must not be covered by any license that conflicts with this license
(e.g. GPL code)
3.2) Will become the property of the author.
*/
// Common.cpp : comment here
//
// These routines are common to both IRCClient and IRCServer
// they mainly deal with text buffering
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "HydraIRC.h"
// forward declare
CChildCommon *FindChildWindow(HWND hWnd);
void IRCCommon::ProcessOutputBuffer( void )
{
#ifdef VERBOSE_DEBUG
sys_printf(BIC_FUNCTION,"IRCCommon::ProcessOutputBuffer()\n");
#endif
// process the buffer if we have text in it
// but keep the buffer for later if the window's not open yet.
if (m_pChildWnd)
{
CChildFrame *pChildFrame = CHILDFRAMEPTR(m_pChildWnd);
switch (m_ObjectType)
{
case OTYPE_QUERY:
case OTYPE_CHANNEL:
case OTYPE_SERVER:
case OTYPE_DCCCHAT:
// there are several ways of handling this:
// 1) process 1 line for 1 message.
// NOTE: this kinda works, but because we can add lines to
// the buffer before the window exists we can end up with
// lines in the buffer that don't get processed immediately.
// 2) process entire buffer when we get a message
// (we'll get several messages that we don't do anything with though..)
// NOTE: This works fine, except that user input is delayed while we process
// the buffer, which can take a while if we have alot to process.
// 3) process some of the buffer when we get a message
// and post another message if there's some left.
// 4) process 1 line for 1 message
// post another message if there's some left.
//
// Tried method 2, see notes, tried 1, see notes, going with 4..
// Method 4
// Process, a single line of the buffer
// Then send another message if any remaining buffer
// sometimes we have already processed the buffer
// by the time we process the message.
// as ProcessBuffer() is also called just after creation.
if (!(m_OutputBuffer.GetSize() > 0))
break;
BufferItem *pBI = m_OutputBuffer[0];
pChildFrame->m_MsgView.Put(pBI->m_Contents, pBI->m_Buffer,&pBI->m_Time);
// Slap it over to the channel monitor too..
if (m_ObjectType == CWTYPE_CHANNEL)
{
if (g_pMainWnd->m_ChannelMonitorView.IsMonitoring(pChildFrame->m_pChannel))
{
g_pMainWnd->m_ChannelMonitorView.Put(pChildFrame->m_pChannel,pBI);
}
}
// Slap it over to the server monitor too..
if (m_ObjectType == CWTYPE_SERVER)
{
if (g_pMainWnd->m_ServerMonitorView.IsMonitoring(pChildFrame->m_pServer))
{
g_pMainWnd->m_ServerMonitorView.Put(pChildFrame->m_pServer,pBI);
}
}
m_OutputBuffer.RemoveAt(0);
delete pBI;
// more waiting ?
if (m_OutputBuffer.GetSize() > 0)
{
m_pChildWnd->PostMessage(WM_BUFFERWAITING,0,0);
}
// Method 2
/*
while (m_OutputBuffer.GetSize() > 0)
{
// Process, display and then free each buffer
BufferItem *pBI = m_OutputBuffer[0];
pChildFrame->m_MsgView.Put(pBI->m_Contents, pBI->m_Buffer);
// Slap it over to the channel monitor too..
if (m_ObjectType == CWTYPE_CHANNEL)
{
if (g_pMainWnd->m_ChannelMonitorView.IsMonitoring(pChildFrame->m_pChannel))
{
g_pMainWnd->m_ChannelMonitorView.Put(pChildFrame->m_pChannel,pBI);
}
}
m_OutputBuffer.RemoveAt(0);
delete pBI;
}
*/
break;
}
}
#ifdef VERBOSE_DEBUG
sys_printf(BIC_FUNCTION,"Exiting IRCCommon::ProcessOutputBuffer()\n");
#endif
}
// note, DO NOT FREE Buffer after calling, Buffer is freed after it is processed.
void IRCCommon::AddToOutputBuffer(int Contents, char *Buffer)
{
time(&m_LastActivityTime);
if (m_pChildWnd && !::IsWindow(m_pChildWnd->m_hWnd))
return;
// Set the dirty flag is the window is NOT active, (or the window is active, but hidden)
if (!ProcessSimpleFilter(m_DirtyFilterList,Contents))
{
time(&m_DirtyTime); // update the time of the last thing that made the window dirty
if (!(m_Dirty & DIRTY_RECENT))
{
m_Dirty |= DIRTY_RECENT;// if we didn't filter it, then set the DIRTY_RECENT flag.
if (!(m_Dirty & DIRTY_TRUE)) // speed things up a bit!
{
HWND hWnd = g_pMainWnd->MDIGetActive();
if (m_pChildWnd &&
((m_pChildWnd->m_hWnd != hWnd) ||
(m_pChildWnd->m_hWnd == hWnd && !m_pChildWnd->IsWindowVisible() )) )
{
m_Dirty |= DIRTY_TRUE; // if we didn't filter it, then set the DIRTY_TRUE flag.
}
}
}
}
m_TicksSinceLastBufferAdd = 0;
m_OutputBuffer.Add(new BufferItem(Contents,Buffer));
if (m_pChildWnd)
m_pChildWnd->PostMessage(WM_BUFFERWAITING,0,0);
}
#define IRCCOMMON_PRINTF_BUFSIZE 1024
/** Output some text to the output view
*
* NOTE: you must only send one line of text with each Put()
* the function handles it ok, but we need to count the lines
* of text in the buffer somehow...
* ad we need to know what each line contains, so it can be filtered.
*/
void IRCCommon::Printf(const int Contents, const char *format, ...)
{
if (!format)
return;
va_list args;
char *buf;
buf = (char *)malloc(IRCCOMMON_PRINTF_BUFSIZE);
if (buf)
{
ZeroMemory(buf, IRCCOMMON_PRINTF_BUFSIZE);
va_start(args, format);
_vsnprintf(buf, IRCCOMMON_PRINTF_BUFSIZE, format, args);
va_end(args);
buf[IRCCOMMON_PRINTF_BUFSIZE-1] = 0;
AddToOutputBuffer(Contents, buf);
// Note: buf is freed automatically later
}
}
void IRCCommon::ClearOutputBuffer( void )
{
// free any items remaining the the output buffer
while (m_OutputBuffer.GetSize() > 0)
{
delete m_OutputBuffer[0];
m_OutputBuffer.RemoveAt(0);
}
m_TicksSinceLastBufferAdd = 0;
}
void IRCCommon::BufferTick( void )
{
m_TicksSinceLastBufferAdd++;
}
// returns TRUE if theme was changed.
BOOL IRCCommon::SetTheme(char *ThemeName)
{
ThemeHandle *pNewTheme = g_ThemeManager.GetThemeHandle(ThemeName);
if (!pNewTheme) // make sure there was no problem getting the new theme...
return FALSE;
BOOL Changed = (m_pTheme != pNewTheme);
g_ThemeManager.ReleaseThemeHandle(m_pTheme);
m_pTheme = pNewTheme;
return Changed;
}
void IRCCommon::ClearUserList( void )
{
m_Users.DeleteAll();
if (m_pChildWnd)
{
CHILDFRAMEPTR(m_pChildWnd)->m_UserListView.RemoveAll();
}
// if the global user list is pointing at this window, then clear it.
// because we just free()'d the users!
if (g_pMainWnd->m_UserListView.m_pChannel == this)
{
g_pMainWnd->ClearGlobalUserList();
}
}
| [
"hydra@b2473a34-e2c4-0310-847b-bd686bddb4b0"
]
| [
[
[
1,
263
]
]
]
|
69b7c5ee562dac76c837205e8deb53ae3b75db47 | 97fd2a81a3baffb26dc5b627c08aa4a69574a761 | /src/DrStrangecodeRssReader.cpp | 0a35092ebe8c76db68996c7da62b1f724c9cf560 | []
| no_license | drstrangecode/Bada_RssReader_DrStrangecode | c4c61dacabacf9419a0335d70a141dc8374c8b2e | b3cf7b1f6afc43af782c0713fa6b54b1e95d0c1a | refs/heads/master | 2016-09-06T05:34:10.075095 | 2011-10-16T16:08:46 | 2011-10-16T16:08:46 | 2,542,044 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,892 | cpp | /**
* Name : DrStrangecodeRssReader
* Version :
* Vendor :
* Description :
*/
#include "DrStrangecodeRssReader.h"
#include "MainForm.h"
#include "ItemForm.h"
#include "Settings.h"
using namespace Osp::App;
using namespace Osp::Base;
using namespace Osp::System;
using namespace Osp::Ui;
using namespace Osp::Ui::Controls;
DrStrangecodeRssReader::DrStrangecodeRssReader()
{
}
DrStrangecodeRssReader::~DrStrangecodeRssReader()
{
}
Application*
DrStrangecodeRssReader::CreateInstance(void)
{
// Create the instance through the constructor.
return new DrStrangecodeRssReader();
}
bool
DrStrangecodeRssReader::OnAppInitializing(AppRegistry& appRegistry)
{
// Create a form
MainForm *pMainForm = new MainForm();
pMainForm->Initialize();
pMainForm->SetName(kMainFormNameString);
ItemForm * pItemForm = new ItemForm();
pItemForm->Initialize();
pItemForm->SetName(kItemFormNameString);
// Add the form to the frame
Frame *pFrame = GetAppFrame()->GetFrame();
pFrame->AddControl(*pMainForm);
pFrame->AddControl(*pItemForm);
// Set the current form
pFrame->SetCurrentForm(*pMainForm);
// Draw and Show the form
pMainForm->Draw();
pMainForm->Show();
return true;
}
bool
DrStrangecodeRssReader::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination)
{
// TODO:
// Deallocate resources allocated by this application for termination.
// The application's permanent data and context can be saved via appRegistry.
return true;
}
void
DrStrangecodeRssReader::OnForeground(void)
{
// TODO:
// Start or resume drawing when the application is moved to the foreground.
}
void
DrStrangecodeRssReader::OnBackground(void)
{
// TODO:
// Stop drawing when the application is moved to the background.
}
void
DrStrangecodeRssReader::OnLowMemory(void)
{
// TODO:
// Free unused resources or close the application.
}
void
DrStrangecodeRssReader::OnBatteryLevelChanged(BatteryLevel batteryLevel)
{
// TODO:
// Handle any changes in battery level here.
// Stop using multimedia features(camera, mp3 etc.) if the battery level is CRITICAL.
}
void
DrStrangecodeRssReader::OnScreenOn (void)
{
// TODO:
// Get the released resources or resume the operations that were paused or stopped in OnScreenOff().
}
void
DrStrangecodeRssReader::OnScreenOff (void)
{
// TODO:
// Unless there is a strong reason to do otherwise, release resources (such as 3D, media, and sensors) to allow the device to enter the sleep mode to save the battery.
// Invoking a lengthy asynchronous method within this listener method can be risky, because it is not guaranteed to invoke a callback before the device enters the sleep mode.
// Similarly, do not perform lengthy operations in this listener method. Any operation must be a quick one.
}
| [
"[email protected]"
]
| [
[
[
1,
116
]
]
]
|
5ecc471eb13f9625694f10a7283b73d806c589a7 | 28aa891f07cc2240c771b5fb6130b1f4025ddc84 | /src/pbr_ctrl/main.cpp | 76b4f452b0d84ddc16b4f8d77862c98bee1ed7af | []
| no_license | Hincoin/mid-autumn | e7476d8c9826db1cc775028573fc01ab3effa8fe | 5271496fb820f8ab1d613a1c2355504251997fef | refs/heads/master | 2021-01-10T19:17:01.479703 | 2011-12-19T14:32:51 | 2011-12-19T14:32:51 | 34,730,620 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 488 | cpp | #include "pbr_ctrl.hpp"
using namespace ma;
int main(int argc,char* argv[])
{
OOLUA::Script lua ;
register_functions(lua);
try
{
if(argc != 4)
{
std::cerr << "Usage: pbr_ctrl <script> <host> <port>"<<std::endl;
return 1;
}
lua.run_file(argv[1]);
boost::asio::io_service io_service;
pbr_ctrl ctrl(lua,io_service,argv[2],argv[3]);
io_service.run();
}
catch(std::exception& e)
{std::cerr<<e.what()<<std::endl; return 1;}
return 0;
}
| [
"luozhiyuan@ea6f400c-e855-0410-84ee-31f796524d81"
]
| [
[
[
1,
26
]
]
]
|
f8031097ba01fd0494f37e2dba8f00350046457f | 42b578d005c2e8870a03fe02807e5607fec68f40 | /src/insdel.cc | 43e952e64cd277753ca1bbe074dab35a260854c9 | [
"MIT"
]
| permissive | hylom/xom | e2b02470cd984d0539ded408d13f9945af6e5f6f | a38841cfe50c3e076b07b86700dfd01644bf4d4a | refs/heads/master | 2021-01-23T02:29:51.908501 | 2009-10-30T08:41:30 | 2009-10-30T08:41:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 51,000 | cc | #include "ed.h"
#include "syntaxinfo.h"
#include "sequence.h"
#include "byte-stream.h"
#ifdef DEBUG
void
Buffer::check_valid () const
{
long nchars = 0;
for (const Chunk *cp = b_chunkb; cp; cp = cp->c_next)
{
nchars += cp->c_used;
if (!cp->c_next)
assert (cp == b_chunke);
}
assert (nchars == b_nchars);
nchars = 0;
for (cp = b_chunke; cp; cp = cp->c_prev)
{
nchars += cp->c_used;
if (!cp->c_prev)
assert (cp == b_chunkb);
}
assert (nchars == b_nchars);
}
#endif /* DEBUG */
void
Buffer::check_read_only () const
{
if (read_only_p ())
FEread_only_buffer ();
}
void
Buffer::prepare_modify_buffer ()
{
if (b_in_post_modified_hook)
FEread_only_buffer ();
if (!b_modified && !verify_modtime ()
&& !yes_or_no_p (Mfile_has_changed_on_disk))
FEplain_error (Eedit_canceled);
if (!file_locked_p () && symbol_value (Slock_file, this) != Qnil
&& lock_file () == Kshared && !yes_or_no_p (Mfile_has_already_locked))
{
unlock_file ();
FEplain_error (Eedit_canceled);
}
}
void
Buffer::modify ()
{
if (!b_modified)
{
b_modified = 1;
modify_mode_line ();
maybe_modify_buffer_bar ();
}
b_modified_count++;
b_nlines = -1;
b_need_auto_save = 1;
b_nfolded = -1;
b_stream_cache.p_chunk = 0;
}
void
Buffer::set_modified_region (point_t p1, point_t p2)
{
b_last_modified = p1;
if (b_modified_region.p1 == -1)
{
b_modified_region.p1 = p1;
b_modified_region.p2 = p2;
}
else
{
b_modified_region.p1 = min (b_modified_region.p1, p1);
b_modified_region.p2 = max (b_modified_region.p2, p2);
}
}
void
Buffer::modify_chunk (Chunk *cp) const
{
cp->c_nlines = -1;
cp->c_nbreaks = -1;
cp->c_bstate = syntax_state::SS_INVALID;
}
void
Buffer::prepare_modify_region (Window *wp, point_t p1, point_t p2)
{
assert (p1 < p2);
assert (p1 >= b_contents.p1);
assert (p2 <= b_contents.p2);
check_read_only ();
prepare_modify_buffer ();
goto_char (wp->w_point, p1);
if (!save_modify_undo (wp->w_point, p2 - p1))
FEstorage_error ();
long size = p2 - p1;
Chunk *cp = wp->w_point.p_chunk;
modify_chunk (cp);
size -= cp->c_used - wp->w_point.p_offset;
for (cp = cp->c_next; cp && size > 0; cp = cp->c_next)
{
modify_chunk (cp);
size -= cp->c_used;
}
modify ();
set_modified_region (p1, p2);
wp->w_disp_flags |= Window::WDF_GOAL_COLUMN;
}
point_t
Buffer::prepare_modify_region (Window *wp, lisp from, lisp to)
{
point_t p1 = coerce_to_restricted_point (from);
point_t p2 = coerce_to_restricted_point (to);
if (p1 == p2)
return -1;
if (p1 > p2)
swap (p1, p2);
prepare_modify_region (wp, p1, p2);
return p2;
}
void
Buffer::set_point (Point &point, point_t goal) const
{
point.p_point = 0;
point.p_chunk = b_chunkb;
point.p_offset = 0;
goto_char (point, goal);
}
void
Buffer::set_point_no_restrictions (Point &point, point_t goal)
{
no_restrictions nr (this);
set_point (point, goal);
}
inline void
move_chunk (Chunk *cp, int src, int dst, int size)
{
if (src != dst)
memmove (cp->c_text + dst, cp->c_text + src, sizeof (Char) * size);
}
inline void
move_chunk (const Chunk *sp, int src, Chunk *dp, int dst, int size)
{
memmove (dp->c_text + dst, sp->c_text + src, sizeof (Char) * size);
}
static void
adjust (const Chunk *&chunk, int &offset)
{
const Chunk *cp = chunk;
int o = offset;
while (o > cp->c_used)
{
o -= cp->c_used;
cp = cp->c_next;
assert (cp);
}
chunk = cp;
offset = o;
}
void
copy_chunk (const Char *src, Chunk *dst, int doff, int size)
{
while (1)
{
int n = min (dst->c_used - doff, size);
bcopy (src, dst->c_text + doff, n);
size -= n;
if (!size)
return;
src += n;
doff += n;
if (doff == dst->c_used)
{
dst = dst->c_next;
doff = 0;
}
}
}
void
Buffer::move_before_gap (Point &w_point, int size) const
{
Chunk *cur = w_point.p_chunk;
int rest = cur->rest ();
int n = cur->c_used - w_point.p_offset;
move_chunk (cur, w_point.p_offset, Chunk::TEXT_SIZE - n, n);
cur->c_used = Chunk::TEXT_SIZE;
modify_chunk (cur);
Chunk *prev = cur->c_prev;
int pused = prev->c_used;
prev->c_used += size - rest;
modify_chunk (prev);
copy_chunk (cur->c_text, prev, pused, w_point.p_offset);
pused += w_point.p_offset;
adjust (prev, pused);
if (pused == prev->c_used)
{
prev = prev->c_next;
pused = 0;
}
w_point.p_chunk = prev;
w_point.p_offset = pused;
}
static void
adjust_dst (const Chunk *&chunk, int &offset)
{
const Chunk *cp = chunk;
int o = offset;
while (o > Chunk::TEXT_SIZE)
{
o -= Chunk::TEXT_SIZE;
cp = cp->c_next;
assert (cp);
}
chunk = cp;
offset = o;
}
static void
copy_chunk_reverse (const Chunk *src, int soff, Chunk *dst, int doff, int size)
{
if (!size)
return;
soff += size;
doff += size;
adjust_dst (dst, doff);
while (1)
{
int n = min (soff, doff);
if (n)
{
n = min (n, size);
soff -= n;
doff -= n;
move_chunk (src, soff, dst, doff, n);
size -= n;
if (!size)
return;
}
if (!doff)
{
dst = dst->c_prev;
doff = Chunk::TEXT_SIZE;
}
if (!soff)
{
src = src->c_prev;
soff = src->c_used;
}
}
}
void
Buffer::move_after_gap (Point &w_point, int size) const
{
Chunk *cp = w_point.p_chunk;
Chunk *next = cp->c_next;
int n = size - cp->rest ();
move_chunk (next, 0, n, next->c_used);
next->c_used += n;
modify_chunk (next);
copy_chunk_reverse (cp, w_point.p_offset, cp, w_point.p_offset + size,
cp->c_used - w_point.p_offset);
cp->c_used = Chunk::TEXT_SIZE;
modify_chunk (cp);
}
int
Buffer::allocate_new_chunks (Point &w_point, int requested)
{
Chunk *chunk = w_point.p_chunk;
int need = requested - chunk->rest ();
Chunk *prev = chunk;
Chunk *head = alloc_chunk ();
for (Chunk *cp = head; cp; cp = cp->c_next)
{
cp->c_prev = prev;
prev = cp;
if (need > Chunk::TEXT_SIZE)
{
cp->c_used = Chunk::TEXT_SIZE;
need -= Chunk::TEXT_SIZE;
cp->c_next = alloc_chunk ();
}
else
{
cp->c_used = need;
cp->c_next = chunk->c_next;
if (cp->c_next)
cp->c_next->c_prev = cp;
else
b_chunke = cp;
chunk->c_next = head;
copy_chunk_reverse (chunk, w_point.p_offset,
chunk, w_point.p_offset + requested,
chunk->c_used - w_point.p_offset);
modify_chunk (chunk);
chunk->c_used = Chunk::TEXT_SIZE;
if (w_point.p_offset == chunk->c_used)
{
w_point.p_chunk = chunk->c_next;
w_point.p_offset = 0;
}
return 1;
}
}
free_all_chunks (head);
return 0;
}
int
Buffer::move_gap (Point &w_point, int requested)
{
Chunk *chunk = w_point.p_chunk;
int rest = chunk->rest ();
if (rest >= requested)
{
move_chunk (chunk, w_point.p_offset, w_point.p_offset + requested,
chunk->c_used - w_point.p_offset);
chunk->c_used += requested;
modify_chunk (chunk);
return 1;
}
Chunk *cp = chunk->c_next;
if (cp && rest + cp->rest () >= requested)
{
move_after_gap (w_point, requested);
return 1;
}
cp = chunk->c_prev;
if (cp && rest + cp->rest () >= requested)
{
move_before_gap (w_point, requested);
return 1;
}
return allocate_new_chunks (w_point, requested);
}
void
Buffer::adjust_insertion (const Point &point, int size)
{
point_t opoint = point.p_point;
#define ADJINS(P) if ((P) > opoint) (P) += size
#define ADJINS2(P) if ((P) >= opoint) (P) += size
ADJINS (b_point);
ADJINS (b_mark);
ADJINS (b_selection_point);
ADJINS (b_selection_marker);
ADJINS (b_reverse_region.p1);
ADJINS (b_reverse_region.p2);
ADJINS (b_disp);
textprop_adjust_insertion (opoint, size);
for (save_excursion *se = b_excursion; se; se = se->prev ())
ADJINS (se->se_point);
for (save_restriction *sr = b_restriction; sr; sr = sr->prev ())
{
ADJINS (sr->sr_contents.p1);
ADJINS2 (sr->sr_contents.p2);
}
for (lisp marker = lmarkers; consp (marker); marker = xcdr (marker))
{
lisp x = xcar (marker);
ADJINS (xmarker_point (x));
}
for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == this)
{
ADJINS (wp->w_point.p_point);
if (&wp->w_point != &point)
set_point_no_restrictions (wp->w_point, wp->w_point.p_point);
ADJINS (wp->w_mark);
ADJINS (wp->w_selection_point);
ADJINS (wp->w_selection_marker);
ADJINS (wp->w_reverse_region.p1);
ADJINS (wp->w_reverse_region.p2);
ADJINS (wp->w_disp);
ADJINS (wp->w_last_disp);
}
for (WindowConfiguration *wc = WindowConfiguration::wc_chain;
wc; wc = wc->wc_prev)
for (WindowConfiguration::Data *d = wc->wc_data, *de = d + wc->wc_nwindows;
d < de; d++)
if (d->bufp == this)
{
ADJINS (d->point);
ADJINS (d->disp);
ADJINS (d->mark);
ADJINS (d->selection_point);
ADJINS (d->selection_marker);
ADJINS (d->reverse_region.p1);
ADJINS (d->reverse_region.p2);
}
}
int
Buffer::pre_insert_chars (Point &point, int size)
{
UndoInfo *undo = setup_insert_undo (point.p_point, size);
if (!undo)
return 0;
if (!move_gap (point, size))
{
discard_insert_undo (undo);
return 0;
}
save_insert_undo (undo, point.p_point, size);
return 1;
}
void
Buffer::post_insert_chars (Point &point, int size)
{
modify ();
set_modified_region (point.p_point, point.p_point);
b_modified_region.p2 += size;
b_nchars += size;
b_contents.p2 += size;
adjust_insertion (point, size);
forward_char (point, size);
b_stream_cache = point;
#ifdef DEBUG
check_valid ();
#endif
}
int
Buffer::insert_chars_internal (Point &point, const insertChars *ichars,
int nargs, int repeat)
{
double total_length = 0;
for (int i = 0; i < nargs; i++)
total_length += ichars[i].length;
total_length *= repeat;
if (total_length > INT_MAX)
return 0;
int size = int (total_length);
if (!size)
return 1;
if (!pre_insert_chars (point, size))
return 0;
Chunk *cp = point.p_chunk;
int off = point.p_offset;
for (i = 0; i < repeat; i++)
for (int j = 0; j < nargs; j++)
{
int rest = ichars[j].length;
const Char *s = ichars[j].string;
while (rest > 0)
{
int n = min (cp->c_used - off, rest);
bcopy (s, cp->c_text + off, n);
s += n;
off += n;
rest -= n;
if (off == cp->c_used)
{
cp = cp->c_next;
off = 0;
}
}
}
post_insert_chars (point, size);
return 1;
}
int
Buffer::insert_chars_internal (Point &point, const Char *string,
int length, int repeat)
{
insertChars ichars;
ichars.string = string;
ichars.length = length;
return insert_chars_internal (point, &ichars, 1, repeat);
}
void
Buffer::insert_chars (Window *wp, const insertChars *ic, int n, int repeat)
{
prepare_modify_buffer ();
wp->w_disp_flags |= Window::WDF_GOAL_COLUMN;
point_t opoint = wp->w_point.p_point;
if (!insert_chars_internal (wp->w_point, ic, n, repeat))
FEstorage_error ();
post_buffer_modified (Kinsert, wp->w_point, opoint, wp->w_point.p_point);
}
void
Buffer::insert_chars (Window *wp, const Char *string, int length, int repeat)
{
prepare_modify_buffer ();
wp->w_disp_flags |= Window::WDF_GOAL_COLUMN;
point_t opoint = wp->w_point.p_point;
if (!insert_chars_internal (wp->w_point, string, length, repeat))
FEstorage_error ();
post_buffer_modified (Kinsert, wp->w_point, opoint, wp->w_point.p_point);
}
void
Buffer::insert_chars (Point &point, const Char *string, int length)
{
prepare_modify_buffer ();
point_t opoint = point.p_point;
if (!insert_chars_internal (point, string, length, 1))
FEstorage_error ();
post_buffer_modified (Kinsert, point, opoint, point.p_point);
}
lisp
Finsert (lisp args)
{
int nargs = xlist_length (args);
if (!nargs)
FEtoo_few_arguments ();
Window *wp = selected_window ();
Buffer *bp = wp->w_bufp;
bp->check_read_only ();
int repeat = 1;
Char *tem;
insertChars *ichars = (insertChars *)alloca ((sizeof *ichars + sizeof *tem)
* nargs);
tem = (Char *)(ichars + nargs);
for (int i = 0; i < nargs; i++, args = xcdr (args))
{
lisp x = xcar (args);
if (charp (x))
{
*tem = xchar_code (x);
ichars[i].string = tem++;
ichars[i].length = 1;
}
else if (stringp (x))
{
ichars[i].string = xstring_contents (x);
ichars[i].length = xstring_length (x);
}
else if (i && i == nargs - 1)
{
repeat = fixnum_value (x);
if (repeat < 0)
FErange_error (x);
break;
}
else
FEtype_error (x, xsymbol_value (Qor_string_character));
}
bp->insert_chars (wp, ichars, i, repeat);
return Qt;
}
void
Buffer::insert_file_contents (Window *wp, lisp filename, lisp visit,
lisp loffset, lisp lsize, ReadFileContext &rfc)
{
check_read_only ();
if (!visit)
visit = Qnil;
if (visit == Qnil)
prepare_modify_buffer ();
char path[PATH_MAX + 1];
pathname2cstr (filename, path);
if (special_file_p (path))
file_error (Eis_character_special_file, filename);
int offset, size;
if (!loffset || loffset == Qnil)
offset = 0;
else
{
offset = fixnum_value (loffset);
if (offset < 0)
FErange_error (loffset);
}
if (!lsize || lsize == Qnil)
size = -1;
else
{
size = fixnum_value (lsize);
if (size < 0)
FErange_error (lsize);
}
Chunk *t_chunk;
if (!wp->w_point.p_offset
|| wp->w_point.p_offset == wp->w_point.p_chunk->c_used)
t_chunk = 0;
else
{
t_chunk = alloc_chunk ();
if (!t_chunk)
FEstorage_error ();
}
long n;
if (!safe_fixnum_value (symbol_value (Vexpected_eol_code, this), &n)
|| !valid_eol_code_p (n))
n = eol_guess;
rfc.r_expect_eol = eol_code (n);
rfc.r_expect_char_encoding = symbol_value (Vexpected_fileio_encoding, this);
if (!char_encoding_p (rfc.r_expect_char_encoding))
rfc.r_expect_char_encoding = Qnil;
rfc.r_char_encoding = lchar_encoding;
read_file_contents (rfc, path, offset, size);
if (rfc.r_status == ReadFileContext::RFCS_IOERR)
{
if (t_chunk)
free_chunk (t_chunk);
if (rfc.r_chunk)
free_all_chunks (rfc.r_chunk);
file_error (rfc.r_errcode, filename);
}
if (!rfc.r_chunk)
{
if (t_chunk)
free_chunk (t_chunk);
switch (rfc.r_status)
{
case ReadFileContext::RFCS_MEM:
FEstorage_error ();
case ReadFileContext::RFCS_OPEN:
file_error (rfc.r_errcode, filename);
default:
break;
}
}
else
{
if (visit != Qnil)
clear_undo_info ();
else
{
UndoInfo *u = setup_insert_undo (wp->w_point.p_point, rfc.r_nchars);
if (!u)
{
if (t_chunk)
free_chunk (t_chunk);
free_all_chunks (rfc.r_chunk);
FEstorage_error ();
}
save_insert_undo (u, wp->w_point.p_point, rfc.r_nchars);
}
if (!b_nchars)
{
free_all_chunks (b_chunkb);
b_chunkb = rfc.r_chunk;
b_chunke = rfc.r_tail;
}
else
{
Chunk *cp = wp->w_point.p_chunk;
if (!wp->w_point.p_offset)
{
rfc.r_chunk->c_prev = cp->c_prev;
if (!cp->c_prev)
b_chunkb = rfc.r_chunk;
else
cp->c_prev->c_next = rfc.r_chunk;
rfc.r_tail->c_next = cp;
cp->c_prev = rfc.r_tail;
}
else if (wp->w_point.p_offset == wp->w_point.p_chunk->c_used)
{
assert (!cp->c_next);
cp->c_next = rfc.r_chunk;
rfc.r_chunk->c_prev = cp;
b_chunke = rfc.r_tail;
}
else
{
bcopy (cp->c_text + wp->w_point.p_offset, t_chunk->c_text,
cp->c_used - wp->w_point.p_offset);
t_chunk->c_used = cp->c_used - wp->w_point.p_offset;
modify_chunk (t_chunk);
t_chunk->c_next = cp->c_next;
if (t_chunk->c_next)
t_chunk->c_next->c_prev = t_chunk;
else
b_chunke = t_chunk;
rfc.r_tail->c_next = t_chunk;
t_chunk->c_prev = rfc.r_tail;
rfc.r_chunk->c_prev = cp;
cp->c_next = rfc.r_chunk;
cp->c_used = wp->w_point.p_offset;
modify_chunk (cp);
}
}
wp->w_point.p_chunk = rfc.r_chunk;
wp->w_point.p_offset = 0;
}
modify ();
set_modified_region (wp->w_point.p_point, wp->w_point.p_point);
b_modified_region.p2 += rfc.r_nchars;
b_nchars += rfc.r_nchars;
b_contents.p2 += rfc.r_nchars;
adjust_insertion (wp->w_point, rfc.r_nchars);
wp->w_disp_flags |= Window::WDF_GOAL_COLUMN;
#ifdef DEBUG
check_valid ();
#endif
if (visit != Qnil)
{
b_eol_code = exact_eol_code (rfc.r_eol_code);
lchar_encoding = rfc.r_char_encoding;
b_modified = 0;
b_need_auto_save = 0;
b_modtime = rfc.r_modtime;
if (symbol_value (Slock_file, this) == Kedit)
unlock_file ();
save_modtime_undo (b_modtime);
maybe_modify_buffer_bar ();
}
else
post_buffer_modified (Kinsert, wp->w_point,
wp->w_point.p_point,
wp->w_point.p_point + rfc.r_nchars);
}
lisp
Finsert_file_contents (lisp filename, lisp visit, lisp offset, lisp size)
{
Window *wp = selected_window ();
Buffer *bp = wp->w_bufp;
ReadFileContext rfc;
bp->insert_file_contents (wp, filename, visit, offset, size, rfc);
multiple_value::count () = 3;
multiple_value::value (1) = boole (rfc.r_status == ReadFileContext::RFCS_NOERR);
multiple_value::value (2) = make_fixnum (rfc.r_nchars);
return make_fixnum (rfc.r_nlines);
}
void
Buffer::delete_chunk (Chunk *cp)
{
Chunk *prev = cp->c_prev;
Chunk *next = cp->c_next;
if (!prev && !next)
{
cp->clear ();
return;
}
if (prev)
prev->c_next = next;
else
b_chunkb = next;
if (next)
next->c_prev = prev;
else
b_chunke = prev;
free_chunk (cp);
}
void
Buffer::adjust_deletion (const Point &point, int size)
{
point_t from = point.p_point;
#define ADJDEL(P) \
if ((P) > from) (P) = max (point_t ((P) - size), from)
ADJDEL (b_point);
ADJDEL (b_mark);
ADJDEL (b_selection_point);
ADJDEL (b_selection_marker);
ADJDEL (b_reverse_region.p1);
ADJDEL (b_reverse_region.p2);
ADJDEL (b_disp);
textprop_adjust_deletion (from, size);
for (save_excursion *se = b_excursion; se; se = se->prev ())
ADJDEL (se->se_point);
for (save_restriction *sr = b_restriction; sr; sr = sr->prev ())
{
ADJDEL (sr->sr_contents.p1);
ADJDEL (sr->sr_contents.p2);
}
for (lisp marker = lmarkers; consp (marker); marker = xcdr (marker))
{
lisp x = xcar (marker);
ADJDEL (xmarker_point (x));
}
for (Window *wp = app.active_frame.windows; wp; wp = wp->w_next)
if (wp->w_bufp == this)
{
if (point.p_point < wp->w_disp && point.p_point + size > wp->w_disp)
wp->w_disp_flags |= Window::WDF_DELETE_TOP;
ADJDEL (wp->w_point.p_point);
if (&wp->w_point != &point)
set_point_no_restrictions (wp->w_point, wp->w_point.p_point);
ADJDEL (wp->w_mark);
ADJDEL (wp->w_selection_point);
ADJDEL (wp->w_selection_marker);
ADJDEL (wp->w_reverse_region.p1);
ADJDEL (wp->w_reverse_region.p2);
ADJDEL (wp->w_disp);
ADJDEL (wp->w_last_disp);
}
for (WindowConfiguration *wc = WindowConfiguration::wc_chain;
wc; wc = wc->wc_prev)
for (WindowConfiguration::Data *d = wc->wc_data, *de = d + wc->wc_nwindows;
d < de; d++)
if (d->bufp == this)
{
ADJDEL (d->point);
ADJDEL (d->disp);
ADJDEL (d->mark);
ADJDEL (d->selection_point);
ADJDEL (d->selection_marker);
ADJDEL (d->reverse_region.p1);
ADJDEL (d->reverse_region.p2);
}
}
int
Buffer::delete_region_internal (Point &point, point_t from, point_t to)
{
from = min (max (from, b_contents.p1), b_contents.p2);
to = min (max (to, b_contents.p1), b_contents.p2);
if (from == to)
return 1;
if (from > to)
swap (from, to);
int size = to - from;
goto_char (point, from);
if (!save_delete_undo (point, size))
return 0;
Chunk *cp = point.p_chunk;
int off = point.p_offset;
while (1)
{
int rest = cp->c_used - off;
if (size >= rest)
{
Chunk *next = cp->c_next;
if (!off)
delete_chunk (cp);
else
{
cp->c_used = off;
modify_chunk (cp);
}
size -= rest;
if (!size)
break;
cp = next;
off = 0;
}
else
{
cp->c_used -= size;
modify_chunk (cp);
bcopy (cp->c_text + off + size, cp->c_text + off, cp->c_used - off);
break;
}
}
size = to - from;
modify ();
set_modified_region (from, to);
b_modified_region.p2 -= size;
b_nchars -= size;
b_contents.p2 -= size;
set_point (point, from);
adjust_deletion (point, size);
#ifdef DEBUG
check_valid ();
#endif
return 1;
}
void
Buffer::delete_region (Window *wp, point_t from, point_t to)
{
prepare_modify_buffer ();
wp->w_disp_flags |= Window::WDF_GOAL_COLUMN;
if (!delete_region_internal (wp->w_point, from, to))
FEstorage_error ();
post_buffer_modified (Kdelete, wp->w_point,
wp->w_point.p_point, wp->w_point.p_point);
}
lisp
Fdelete_region (lisp from, lisp to)
{
Window *wp = selected_window ();
Buffer *bp = wp->w_bufp;
point_t p1 = bp->coerce_to_point (from);
point_t p2 = bp->coerce_to_point (to);
if (p1 != p2)
{
bp->check_read_only ();
bp->delete_region (wp, p1, p2);
}
return Qt;
}
void
Buffer::overwrite_chars (Window *wp, const Char *p, int size)
{
prepare_modify_region (wp, wp->w_point.p_point, wp->w_point.p_point + size);
copy_chunk (p, wp->w_point.p_chunk, wp->w_point.p_offset, size);
post_buffer_modified (Kmodify, wp->w_point,
wp->w_point.p_point, wp->w_point.p_point + size);
}
void
Buffer::substring (const Point &point, int size, Char *b) const
{
const Chunk *cp = point.p_chunk;
int n = cp->c_used - point.p_offset;
if (n >= size)
bcopy (cp->c_text + point.p_offset, b, size);
else
{
bcopy (cp->c_text + point.p_offset, b, n);
b += n;
size -= n;
for (cp = cp->c_next; size > cp->c_used; cp = cp->c_next)
{
bcopy (cp->c_text, b, cp->c_used);
b += cp->c_used;
size -= cp->c_used;
}
bcopy (cp->c_text, b, size);
}
}
void
Buffer::substring (point_t point, int size, Char *b) const
{
Point p;
set_point (p, point);
substring (p, size, b);
}
lisp
Buffer::substring (point_t p1, point_t p2) const
{
p1 = min (max (p1, b_contents.p1), b_contents.p2);
p2 = min (max (p2, b_contents.p1), b_contents.p2);
if (p1 > p2)
swap (p1, p2);
int size = p2 - p1;
lisp x = make_string (size);
substring (p1, size, xstring_contents (x));
return x;
}
lisp
Fbuffer_substring (lisp p1, lisp p2)
{
Buffer *bp = selected_buffer ();
return bp->substring (bp->coerce_to_point (p1), bp->coerce_to_point (p2));
}
static int
encoding_sjis_p (lisp encoding)
{
return (!char_encoding_p (encoding)
|| xchar_encoding_type (encoding) == encoding_auto_detect
|| xchar_encoding_type (encoding) == encoding_sjis);
}
static int
encoding_utf16_p (lisp encoding)
{
return (char_encoding_p (encoding)
&& xchar_encoding_type (encoding) == encoding_utf16);
}
static void *
galloc (CLIPBOARDTEXT &clp, int size)
{
clp.hgl = GlobalAlloc (GMEM_MOVEABLE, size);
if (!clp.hgl)
return 0;
void *p = GlobalLock (clp.hgl);
if (p)
return p;
GlobalFree (clp.hgl);
clp.hgl = 0;
return 0;
}
static int
make_cf_text_sjis (CLIPBOARDTEXT &clp, lisp string)
{
const Char *s = xstring_contents (string);
const Char *const se = s + xstring_length (string);
for (int extra = 0; s < se; s++)
if (*s == '\n' || DBCP (*s))
extra++;
clp.fmt = CF_TEXT;
char *b = (char *)galloc (clp, xstring_length (string) + extra + 1);
if (!b)
return 0;
for (s = xstring_contents (string); s < se; s++)
{
Char cc = *s;
if (DBCP (cc))
{
if (code_charset (cc) == ccs_cp932)
*b++ = cc >> 8;
else
{
Char c2 = wc2cp932 (i2w (cc));
if (c2 != Char (-1))
{
cc = c2;
if (DBCP (cc))
*b++ = cc >> 8;
}
else
cc = '?';
}
}
else if (cc == '\n')
*b++ = '\r';
*b++ = char (cc);
}
*b = 0;
GlobalUnlock (clp.hgl);
return 1;
}
static int
make_cf_text (CLIPBOARDTEXT &clp, lisp string, lisp encoding)
{
if (encoding_sjis_p (encoding))
return make_cf_text_sjis (clp, string);
Char_input_string_stream str1 (string);
encoding_output_stream_helper is1 (encoding, str1, eol_crlf);
int l = is1->total_length ();
clp.fmt = CF_TEXT;
char *b = (char *)galloc (clp, l + 1);
if (!b)
return 0;
Char_input_string_stream str2 (string);
encoding_output_stream_helper is2 (encoding, str2, eol_crlf);
is2->copyto ((u_char *)b, l + 1);
GlobalUnlock (clp.hgl);
return 1;
}
static int
make_cf_wtext (CLIPBOARDTEXT &clp, lisp string)
{
const Char *s = xstring_contents (string);
const Char *const se = s + xstring_length (string);
for (int extra = 0; s < se; s++)
if (*s == '\n')
extra++;
clp.fmt = CF_UNICODETEXT;
ucs2_t *b = (ucs2_t *)galloc (clp, (xstring_length (string) + extra + 1) * sizeof *b);
if (!b)
return 0;
for (s = xstring_contents (string); s < se; s++)
{
if (*s == '\n')
*b++ = '\r';
ucs2_t c = i2w (*s);
if (c == ucs2_t (-1))
{
if (utf16_undef_char_high_p (*s) && s < se - 1
&& utf16_undef_char_low_p (s[1]))
{
c = utf16_undef_pair_to_ucs2 (*s, s[1]);
s++;
}
else
c = DEFCHAR;
}
*b++ = c;
}
*b = 0;
GlobalUnlock (clp.hgl);
return 1;
}
int
make_clipboard_text (CLIPBOARDTEXT &clp, lisp string, int req)
{
clp.hgl = 0;
clp.fmt = 0;
lisp encoding = symbol_value (Vclipboard_char_encoding, selected_buffer ());
if (req == CF_UNICODETEXT || encoding_utf16_p (encoding))
return make_cf_wtext (clp, string);
return make_cf_text (clp, string, encoding);
}
static int
open_clipboard (HWND hwnd)
{
for (int i = 0; i < 100; i++)
{
if (OpenClipboard (hwnd))
return 1;
Sleep (0);
}
return 0;
}
lisp
Fcopy_to_clipboard (lisp string)
{
check_string (string);
if (!xstring_length (string))
return Qnil;
CLIPBOARDTEXT clp[2];
bzero (clp, sizeof clp);
if (!make_clipboard_text (clp[0], string, 0))
FEstorage_error ();
if (clp[0].fmt == CF_UNICODETEXT && !sysdep.WinNTp ()
&& !make_cf_text_sjis (clp[1], string))
{
GlobalFree (clp[0].hgl);
FEstorage_error ();
}
int result = 0;
if (open_clipboard (app.toplev))
{
if (EmptyClipboard ())
for (int i = 0; i < numberof (clp) && clp[i].hgl; i++)
{
if (!SetClipboardData (clp[i].fmt, clp[i].hgl))
break;
result = 1;
clp[i].hgl = 0;
}
CloseClipboard ();
}
for (int i = 0; i < numberof (clp); i++)
if (clp[i].hgl)
GlobalFree (clp[i].hgl);
xsymbol_value (Vclipboard_newer_than_kill_ring_p) = Qnil;
xsymbol_value (Vkill_ring_newer_than_clipboard_p) = Qnil;
return boole (result);
}
static int
count_cf_text_length (const u_char *string)
{
int l = 0;
for (const u_char *s = string; *s;)
{
if (SJISP (*s))
{
if (!s[1])
{
s++;
break;
}
l++;
s += 2;
}
else
{
if (*s == '\r' && s[1] == '\n')
l++;
s++;
}
}
return s - string - l;
}
static int
make_string_from_cf_text_sjis (lisp lstring, const u_char *s)
{
int l = count_cf_text_length (s);
Char *b = (Char *)malloc (l * sizeof *b);
if (!b)
return 0;
xstring_contents (lstring) = b;
xstring_length (lstring) = l;
while (*s)
{
if (SJISP (*s))
{
if (!s[1])
{
*b = *s;
break;
}
*b++ = (*s << 8) | s[1];
s += 2;
}
else if (*s == '\r' && s[1] == '\n')
s++;
else
*b++ = *s++;
}
return 1;
}
static int
make_string_from_cf_text (lisp lstring, const u_char *s)
{
lisp encoding = symbol_value (Vclipboard_char_encoding, selected_buffer ());
if (encoding_sjis_p (encoding))
return make_string_from_cf_text_sjis (lstring, s);
int sl = strlen ((const char *)s);
xinput_strstream str1 ((const char *)s, sl);
encoding_input_stream_helper is1 (encoding, str1);
int l = is1->total_length ();
Char *b = (Char *)malloc (l * sizeof *b);
if (!b)
return 0;
xstring_contents (lstring) = b;
xinput_strstream str2 ((const char *)s, sl);
encoding_input_stream_helper is2 (encoding, str2);
int c;
while ((c = is2->get ()) != xstream::eof)
if (c != '\r')
*b++ = c;
else
while (1)
{
c = is2->get ();
if (c == '\n')
{
*b++ = c;
break;
}
*b++ = '\r';
if (c == xstream::eof)
goto eof;
if (c != '\r')
{
*b++ = c;
break;
}
}
eof:
xstring_length (lstring) = b - xstring_contents (lstring);
return 1;
}
static int
count_cf_wtext_length (const ucs2_t *string)
{
int l = 0;
for (const ucs2_t *s = string; *s; s++)
if (*s == '\r')
{
if (s[1] == '\n')
{
l--;
s++;
}
}
else if (w2i (*s) == Char (-1))
l++;
return s - string + l;
}
static int
make_string_from_cf_wtext (lisp lstring, const ucs2_t *s, int lang)
{
int l = count_cf_wtext_length (s);
Char *b = (Char *)malloc (l * sizeof *b);
if (!b)
return 0;
xstring_contents (lstring) = b;
xstring_length (lstring) = l;
const Char *const translate = cjk_translate_table (lang);
switch (lang)
{
case ENCODING_LANG_JP:
case ENCODING_LANG_JP2:
default:
{
int to_half = xsymbol_value (Vunicode_to_half_width) != Qnil;
for (; *s; s++)
if (*s != '\r' || s[1] != '\n')
{
Char cc;
if (to_half
|| (cc = wc2cp932 (*s)) == Char (-1)
|| ccs_1byte_94_charset_p (code_charset (cc)))
cc = w2i (*s);
if (cc == Char (-1))
{
*b++ = utf16_ucs2_to_undef_pair_high (*s);
*b++ = utf16_ucs2_to_undef_pair_low (*s);
}
else
*b++ = cc;
}
}
break;
case ENCODING_LANG_KR:
case ENCODING_LANG_CN_GB:
case ENCODING_LANG_CN_BIG5:
for (; *s; s++)
if (*s != '\r' || s[1] != '\n')
{
Char cc = w2i (*s);
if (cc == Char (-1))
{
*b++ = utf16_ucs2_to_undef_pair_high (*s);
*b++ = utf16_ucs2_to_undef_pair_low (*s);
}
else
{
if (!ccs_1byte_94_charset_p (code_charset (cc)))
{
Char t = translate[*s];
if (t != Char (-1))
cc = t;
}
*b++ = cc;
}
}
break;
case ENCODING_LANG_CN:
for (; *s; s++)
if (*s != '\r' || s[1] != '\n')
{
Char cc = w2i (*s);
if (cc == Char (-1))
{
*b++ = utf16_ucs2_to_undef_pair_high (*s);
*b++ = utf16_ucs2_to_undef_pair_low (*s);
}
else
{
if (!ccs_1byte_94_charset_p (code_charset (cc)))
{
Char t = wc2gb2312_table[*s];
if (t != Char (-1) || (t = wc2big5_table[*s]) != Char (-1))
cc = t;
}
*b++ = cc;
}
}
break;
}
return 1;
}
int
make_string_from_clipboard_text (lisp lstring, const void *data, UINT fmt, int lang)
{
switch (fmt)
{
case CF_TEXT:
return make_string_from_cf_text (lstring, (const u_char *)data);
case CF_UNICODETEXT:
return make_string_from_cf_wtext (lstring, (const ucs2_t *)data, lang);
default:
assert (0);
return 0;
}
}
static int
get_clipboatd_data (UINT fmt, lisp lstring, int lang)
{
HGLOBAL hgl = GetClipboardData (fmt);
if (!hgl)
return -1;
void *data = GlobalLock (hgl);
if (!data)
return 0;
int r = make_string_from_clipboard_text (lstring, data, fmt, lang);
GlobalUnlock (hgl);
return r;
}
lisp
Fget_clipboard_data ()
{
int result = -1;
lisp lstring = make_simple_string ();
if (open_clipboard (app.toplev))
{
lisp encoding = symbol_value (Vclipboard_char_encoding,
selected_buffer ());
if (encoding_utf16_p (encoding))
result = get_clipboatd_data (CF_UNICODETEXT, lstring,
xchar_encoding_utf_cjk (encoding));
if (result == -1)
{
UINT fmt = 0;
while ((fmt = EnumClipboardFormats (fmt)))
if (fmt == CF_TEXT || fmt == CF_UNICODETEXT)
{
result = get_clipboatd_data (fmt, lstring, ENCODING_LANG_NIL);
break;
}
}
CloseClipboard ();
}
if (!result)
FEstorage_error ();
if (result == -1)
return Qnil;
return lstring;
}
lisp
Fclipboard_empty_p ()
{
return boole (!IsClipboardFormatAvailable (CF_TEXT)
&& (sysdep.WinNTp ()
|| !IsClipboardFormatAvailable (CF_UNICODETEXT)));
}
textprop *
Buffer::find_textprop (point_t point) const
{
for (textprop *p = textprop_head (point); p; p = p->t_next)
if (p->t_range.p2 > point)
return p;
return 0;
}
void
Buffer::textprop_adjust_insertion (point_t point, int size)
{
for (textprop *p = textprop_head (point); p; p = p->t_next)
if (p->t_range.p2 > point)
{
if (p->t_range.p1 > point)
p->t_range.p1 += size;
p->t_range.p2 += size;
while ((p = p->t_next))
{
p->t_range.p1 += size;
p->t_range.p2 += size;
}
break;
}
}
void
Buffer::textprop_adjust_deletion (point_t point, int size)
{
point_t pe = point + size;
for (textprop *p = textprop_head (point), *prev = 0, *next; p; prev = p, p = next)
{
next = p->t_next;
if (p->t_range.p1 >= pe)
{
do
{
p->t_range.p1 -= size;
p->t_range.p2 -= size;
}
while (p = p->t_next);
break;
}
if (p->t_range.p2 > point)
{
if (p->t_range.p1 > point)
p->t_range.p1 = max (point_t (p->t_range.p1 - size), point);
p->t_range.p2 = max (point_t (p->t_range.p2 - size), point);
if (p->t_range.p1 == p->t_range.p2)
{
free_textprop (p);
if (prev)
{
prev->t_next = next;
p = prev;
}
else
{
b_textprop = next;
p = 0;
}
}
}
}
}
static inline void
copy_textprop (const textprop *p, textprop *t)
{
t->t_attrib = p->t_attrib;
t->t_tag = p->t_tag;
}
textprop *
Buffer::add_textprop (point_t p1, point_t p2)
{
for (textprop *p = textprop_head (p1), *prev = 0; p; prev = p, p = p->t_next)
if (*p > p1)
break;
if (p && p->t_range.p1 == p1 && p->t_range.p2 == p2)
return p;
textprop *q = make_textprop ();
if (!q)
return 0;
q->t_range.p1 = p1;
q->t_range.p2 = p2;
textprop **pl = prev ? &prev->t_next : &b_textprop;
if (p)
{
if (p2 <= p->t_range.p1)
{
q->t_next = p;
*pl = q;
}
else if (p2 < p->t_range.p2)
{
if (p1 <= p->t_range.p1)
{
q->t_next = p;
p->t_range.p1 = p2;
*pl = q;
}
else
{
textprop *t = make_textprop ();
if (!t)
{
free_textprop (q);
return 0;
}
t->t_next = p->t_next;
q->t_next = t;
p->t_next = q;
t->t_range.p1 = p2;
t->t_range.p2 = p->t_range.p2;
p->t_range.p2 = p1;
copy_textprop (p, t);
}
}
else
{
if (p1 <= p->t_range.p1)
{
p->t_range.p1 = p1;
p->t_range.p2 = p2;
free_textprop (q);
q = p;
}
else
{
q->t_next = p->t_next;
p->t_next = q;
p->t_range.p2 = p1;
}
}
}
else
{
q->t_next = *pl;
*pl = q;
}
for (p = q->t_next; p && p->t_range.p1 < p2; p = q->t_next)
{
if (p->t_range.p2 > p2)
{
p->t_range.p1 = p2;
break;
}
q->t_next = p->t_next;
free_textprop (p);
}
return q;
}
static int
check_attrib (lisp lc1, lisp lc2, lisp bold, lisp underline, lisp strikeout, lisp lcc, lisp lextend)
{
int attrib = 0;
if (lc1 != Qnil)
attrib |= ((fixnum_value (lc1) & (GLYPH_TEXTPROP_NCOLORS - 1))
<< GLYPH_TEXTPROP_FG_SHIFT_BITS);
if (lc2 != Qnil)
attrib |= ((fixnum_value (lc2) & (GLYPH_TEXTPROP_NCOLORS - 1))
<< GLYPH_TEXTPROP_BG_SHIFT_BITS);
if (bold != Qnil)
attrib |= GLYPH_BOLD;
if (underline != Qnil)
attrib |= GLYPH_UNDERLINE;
if (strikeout != Qnil)
attrib |= GLYPH_STRIKEOUT;
if (lcc != Qnil)
{
check_char (lcc);
int cc = xchar_code (lcc);
if (cc > ' ' && cc < 0x7f)
attrib |= cc;
}
if (lextend != Qnil)
attrib |= TEXTPROP_EXTEND_EOL_BIT;
return attrib;
}
static int
attrib_value (lisp keys)
{
return check_attrib (find_keyword (Kforeground, keys, Qnil),
find_keyword (Kbackground, keys, Qnil),
find_keyword (Kbold, keys, Qnil),
find_keyword (Kunderline, keys, Qnil),
find_keyword (Kstrike_out, keys, Qnil),
find_keyword (Kprefix, keys, Qnil),
find_keyword (Kextend, keys, Qnil));
}
static lisp
set_text_attribute (lisp lp1, lisp lp2, lisp tag, int attrib)
{
Buffer *bp = selected_buffer ();
point_t p1 = bp->coerce_to_restricted_point (lp1);
point_t p2 = bp->coerce_to_restricted_point (lp2);
if (p1 > p2)
swap (p1, p2);
textprop *p = bp->add_textprop (p1, p2);
if (!p)
FEstorage_error ();
p->t_attrib = attrib;
p->t_tag = tag;
bp->b_textprop_cache = p;
bp->set_modified_region (p1, p2);
return Qt;
}
lisp
Fset_text_attribute (lisp lp1, lisp lp2, lisp tag, lisp keys)
{
return set_text_attribute (lp1, lp2, tag, attrib_value (keys));
}
lisp
Fclear_all_text_attributes ()
{
Buffer *bp = selected_buffer ();
if (bp->b_textprop)
{
bp->b_textprop_heap.free_all ();
bp->b_textprop = 0;
bp->b_textprop_cache = 0;
bp->refresh_buffer ();
}
return Qt;
}
static lisp
delete_text_attributes (test_proc &test)
{
Buffer *bp = selected_buffer ();
for (textprop *t = bp->b_textprop, *prev = 0, *next; t; t = next)
{
next = t->t_next;
if (test.test (t->t_tag))
{
if (prev)
{
prev->t_next = next;
bp->b_textprop_cache = prev;
}
else
{
bp->b_textprop = next;
if (bp->b_textprop_cache == t)
bp->b_textprop_cache = 0;
}
bp->free_textprop (t);
}
else
prev = t;
}
bp->refresh_buffer ();
return Qt;
}
lisp
Fdelete_text_attributes (lisp tag, lisp keys)
{
seq_testproc test (tag, keys);
return delete_text_attributes (test);
}
lisp
Fdelete_text_attributes_if (lisp pred, lisp keys)
{
seq_testproc_if test (pred, keys);
return delete_text_attributes (test);
}
lisp
Fdelete_text_attributes_if_not (lisp pred, lisp keys)
{
seq_testproc_if_not test (pred, keys);
return delete_text_attributes (test);
}
lisp
Fdelete_text_attribute_point (lisp lpoint)
{
Buffer *bp = selected_buffer ();
point_t point = bp->coerce_to_point (lpoint);
for (textprop *t = bp->b_textprop, *prev = 0;
t && t->t_range.p1 <= point; prev = t, t = t->t_next)
if (*t > point)
{
if (prev)
{
prev->t_next = t->t_next;
bp->b_textprop_cache = prev;
}
else
{
bp->b_textprop = t->t_next;
if (bp->b_textprop_cache == t)
bp->b_textprop_cache = 0;
}
bp->set_modified_region (t->t_range.p1, t->t_range.p2);
bp->free_textprop (t);
return Qt;
}
return Qnil;
}
lisp
Ffind_text_attribute_point (lisp lpoint)
{
Buffer *bp = selected_buffer ();
point_t point = bp->coerce_to_point (lpoint);
for (textprop *t = bp->textprop_head (point);
t && t->t_range.p1 <= point; t = t->t_next)
if (*t > point)
{
int attrib = t->t_attrib;
multiple_value::count () = 10;
multiple_value::value (9) = boole (attrib & TEXTPROP_EXTEND_EOL_BIT);
multiple_value::value (8) = attrib & 0xff ? make_char (attrib & 0xff) : Qnil;
multiple_value::value (7) = boole (attrib & GLYPH_STRIKEOUT);
multiple_value::value (6) = boole (attrib & GLYPH_UNDERLINE);
multiple_value::value (5) = boole (attrib & GLYPH_BOLD);
multiple_value::value (4) = (attrib & ((GLYPH_TEXTPROP_NCOLORS - 1)
<< GLYPH_TEXTPROP_BG_SHIFT_BITS)
? make_fixnum ((attrib >> GLYPH_TEXTPROP_BG_SHIFT_BITS)
& (GLYPH_TEXTPROP_NCOLORS - 1))
: Qnil);
multiple_value::value (3) = (attrib & ((GLYPH_TEXTPROP_NCOLORS - 1)
<< GLYPH_TEXTPROP_FG_SHIFT_BITS)
? make_fixnum ((attrib >> GLYPH_TEXTPROP_FG_SHIFT_BITS)
& (GLYPH_TEXTPROP_NCOLORS - 1))
: Qnil);
multiple_value::value (2) = t->t_tag;
multiple_value::value (1) = make_fixnum (t->t_range.p2);
return make_fixnum (t->t_range.p1);
}
return Qnil;
}
static lisp
find_text_attribute (test_proc &test, lisp keys)
{
Buffer *bp = selected_buffer ();
lisp lstart = find_keyword (Kstart, keys, Qnil);
lisp lend = find_keyword (Kend, keys, Qnil);
lisp from_end = find_keyword (Kfrom_end, keys, Qnil);
point_t start = lstart == Qnil ? bp->b_contents.p1 : bp->coerce_to_point (lstart);
point_t end = lend == Qnil ? bp->b_contents.p2: bp->coerce_to_point (lend);
textprop *match = 0;
if (from_end == Qnil)
{
for (textprop *t = bp->textprop_head (start); t && *t < end; t = t->t_next)
if (t->t_range.p1 >= start && test.test (t->t_tag))
{
match = t;
break;
}
}
else
{
for (textprop *t = bp->textprop_head (start); t && *t < end; t = t->t_next)
if (t->t_range.p1 >= start && test.test (t->t_tag))
match = t;
}
if (!match)
return Qnil;
multiple_value::count () = 3;
multiple_value::value (2) = match->t_tag;
multiple_value::value (1) = make_fixnum (match->t_range.p2);
return make_fixnum (match->t_range.p1);
}
lisp
Ffind_text_attribute (lisp tag, lisp keys)
{
seq_testproc test (tag, keys);
return find_text_attribute (test, keys);
}
lisp
Ffind_text_attribute_if (lisp pred, lisp keys)
{
seq_testproc_if test (pred, keys);
return find_text_attribute (test, keys);
}
lisp
Ffind_text_attribute_if_not (lisp pred, lisp keys)
{
seq_testproc_if_not test (pred, keys);
return find_text_attribute (test, keys);
}
static lisp
modify_text_attributes (test_proc &test, lisp keys)
{
int attrib = attrib_value (keys);
Buffer *bp = selected_buffer ();
lisp lstart = find_keyword (Kstart, keys, Qnil);
lisp lend = find_keyword (Kend, keys, Qnil);
point_t start = lstart == Qnil ? bp->b_contents.p1 : bp->coerce_to_point (lstart);
point_t end = lend == Qnil ? bp->b_contents.p2: bp->coerce_to_point (lend);
for (textprop *t = bp->textprop_head (start); t && *t < end; t = t->t_next)
if (t->t_range.p1 >= start && test.test (t->t_tag))
t->t_attrib = attrib;
bp->refresh_buffer ();
return Qt;
}
lisp
Fmodify_text_attributes (lisp tag, lisp keys)
{
seq_testproc test (tag, keys);
return modify_text_attributes (test, keys);
}
lisp
Fmodify_text_attributes_if (lisp pred, lisp keys)
{
seq_testproc_if test (pred, keys);
return modify_text_attributes (test, keys);
}
lisp
Fmodify_text_attributes_if_not (lisp pred, lisp keys)
{
seq_testproc_if_not test (pred, keys);
return modify_text_attributes (test, keys);
}
static lisp
push_attrib (lisp x, lisp key, lisp value)
{
return xcons (key, xcons (value, x));
}
lisp
Flist_text_attributes (lisp lstart, lisp lend)
{
Buffer *bp = selected_buffer ();
point_t start = (lstart && lstart != Qnil
? bp->coerce_to_point (lstart)
: bp->b_contents.p1);
point_t end = (lend && lend != Qnil
? bp->coerce_to_point (lend)
: bp->b_contents.p2);
lisp r = Qnil;
for (const textprop *t = bp->b_textprop; t && *t < end; t = t->t_next)
if (*t > start)
{
lisp x = Qnil;
int attrib = t->t_attrib;
if (attrib & TEXTPROP_EXTEND_EOL_BIT)
x = push_attrib (x, Kextend, Qt);
if (attrib & 0xff)
x = push_attrib (x, Kprefix, make_char (attrib & 0xff));
if (attrib & GLYPH_STRIKEOUT)
x = push_attrib (x, Kstrike_out, Qt);
if (attrib & GLYPH_UNDERLINE)
x = push_attrib (x, Kunderline, Qt);
if (attrib & GLYPH_BOLD)
x = push_attrib (x, Kbold, Qt);
if (attrib & ((GLYPH_TEXTPROP_NCOLORS - 1) << GLYPH_TEXTPROP_BG_SHIFT_BITS))
x = push_attrib (x, Kbackground,
make_fixnum ((attrib >> GLYPH_TEXTPROP_BG_SHIFT_BITS)
& (GLYPH_TEXTPROP_NCOLORS - 1)));
if (attrib & ((GLYPH_TEXTPROP_NCOLORS - 1) << GLYPH_TEXTPROP_FG_SHIFT_BITS))
x = push_attrib (x, Kforeground,
make_fixnum ((attrib >> GLYPH_TEXTPROP_FG_SHIFT_BITS)
& (GLYPH_TEXTPROP_NCOLORS - 1)));
x = xcons (t->t_tag, x);
x = xcons (make_fixnum (t->t_range.p2), x);
x = xcons (make_fixnum (t->t_range.p1), x);
r = xcons (x, r);
}
return Fnreverse (r);
}
| [
"[email protected]"
]
| [
[
[
1,
1990
]
]
]
|
a9ca2168d0ffa65346f4ce6587d5a1d20aa9f99b | 035288d85c21cb6494d5f03c1fafb58a31810988 | /CS6620 Symmetry/pmvs_base/numeric/vec4.h | ff40835cef2f78610d477218878368eb79bdc9a2 | []
| no_license | AySz88/cs6620-symmetry | b0a658186a8876da6de51c5e28a29059fd596f05 | f189c56b45973cc7d8cf3e525b00787c86cab094 | refs/heads/master | 2016-09-10T02:12:57.637244 | 2009-12-17T23:09:44 | 2009-12-17T23:09:44 | 40,057,637 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,437 | h | #ifndef NUMERIC_VEC4_H
#define NUMERIC_VEC4_H
#include <cmath>
#include "vec3.h"
template<class T>
class TVec4 {
private:
T m_elt[4];
public:
// Standard constructors
//
TVec4(T s=0) { *this = s; }
TVec4(T x, T y, T z, T w) { m_elt[0]=x; m_elt[1]=y; m_elt[2]=z; m_elt[3]=w; }
// Copy constructors & assignment operators
template<class U> TVec4(const TVec4<U>& v) { *this = v; }
template<class U> TVec4(const TVec3<U>& v,T w)
{ m_elt[0]=v[0]; m_elt[1]=v[1]; m_elt[2]=v[2]; m_elt[3]=w; }
template<class U> TVec4(const U v[4])
{ m_elt[0]=v[0]; m_elt[1]=v[1]; m_elt[2]=v[2]; m_elt[3]=v[3]; }
template<class U> TVec4& operator=(const TVec4<U>& v)
{ m_elt[0]=v[0]; m_elt[1]=v[1]; m_elt[2]=v[2]; m_elt[3]=v[3]; return *this; }
TVec4& operator=(T s) { m_elt[0]=m_elt[1]=m_elt[2]=m_elt[3]=s; return *this; }
// Descriptive interface
//
typedef T value_type;
static int size() { return 4; }
// Access methods
//
operator T*() { return m_elt; }
operator const T*() const { return m_elt; }
T& operator[](int i) { return m_elt[i]; }
T operator[](int i) const { return m_elt[i]; }
operator const T*() { return m_elt; }
// Assignment and in-place arithmetic methods
//
inline TVec4& operator+=(const TVec4& v);
inline TVec4& operator-=(const TVec4& v);
inline TVec4& operator*=(T s);
inline TVec4& operator/=(T s);
inline bool operator==(const TVec4& v) const;
inline bool operator!=(const TVec4& v) const;
inline T norm2(void) const{
return (*this) * (*this);
}
inline T norm(void) const{
return sqrt(norm2());
}
inline void unitize(void) {
const T denom2 = norm2();
if(denom2 != 1.0 && denom2 != 0.0 ) {
const T denom = sqrt(denom2);
m_elt[0] /= denom; m_elt[1] /= denom;
m_elt[2] /= denom; m_elt[3] /= denom;
}
}
};
////////////////////////////////////////////////////////////////////////
//
// Method definitions
//
template<class T> inline TVec4<T>& TVec4<T>::operator+=(const TVec4<T>& v)
{ m_elt[0]+=v[0]; m_elt[1]+=v[1]; m_elt[2]+=v[2]; m_elt[3]+=v[3]; return *this;};
template<class T> inline TVec4<T>& TVec4<T>::operator-=(const TVec4<T>& v)
{ m_elt[0]-=v[0]; m_elt[1]-=v[1]; m_elt[2]-=v[2]; m_elt[3]-=v[3]; return *this;};
template<class T> inline TVec4<T>& TVec4<T>::operator*=(T s)
{ m_elt[0] *= s; m_elt[1] *= s; m_elt[2] *= s; m_elt[3] *= s; return *this; };
template<class T> inline TVec4<T>& TVec4<T>::operator/=(T s)
{ m_elt[0] /= s; m_elt[1] /= s; m_elt[2] /= s; m_elt[3] /= s; return *this; };
template<class T> inline bool TVec4<T>::operator==(const TVec4<T>& v) const{
if (m_elt[0] == v.m_elt[0] && m_elt[1] == v.m_elt[1] &&
m_elt[2] == v.m_elt[2] && m_elt[3] == v.m_elt[3])
return true;
else
return false;
};
template<class T> inline bool TVec4<T>::operator!=(const TVec4<T>& v) const{
return !(*this == v);
};
////////////////////////////////////////////////////////////////////////
//
// Operator definitions
//
template<class T>
inline TVec4<T> operator+(const TVec4<T> &u, const TVec4<T> &v)
{ return TVec4<T>(u[0]+v[0], u[1]+v[1], u[2]+v[2], u[3]+v[3]); };
template<class T>
inline TVec4<T> operator-(const TVec4<T> &u, const TVec4<T>& v)
{ return TVec4<T>(u[0]-v[0], u[1]-v[1], u[2]-v[2], u[3]-v[3]); };
template<class T> inline TVec4<T> operator-(const TVec4<T> &u)
{ return TVec4<T>(-u[0], -u[1], -u[2], -u[3]); };
template<class T, class N> inline TVec4<T> operator*(N s, const TVec4<T> &v)
{ return TVec4<T>(v[0]*s, v[1]*s, v[2]*s, v[3]*s); };
template<class T, class N> inline TVec4<T> operator*(const TVec4<T> &v, N s)
{ return s*v; };
template<class T, class N> inline TVec4<T> operator/(const TVec4<T> &v, N s)
{ return TVec4<T>(v[0]/s, v[1]/s, v[2]/s, v[3]/s); };
template<class T> inline T operator*(const TVec4<T> &u, const TVec4<T> &v)
{ return u[0]*v[0] + u[1]*v[1] + u[2]*v[2] + u[3]*v[3]; };
template<class T>
inline std::ostream &operator<<(std::ostream &out, const TVec4<T>& v)
{ return out <<v[0] <<" " <<v[1] <<" " <<v[2] <<" " <<v[3]; };
template<class T>
inline std::istream &operator>>(std::istream &in, TVec4<T>& v)
{ return in >> v[0] >> v[1] >> v[2] >> v[3]; };
////////////////////////////////////////////////////////////////////////
//
// Misc. function definitions
//
template<class T>
inline TVec4<T> cross(const TVec4<T>& a, const TVec4<T>& b, const TVec4<T>& c)
{
// Code adapted from VecLib4d.c in Graphics Gems V
T d1 = (b[2] * c[3]) - (b[3] * c[2]);
T d2 = (b[1] * c[3]) - (b[3] * c[1]);
T d3 = (b[1] * c[2]) - (b[2] * c[1]);
T d4 = (b[0] * c[3]) - (b[3] * c[0]);
T d5 = (b[0] * c[2]) - (b[2] * c[0]);
T d6 = (b[0] * c[1]) - (b[1] * c[0]);
return TVec4<T>(- a[1] * d1 + a[2] * d2 - a[3] * d3,
a[0] * d1 - a[2] * d4 + a[3] * d5,
- a[0] * d2 + a[1] * d4 - a[3] * d6,
a[0] * d3 - a[1] * d5 + a[2] * d6);
};
template<class T>
inline TVec4<T> cross(const TVec4<T>& u, const TVec4<T>& v) {
// Code adapted from VecLib4d.c in Graphics Gems V
return TVec4<T>(u[1]*v[2] - v[1]*u[2],
-u[0]*v[2] + v[0]*u[2],
u[0]*v[1] - v[0]*u[1],
0);
};
template<class T> inline T norm2(const TVec4<T>& v) { return v*v; };
template<class T> inline T norm(const TVec4<T>& v) { return sqrt(norm2(v)); };
template<class T> inline void unitize(TVec4<T>& v)
{
T l = norm2(v);
if( l!=1.0 && l!=0.0 ) v /= sqrt(l);
};
template<class T> inline TVec3<T> proj(const TVec4<T>& v)
{
TVec3<T> u(v[0], v[1], v[2]);
if( v[3]!=1.0 && v[3]!=0.0 )
u /= v[3];
return u;
};
template<class T>
bool predVec40(const TVec4<T>& lhs, const TVec4<T>& rhs) {
if (lhs[0] < rhs[0])
return true;
else
return false;
};
template<class T>
bool predVec41(const TVec4<T>& lhs, const TVec4<T>& rhs) {
if (lhs[1] < rhs[1])
return true;
else
return false;
};
template<class T>
bool predVec42(const TVec4<T>& lhs, const TVec4<T>& rhs) {
if (lhs[2] < rhs[2])
return true;
else
return false;
};
template<class T>
bool predVec43(const TVec4<T>& lhs, const TVec4<T>& rhs) {
if (lhs[3] < rhs[3])
return true;
else
return false;
};
typedef TVec4<double> Vec4;
typedef TVec4<float> Vec4f;
typedef TVec4<int> Vec4i;
template<class T>
struct Svec4cmp {
bool operator()(const TVec4<T>& lhs, const TVec4<T>& rhs) const {
if (lhs[0] < rhs[0] ||
(lhs[0] == rhs[0] && lhs[1] < rhs[1]) ||
(lhs[0] == rhs[0] && lhs[1] == rhs[1] && lhs[2] < rhs[2]) ||
(lhs[0] == rhs[0] && lhs[1] == rhs[1] &&
lhs[2] == rhs[2] && lhs[3] < rhs[3]))
return true;
else
return false;
}
};
template<class T> inline void ortho(const TVec4<T>& z,
TVec4<T>& x, TVec4<T>& y) {
if (fabs(z[0]) > 0.5) {
x[0] = z[1]; x[1] = -z[0]; x[2] = 0;
}
else if (fabs(z[1]) > 0.5) {
x[1] = z[2]; x[2] = -z[1]; x[0] = 0;
}
else {
x[2] = z[0]; x[0] = -z[2]; x[1] = 0;
}
unitize(x);
y[0] = z[1] * x[2] - z[2] * x[1];
y[1] = z[2] * x[0] - z[0] * x[2];
y[2] = z[0] * x[1] - z[1] * x[0];
};
#endif // VEC4_H
| [
"[email protected]"
]
| [
[
[
1,
250
]
]
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.