本文整理汇总了C++中std::map::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ map::empty方法的具体用法?C++ map::empty怎么用?C++ map::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::map
的用法示例。
在下文中一共展示了map::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WindowProc
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM lParam) {
BrowserWindow* browser = 0;
BOOL b = 0;
WORD childEvent = 0;
HWND childHandle = 0;
HWND shellBrowserHandle = 0;
switch (uMsg) {
case WM_SIZE:
browser = GetBrowserWindow(hwnd);
if (browser) {
browser->OnSize();
} else {
LOG_WARNING << "WindowProc(): event WM_SIZE: "
"could not fetch BrowserWindow";
}
break;
case WM_CREATE:
if (GetWindow(hwnd, GW_OWNER)) {
browser = new BrowserWindow(hwnd, true);
} else {
browser = new BrowserWindow(hwnd, false);
}
StoreBrowserWindow(hwnd, browser);
return 0;
case WM_DESTROY:
LOG_DEBUG << "WM_DESTROY";
RemoveBrowserWindow(hwnd);
if (g_browserWindows.empty()) {
StopWebServer();
#ifdef DEBUG
// Debugging mongoose, see InitializeLogging().
printf("----------------------------------------");
printf("----------------------------------------\n");
#endif
// Cannot call PostQuitMessage as cookies won't be flushed to disk
// if application is closed immediately. See comment #2:
// https://code.google.com/p/phpdesktop/issues/detail?id=146
// I suppose that this PostQuitMessage was added here so that
// application is forced to exit cleanly in case Mongoose
// web server hanged while stopping it, as I recall such case.
// -------------------
// PostQuitMessage(0);
// -------------------
}
return 0;
case WM_GETMINMAXINFO:
browser = GetBrowserWindow(hwnd);
if (browser) {
browser->OnGetMinMaxInfo(uMsg, wParam, lParam);
return 0;
} else {
// GetMinMaxInfo may fail during window creation, so
// log severity is only DEBUG.
LOG_DEBUG << "WindowProc(): event WM_GETMINMAXINFO: "
"could not fetch BrowserWindow";
}
break;
case WM_SETFOCUS:
browser = GetBrowserWindow(hwnd);
if (browser) {
browser->SetFocus();
return 0;
} else {
LOG_DEBUG << "WindowProc(): event WM_SETFOCUS: "
"could not fetch BrowserWindow";
}
break;
case WM_ERASEBKGND:
browser = GetBrowserWindow(hwnd);
if (browser && browser->GetCefBrowser().get()) {
CefWindowHandle hwnd = \
browser->GetCefBrowser()->GetHost()->GetWindowHandle();
if (hwnd) {
// Dont erase the background if the browser window has been loaded
// (this avoids flashing)
return 1;
}
}
break;
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
示例2: GetDelimiter
char_t Tokenizer::GetDelimiter(TokenRange range) const {
// Symbols are sorted by their precedence, in decreasing order. While the most
// common delimiters are underscore, space and dot, we give comma the priority
// to handle the case where words are separated by ", ". Besides, we'll be
// trimming whitespace later on.
static const string_t kDelimiterTable = L",_ .-+;&|~";
// Trim whitespace so that it doesn't interfere with our frequency analysis.
// This proves useful for handling some edge cases, and it doesn't seem to
// have any side effects.
if (!TrimWhitespace(filename_, range))
return L' ';
static std::map<char_t, size_t> frequency;
if (frequency.empty()) {
// Initialize frequency map
for (const auto& character : kDelimiterTable) {
frequency.insert(std::make_pair(character, 0));
}
} else {
// Reset frequency map
for (auto& pair : frequency) {
pair.second = 0;
}
}
// Count all possible delimiters
for (size_t i = range.offset; i < range.offset + range.size; i++) {
const char_t character = filename_.at(i);
if (IsAlphanumericChar(character))
continue;
if (frequency.find(character) == frequency.end())
continue;
frequency.at(character) += 1;
}
char_t delimiter = L'\0';
for (const auto& pair : frequency) {
if (pair.second == 0)
continue;
// Initialize delimiter at first iteration
if (delimiter == L'\0') {
delimiter = pair.first;
continue;
}
int character_distance =
static_cast<int>(kDelimiterTable.find(pair.first)) -
static_cast<int>(kDelimiterTable.find(delimiter));
// If the distance is negative, then the new delimiter has higher priority
if (character_distance < 0) {
delimiter = pair.first;
continue;
}
// Even if the new delimiter has lower priority, it may be much more common
float frequency_ratio = static_cast<float>(pair.second) /
static_cast<float>(frequency[delimiter]);
// The constant value was chosen by trial and error. There should be room
// for improvement.
if (frequency_ratio / abs(character_distance) > 0.8f)
delimiter = pair.first;
}
return delimiter;
}
示例3: if
//.........这里部分代码省略.........
if (*s != ')') {
return def;
}
++s;
if (hasp && hasd) return def;
if (hasp) {
val = static_cast<guint>(floor(CLAMP(r, 0.0, 100.0) * 2.559999)) << 24;
val |= (static_cast<guint>(floor(CLAMP(g, 0.0, 100.0) * 2.559999)) << 16);
val |= (static_cast<guint>(floor(CLAMP(b, 0.0, 100.0) * 2.559999)) << 8);
} else {
val = static_cast<guint>(CLAMP(r, 0, 255)) << 24;
val |= (static_cast<guint>(CLAMP(g, 0, 255)) << 16);
val |= (static_cast<guint>(CLAMP(b, 0, 255)) << 8);
}
if (end_ptr) {
*end_ptr = s;
}
return val;
} else if (strneq(str, "hsl(", 4)) {
gchar *ptr = (gchar *) str + 4;
gchar *e; // ptr after read
double h = g_ascii_strtod(ptr, &e); // Read h (0-360)
if (ptr == e) return def; // Read failed
ptr = e;
while (*ptr && g_ascii_isspace(*ptr)) ptr += 1; // Remove any white space
if (*ptr != ',') return def; // Need comma
ptr += 1;
while (*ptr && g_ascii_isspace(*ptr)) ptr += 1; // Remove any white space
double s = g_ascii_strtod(ptr, &e); // Read s (percent)
if (ptr == e) return def; // Read failed
ptr = e;
while (*ptr && g_ascii_isspace(*ptr)) ptr += 1; // Remove any white space
if (*ptr != '%') return def; // Need %
ptr += 1;
while (*ptr && g_ascii_isspace(*ptr)) ptr += 1; // Remove any white space
if (*ptr != ',') return def; // Need comma
ptr += 1;
while (*ptr && g_ascii_isspace(*ptr)) ptr += 1; // Remove any white space
double l = g_ascii_strtod(ptr, &e); // Read l (percent)
if (ptr == e) return def; // Read failed
ptr = e;
while (*ptr && g_ascii_isspace(*ptr)) ptr += 1; // Remove any white space
if (*ptr != '%') return def; // Need %
ptr += 1;
if (end_ptr) {
*end_ptr = ptr;
}
// Normalize to 0..1
h /= 360.0;
s /= 100.0;
l /= 100.0;
gfloat rgb[3];
sp_color_hsl_to_rgb_floatv( rgb, h, s, l );
val = static_cast<guint>(floor(CLAMP(rgb[0], 0.0, 1.0) * 255.9999)) << 24;
val |= (static_cast<guint>(floor(CLAMP(rgb[1], 0.0, 1.0) * 255.9999)) << 16);
val |= (static_cast<guint>(floor(CLAMP(rgb[2], 0.0, 1.0) * 255.9999)) << 8);
return val;
} else {
gint i;
if (colors.empty()) {
colors = sp_svg_create_color_hash();
}
gchar c[32];
for (i = 0; i < 31; i++) {
if (str[i] == ';' || g_ascii_isspace(str[i])) {
c[i] = '\0';
break;
}
c[i] = g_ascii_tolower(str[i]);
if (!str[i]) break;
}
c[31] = '\0';
if (colors.count(string(c))) {
val = colors[string(c)];
}
else {
return def;
}
if (end_ptr) {
*end_ptr = str + i;
}
}
return (val << 8);
}
示例4: ParseScript
CScript ParseScript(const std::string& s)
{
CScript result;
static std::map<std::string, opcodetype> mapOpNames;
if (mapOpNames.empty())
{
for (int op = 0; op <= OP_NOP10; op++)
{
// Allow OP_RESERVED to get into mapOpNames
if (op < OP_NOP && op != OP_RESERVED)
continue;
const char* name = GetOpName((opcodetype)op);
if (strcmp(name, "OP_UNKNOWN") == 0)
continue;
std::string strName(name);
mapOpNames[strName] = (opcodetype)op;
// Convenience: OP_ADD and just ADD are both recognized:
boost::algorithm::replace_first(strName, "OP_", "");
mapOpNames[strName] = (opcodetype)op;
}
}
std::vector<std::string> words;
boost::algorithm::split(words, s, boost::algorithm::is_any_of(" \t\n"), boost::algorithm::token_compress_on);
for (std::vector<std::string>::const_iterator w = words.begin(); w != words.end(); ++w)
{
if (w->empty())
{
// Empty string, ignore. (boost::split given '' will return one word)
}
else if (all(*w, boost::algorithm::is_digit()) ||
(boost::algorithm::starts_with(*w, "-") && all(std::string(w->begin()+1, w->end()), boost::algorithm::is_digit())))
{
// Number
int64_t n = atoi64(*w);
result << n;
}
else if (boost::algorithm::starts_with(*w, "0x") && (w->begin()+2 != w->end()) && IsHex(std::string(w->begin()+2, w->end())))
{
// Raw hex data, inserted NOT pushed onto stack:
std::vector<unsigned char> raw = ParseHex(std::string(w->begin()+2, w->end()));
result.insert(result.end(), raw.begin(), raw.end());
}
else if (w->size() >= 2 && boost::algorithm::starts_with(*w, "'") && boost::algorithm::ends_with(*w, "'"))
{
// Single-quoted string, pushed as data. NOTE: this is poor-man's
// parsing, spaces/tabs/newlines in single-quoted strings won't work.
std::vector<unsigned char> value(w->begin()+1, w->end()-1);
result << value;
}
else if (mapOpNames.count(*w))
{
// opcode, e.g. OP_ADD or ADD:
result << mapOpNames[*w];
}
else
{
throw std::runtime_error("script parse error");
}
}
return result;
}
示例5: isEmpty
inline bool KerningTable::isEmpty() const
{
return pairs.empty();
}
示例6: unrender
void halo_impl::unrender(std::set<map_location> invalidated_locations)
{
if(preferences::show_haloes() == false || haloes.empty()) {
return;
}
//assert(invalidated_haloes.empty());
// Remove expired haloes
std::map<int, effect>::iterator itor = haloes.begin();
for(; itor != haloes.end(); ++itor ) {
if(itor->second.expired()) {
deleted_haloes.insert(itor->first);
}
}
// Add the haloes marked for deletion to the invalidation set
std::set<int>::const_iterator set_itor = deleted_haloes.begin();
for(; set_itor != deleted_haloes.end(); ++set_itor) {
invalidated_haloes.insert(*set_itor);
haloes.find(*set_itor)->second.add_overlay_location(invalidated_locations);
}
// Test the multi-frame haloes whether they need an update
for(set_itor = changing_haloes.begin();
set_itor != changing_haloes.end(); ++set_itor) {
if(haloes.find(*set_itor)->second.need_update()) {
invalidated_haloes.insert(*set_itor);
haloes.find(*set_itor)->second.add_overlay_location(invalidated_locations);
}
}
// Find all halo's in a the invalidated area
size_t halo_count;
// Repeat until set of haloes in the invalidated area didn't change
// (including none found) or all existing haloes are found.
do {
halo_count = invalidated_haloes.size();
for(itor = haloes.begin(); itor != haloes.end(); ++itor) {
// Test all haloes not yet in the set
// which match one of the locations
if(invalidated_haloes.find(itor->first) == invalidated_haloes.end() &&
(itor->second.location_not_known() ||
itor->second.on_location(invalidated_locations))) {
// If found, add all locations which the halo invalidates,
// and add it to the set
itor->second.add_overlay_location(invalidated_locations);
invalidated_haloes.insert(itor->first);
}
}
} while (halo_count != invalidated_haloes.size() && halo_count != haloes.size());
if(halo_count == 0) {
return;
}
// Render the haloes:
// iterate through all the haloes and invalidate if in set
for(std::map<int, effect>::reverse_iterator ritor = haloes.rbegin(); ritor != haloes.rend(); ++ritor) {
if(invalidated_haloes.find(ritor->first) != invalidated_haloes.end()) {
ritor->second.unrender();
}
}
// Really delete the haloes marked for deletion
for(set_itor = deleted_haloes.begin(); set_itor != deleted_haloes.end(); ++set_itor) {
// It can happen a deleted halo hasn't been rendered yet, invalidate them as well
new_haloes.erase(*set_itor);
changing_haloes.erase(*set_itor);
invalidated_haloes.erase(*set_itor);
haloes.erase(*set_itor);
}
deleted_haloes.clear();
}
示例7: CreateObjectOnScene
void GD_API CreateObjectOnScene(RuntimeScene & scene, std::map <gd::String, std::vector<RuntimeObject*> *> pickedObjectLists, float positionX, float positionY, const gd::String & layer)
{
if ( pickedObjectLists.empty() ) return;
::DoCreateObjectOnScene(scene, pickedObjectLists.begin()->first, pickedObjectLists, positionX, positionY, layer);
}
示例8: UpdateAI
//.........这里部分代码省略.........
else uiGuardiansOfIcecrownTimer -= diff;
}
if (me->HasUnitState(UNIT_STATE_CASTING))
return;
if (uint32 eventId = events.GetEvent())
{
switch (eventId)
{
case EVENT_BOLT:
DoCastVictim(RAID_MODE(SPELL_FROST_BOLT, H_SPELL_FROST_BOLT));
events.RepeatEvent(urand(5000, 10000));
break;
case EVENT_NOVA:
DoCastAOE(RAID_MODE(SPELL_FROST_BOLT_AOE, H_SPELL_FROST_BOLT_AOE));
events.RepeatEvent(urand(15000, 30000));
break;
case EVENT_CHAIN:
{
uint32 count = urand(1, 3);
for (uint8 i = 1; i <= count; i++)
{
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 200, true);
if (target && !target->isCharmed() && (chained.find(target->GetGUID()) == chained.end()))
{
DoCast(target, SPELL_CHAINS_OF_KELTHUZAD);
float scale = target->GetFloatValue(OBJECT_FIELD_SCALE_X);
chained.insert(std::make_pair(target->GetGUID(), scale));
target->SetObjectScale(scale * 2);
events.ScheduleEvent(EVENT_CHAINED_SPELL, 2000); //core has 2000ms to set unit flag charm
}
}
if (!chained.empty())
Talk(SAY_CHAIN);
events.RepeatEvent(urand(100000, 180000));
break;
}
case EVENT_CHAINED_SPELL:
{
std::map<uint64, float>::iterator itr;
for (itr = chained.begin(); itr != chained.end();)
{
if (Unit* player = Unit::GetPlayer(*me, (*itr).first))
{
if (!player->isCharmed())
{
player->SetObjectScale((*itr).second);
std::map<uint64, float>::iterator next = itr;
++next;
chained.erase(itr);
itr = next;
continue;
}
if (Unit* target = SelectTarget(SELECT_TARGET_TOPAGGRO, 0, NotCharmedTargetSelector()))
{
switch (player->getClass())
{
case CLASS_DRUID:
if (urand(0, 1))
player->CastSpell(target, SPELL_MOONFIRE, false);
else
player->CastSpell(me, SPELL_LIFEBLOOM, false);
break;
case CLASS_HUNTER:
示例9: empty
bool empty() { return symbols.empty(); }
示例10: hasVariable
bool hasVariable() const { return !(VariableUses.empty() &&
VariableDefs.empty()); }
示例11: curses_start_color
int curses_start_color(void)
{
colorpairs = new pairs[100];
windowsPalette = new RGBQUAD[16];
//Load the console colors from colors.json
std::ifstream colorfile("data/raw/colors.json", std::ifstream::in | std::ifstream::binary);
try{
JsonIn jsin(colorfile);
char ch;
// Manually load the colordef object because the json handler isn't loaded yet.
jsin.eat_whitespace();
ch = jsin.peek();
if( ch == '[' ) {
jsin.start_array();
// find type and dispatch each object until array close
while (!jsin.end_array()) {
jsin.eat_whitespace();
char ch = jsin.peek();
if (ch != '{') {
std::stringstream err;
err << jsin.line_number() << ": ";
err << "expected array of objects but found '";
err << ch << "', not '{'";
throw err.str();
}
JsonObject jo = jsin.get_object();
load_colors(jo);
jo.finish();
}
} else {
// not an array?
std::stringstream err;
err << jsin.line_number() << ": ";
err << "expected object or array, but found '" << ch << "'";
throw err.str();
}
}
catch(std::string e){
throw "data/raw/colors.json: " + e;
}
if(consolecolors.empty())return SetDIBColorTable(backbuffer, 0, 16, windowsPalette);
windowsPalette[0] = BGR(ccolor("BLACK"));
windowsPalette[1] = BGR(ccolor("RED"));
windowsPalette[2] = BGR(ccolor("GREEN"));
windowsPalette[3] = BGR(ccolor("BROWN"));
windowsPalette[4] = BGR(ccolor("BLUE"));
windowsPalette[5] = BGR(ccolor("MAGENTA"));
windowsPalette[6] = BGR(ccolor("CYAN"));
windowsPalette[7] = BGR(ccolor("GRAY"));
windowsPalette[8] = BGR(ccolor("DGRAY"));
windowsPalette[9] = BGR(ccolor("LRED"));
windowsPalette[10] = BGR(ccolor("LGREEN"));
windowsPalette[11] = BGR(ccolor("YELLOW"));
windowsPalette[12] = BGR(ccolor("LBLUE"));
windowsPalette[13] = BGR(ccolor("LMAGENTA"));
windowsPalette[14] = BGR(ccolor("LCYAN"));
windowsPalette[15] = BGR(ccolor("WHITE"));
return SetDIBColorTable(backbuffer, 0, 16, windowsPalette);
}
示例12: while
void CoverTree<MetricType, RootPointPolicy, StatisticType>::
DualTreeTraverser<RuleType>::ReferenceRecursion(
CoverTree& queryNode,
std::map<int, std::vector<DualCoverTreeMapEntry> >& referenceMap)
{
// First, reduce the maximum scale in the reference map down to the scale of
// the query node.
while (!referenceMap.empty())
{
// Hacky bullshit to imitate jl cover tree.
if (queryNode.Parent() == NULL && (*referenceMap.rbegin()).first <
queryNode.Scale())
break;
if (queryNode.Parent() != NULL && (*referenceMap.rbegin()).first <=
queryNode.Scale())
break;
// If the query node's scale is INT_MIN and the reference map's maximum
// scale is INT_MIN, don't try to recurse...
if ((queryNode.Scale() == INT_MIN) &&
((*referenceMap.rbegin()).first == INT_MIN))
break;
// Get a reference to the current largest scale.
std::vector<DualCoverTreeMapEntry>& scaleVector = (*referenceMap.rbegin()).second;
// Before traversing all the points in this scale, sort by score.
std::sort(scaleVector.begin(), scaleVector.end());
// Now loop over each element.
for (size_t i = 0; i < scaleVector.size(); ++i)
{
// Get a reference to the current element.
const DualCoverTreeMapEntry& frame = scaleVector.at(i);
CoverTree<MetricType, RootPointPolicy, StatisticType>* refNode =
frame.referenceNode;
// Create the score for the children.
double score = rule.Rescore(queryNode, *refNode, frame.score);
// Now if this childScore is DBL_MAX we can prune all children. In this
// recursion setup pruning is all or nothing for children.
if (score == DBL_MAX)
{
++numPrunes;
continue;
}
// If it is not pruned, we must evaluate the base case.
// Add the children.
for (size_t j = 0; j < refNode->NumChildren(); ++j)
{
rule.TraversalInfo() = frame.traversalInfo;
double childScore = rule.Score(queryNode, refNode->Child(j));
if (childScore == DBL_MAX)
{
++numPrunes;
continue;
}
// It wasn't pruned; evaluate the base case.
const double baseCase = rule.BaseCase(queryNode.Point(),
refNode->Child(j).Point());
DualCoverTreeMapEntry newFrame;
newFrame.referenceNode = &refNode->Child(j);
newFrame.score = childScore; // Use the score of the parent.
newFrame.baseCase = baseCase;
newFrame.traversalInfo = rule.TraversalInfo();
referenceMap[newFrame.referenceNode->Scale()].push_back(newFrame);
}
}
// Now clear the memory for this scale; it isn't needed anymore.
referenceMap.erase((*referenceMap.rbegin()).first);
}
}
示例13: initialized
bool group_weights_cache_impl::initialized() {
boost::shared_lock<boost::shared_mutex> lock(shared_mutex_);
return !map_.empty();
}
示例14: ApiException
pplx::task<web::http::http_response> ApiClient::callApi(
const utility::string_t& path,
const utility::string_t& method,
const std::map<utility::string_t, utility::string_t>& queryParams,
const std::shared_ptr<IHttpBody> postBody,
const std::map<utility::string_t, utility::string_t>& headerParams,
const std::map<utility::string_t, utility::string_t>& formParams,
const std::map<utility::string_t, std::shared_ptr<HttpContent>>& fileParams,
const utility::string_t& contentType
) const
{
if (postBody != nullptr && formParams.size() != 0)
{
throw ApiException(400, utility::conversions::to_string_t("Cannot have body and form params"));
}
if (postBody != nullptr && fileParams.size() != 0)
{
throw ApiException(400, utility::conversions::to_string_t("Cannot have body and file params"));
}
if (fileParams.size() > 0 && contentType != utility::conversions::to_string_t("multipart/form-data"))
{
throw ApiException(400, utility::conversions::to_string_t("Operations with file parameters must be called with multipart/form-data"));
}
web::http::client::http_client client(m_Configuration->getBaseUrl(), m_Configuration->getHttpConfig());
web::http::http_request request;
for ( auto& kvp : headerParams )
{
request.headers().add(kvp.first, kvp.second);
}
if (fileParams.size() > 0)
{
MultipartFormData uploadData;
for (auto& kvp : formParams)
{
uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second));
}
for (auto& kvp : fileParams)
{
uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second));
}
std::stringstream data;
uploadData.writeTo(data);
auto bodyString = data.str();
auto length = bodyString.size();
request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, utility::conversions::to_string_t("multipart/form-data; boundary=") + uploadData.getBoundary());
}
else
{
if (postBody != nullptr)
{
std::stringstream data;
postBody->writeTo(data);
auto bodyString = data.str();
auto length = bodyString.size();
request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, contentType);
}
else
{
if (contentType == utility::conversions::to_string_t("application/json"))
{
web::json::value body_data = web::json::value::object();
for (auto& kvp : formParams)
{
body_data[kvp.first] = ModelBase::toJson(kvp.second);
}
if (!formParams.empty())
{
request.set_body(body_data);
}
}
else
{
web::http::uri_builder formData;
for (auto& kvp : formParams)
{
formData.append_query(kvp.first, kvp.second);
}
if (!formParams.empty())
{
request.set_body(formData.query(), utility::conversions::to_string_t("application/x-www-form-urlencoded"));
}
}
}
}
web::http::uri_builder builder(path);
for (auto& kvp : queryParams)
{
builder.append_query(kvp.first, kvp.second);
}
request.set_request_uri(builder.to_uri());
request.set_method(method);
if ( !request.headers().has( web::http::header_names::user_agent ) )
{
request.headers().add( web::http::header_names::user_agent, m_Configuration->getUserAgent() );
//.........这里部分代码省略.........
示例15: transformAS
std::string CSeqWriter::transformAS( CSeqLog &log, const char* packetPath, std::list<std::string> &import, std::map< std::string, std::string > &classDir )
{
if ( log.className == "SPackHead" )
log.className = "SPackHead";
std::list<std::string> importList = import;
//import 统计
if ( !classDir.empty() )
parseImport( log, classDir, importList );
std::stringstream stream;
//输出package{
stream << "package";
if ( packetPath != NULL && packetPath[0] != '\0' )
stream << " " << packetPath;
stream << std::endl;
stream << '{' << std::endl;
//输出import
for ( std::vector< wd::CSeqEle >::iterator iter = log.eleList.begin();
iter != log.eleList.end();
++iter )
{
if ( VarType2As( iter->eleType ) == "ByteArray" )
{
stream << taps << "import flash.utils.ByteArray;" << std::endl;
break;
}
}
if ( !importList.empty() )
{
for ( std::list<std::string>::iterator iter = importList.begin();
iter != importList.end();
++iter )
{
stream << taps << "import " << *iter << ";" << std::endl;
}
}
stream << std::endl;
//输出注释
if ( !log.classDescript.empty() )
{
std::string descript = log.classDescript;
for ( int i = (int)descript.find_first_of( '\n' ); i >= 0 && i < (int)descript.length(); )
{
if ( descript[i] == '\n' )
{
descript.insert( i + 1, taps );
i += sizeof( taps );
}
else
++i;
}
stream << taps << "/*" << descript << "*/" << std::endl;
}
//输出类名
stream << taps << "public class " << log.className;
//输出父类
if ( !log.classParent.empty() )
stream << " extends " << log.classParent;
else
stream << " extends CSeq";
stream << std::endl;
//类 {
stream << taps << '{' << std::endl;
for ( std::vector< wd::CSeqEle >::iterator iter = log.eleList.begin();
iter != log.eleList.end();
++iter )
{
std::string init_type;
stream << taps << taps << "public var " << iter->eleName << ':' << output_element_as( *iter, init_type );
if ( !init_type.empty() )
stream << " = " << init_type;
stream << ";";
if ( !iter->eleDescript.empty() )
stream << taps << "//" << iter->eleDescript;
stream << std::endl;
}
stream << std::endl;
//输出构造
stream << taps << taps << "public function " << log.className << "()" << std::endl;
stream << taps << taps << '{' << std::endl;
stream << taps << taps << taps << "elementInfo = static_element_info;" << std::endl;
//输出构造项
if ( !log.initList.empty() )
{
stream << std::endl;
for ( std::vector< CSeqInit >::iterator iter = log.initList.begin();
//.........这里部分代码省略.........